adafruit / circuitpython

CircuitPython - a Python implementation for teaching coding with microcontrollers
https://circuitpython.org
Other
4.01k stars 1.19k forks source link

RTC Functionality missing from NRF making DS3231 Library Unusable #1561

Closed makermelissa closed 5 years ago

makermelissa commented 5 years ago

Regarding Discussion in PR https://github.com/adafruit/Adafruit_CircuitPython_FeatherWing/pull/27, in the latest official release (beta 2), the functions are there, but cause a BCDDateTimeRegister object to be returned. @jerryneedell had compiled a build from master on 2/15 and that was missing the mktime() and localtime() functions, but the BCDDateTimeRegister seemed to be fixed.

makermelissa commented 5 years ago

Forgot to mention, Dan mentioned there was work being done on this in #1534.

makermelissa commented 5 years ago

Ok, now that I've successfully compiled the latest version of circuitpython, it appears the specific functionality I need is the mktime() and localtime() functions in the time package.

nickzoic commented 5 years ago

G'day Melissa! PR #1534 did not turn out as well as I'd hoped but hopefully the PR #1736 should address this ...

UPDATE: OK, yeah, this now works ...

>>> import adafruit_featherwing.rtc_featherwing
>>> ext_rtc = adafruit_featherwing.rtc_featherwing.RTCFeatherWing()
>>> import rtc
>>> rtc.set_time_source(ext_rtc)
>>> import time
>>> time.localtime()
struct_time(tm_year=2006, tm_mon=5, tm_mday=4, tm_hour=10, tm_min=21, tm_sec=44, tm_wday=3, tm_yday=124, tm_isdst=-1)

... and the DS3231 module is remembering the time :-)

nickzoic commented 5 years ago

G'day @makermelissa #1736 is merged & I think it works for my very small test case, can you confirm that this works okay for you now?

makermelissa commented 5 years ago

Tested and it works great! Thanks @nickzoic.