From 4e90dcadb48d0e3d2e587c70ce73180d0a5a4061 Mon Sep 17 00:00:00 2001 From: caternuson Date: Thu, 14 Nov 2019 15:14:46 -0800 Subject: [PATCH 1/3] change verification check --- adafruit_ds3231.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/adafruit_ds3231.py b/adafruit_ds3231.py index 4655a2e..9d8cb9a 100644 --- a/adafruit_ds3231.py +++ b/adafruit_ds3231.py @@ -54,6 +54,7 @@ #. Datasheet: https://datasheets.maximintegrated.com/en/ds/DS3231.pdf """ +import time from adafruit_bus_device.i2c_device import I2CDevice from adafruit_register import i2c_bit from adafruit_register import i2c_bcd_alarm @@ -96,14 +97,10 @@ class DS3231: def __init__(self, i2c): self.i2c_device = I2CDevice(i2c, 0x68) - # Try and verify this is the RTC we expect by checking the rate select - # control bits which are 1 on reset and shouldn't ever be changed. - buf = bytearray(2) - buf[0] = 0x0e - with self.i2c_device as i2c_device: - i2c_device.write_then_readinto(buf, buf, out_end=1, in_start=1) - - if (buf[1] & 0b00011000) != 0b00011000: + # Try and verify this is the RTC we expect by checking change in secs + check = self.datetime_register.tm_sec + time.sleep(1.1) + if self.datetime_register.tm_sec == check: raise ValueError("Unable to find DS3231 at i2c address 0x68.") @property From 82d250586d86a7396a9ee82a11a579b30f12152e Mon Sep 17 00:00:00 2001 From: caternuson Date: Thu, 14 Nov 2019 16:34:44 -0800 Subject: [PATCH 2/3] remove verification check --- adafruit_ds3231.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/adafruit_ds3231.py b/adafruit_ds3231.py index 9d8cb9a..54fdf1e 100644 --- a/adafruit_ds3231.py +++ b/adafruit_ds3231.py @@ -97,12 +97,6 @@ class DS3231: def __init__(self, i2c): self.i2c_device = I2CDevice(i2c, 0x68) - # Try and verify this is the RTC we expect by checking change in secs - check = self.datetime_register.tm_sec - time.sleep(1.1) - if self.datetime_register.tm_sec == check: - raise ValueError("Unable to find DS3231 at i2c address 0x68.") - @property def datetime(self): """Gets the current date and time or sets the current date and time From 65c458da1a31bfa6dbcde611e2cc239d324f0de4 Mon Sep 17 00:00:00 2001 From: caternuson Date: Thu, 14 Nov 2019 16:37:39 -0800 Subject: [PATCH 3/3] and that --- adafruit_ds3231.py | 1 - 1 file changed, 1 deletion(-) diff --git a/adafruit_ds3231.py b/adafruit_ds3231.py index 54fdf1e..409d787 100644 --- a/adafruit_ds3231.py +++ b/adafruit_ds3231.py @@ -54,7 +54,6 @@ #. Datasheet: https://datasheets.maximintegrated.com/en/ds/DS3231.pdf """ -import time from adafruit_bus_device.i2c_device import I2CDevice from adafruit_register import i2c_bit from adafruit_register import i2c_bcd_alarm