Skip to content

Added DS3231 RTC Featherwing #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Feb 17, 2019
Merged

Conversation

makermelissa
Copy link
Collaborator

Ok, the next FeatherWing is done. I added some cool features such as the ability to change individual numbers instead of the entire time/date structure as well as a few other goodies like checking number of days and getting/setting by unix time.

@makermelissa makermelissa requested a review from a team February 17, 2019 03:05
@jerryneedell
Copy link
Contributor

I just tried a few things ona Particle Argon with the DS3231 Featherwing and ran into this - is something missing?

>>> from adafruit_featherwing import rtc_featherwing
>>> days = ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday")
>>>
>>> rtc = rtc_featherwing.RTCFeatherWing()
>>> rtc.unixtime
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "adafruit_featherwing/rtc_featherwing.py", line 292, in unixtime
AttributeError: 'module' object has no attribute 'mktime'
>>> rtc.now
DateTime(second=8, minute=21, hour=3, day=17, month=2, year=2019, weekday=0)
>>> 

@jerryneedell
Copy link
Contributor

apparently

>>> import time
>>> dir(time)
['__class__', '__name__', 'monotonic', 'sleep', 'struct_time']
>>> 

@makermelissa
Copy link
Collaborator Author

Oh, I wonder if the mktime() is board specific. I figured all of the time functionality was the same. I'll try on my argon and see what happens.

@makermelissa
Copy link
Collaborator Author

Well, it was more of a nicety, so I can just remove that function.

@jerryneedell
Copy link
Contributor

but on the feather_m4

ress any key to enter the REPL. Use CTRL-D to reload.
Adafruit CircuitPython 4.0.0-beta.2-72-gf7a397d52 on 2019-02-16; Adafruit Feather M4 Express with samd51j19
>>> 
>>> import time
>>> dir(time)
['__class__', '__name__', 'localtime', 'mktime', 'monotonic', 'monotonic_ns', 'sleep', 'struct_time', 'time']
>>> 

@jerryneedell
Copy link
Contributor

It is a nice thing to have -- I wonder how how hard it is to get mktime into the nrf builds

@makermelissa
Copy link
Collaborator Author

It has mktime on mine, but I'm running into some other oddities on the argon. It may or may not function with the ds3231 library itself. I'll try the nrf52840 express and see how that behaves.

@makermelissa
Copy link
Collaborator Author

Yeah, I'm getting the same oddities on the nRF52840 Express. Something about tm_sec not existing, so I'll see if I can get it working on that board as well as the feather m4 express.

@makermelissa
Copy link
Collaborator Author

Ok yeah, it looks like the bug is in the DS3231 library. I can't get that example to run either.

@jerryneedell
Copy link
Contributor

you have mktime on your argon? that odd -- why don't I?

@makermelissa
Copy link
Collaborator Author

Yeah, probably because I compiled the bootloader for it myself.

@jerryneedell
Copy link
Contributor

its not from the Bootloader -- its in CP - what version of CP do you have?

@makermelissa
Copy link
Collaborator Author

4.0.0 Beta 2

@jerryneedell
Copy link
Contributor

jerryneedell commented Feb 17, 2019

what build? this is current master for nrf52840 (actually yesterdays master) -- but it is the same now

ress any key to enter the REPL. Use CTRL-D to reload.
Adafruit CircuitPython 4.0.0-beta.2-68-g619b4f13f on 2019-02-15; Adafruit Feather nRF52840 Express with nRF52840
>>> import time
>>> dir(time)
['__class__', '__name__', 'monotonic', 'sleep', 'struct_time']
>>> 

@makermelissa
Copy link
Collaborator Author

For Argon:
Adafruit CircuitPython 4.0.0-beta.2 on 2019-02-05; Particle Argon with nRF52840

For nRF52840:
Adafruit CircuitPython 4.0.0-beta.2 on 2019-02-05; Adafruit Feather nRF52840 Express with nRF52840

Both have mktime()

@jerryneedell
Copy link
Contributor

hmmm -- must have gotten removed since then ...

@makermelissa
Copy link
Collaborator Author

Mine came from the releases tab off of github, yours appears to be compiled, but I could be wrong.

@jerryneedell
Copy link
Contributor

yes - mine is built from the current master branch of the repo.

@jerryneedell
Copy link
Contributor

this looks suspicious and it was part of the recent changes, I think
https://github.com/adafruit/circuitpython/blob/a345ef28f2278dd53a33d96861c0c7d3fad6fbbe/ports/nrf/mpconfigport.mk#L23

@makermelissa
Copy link
Collaborator Author

makermelissa commented Feb 17, 2019

Yeah, I got a message about that when attempting to run localtime() on mine even though the functions are all there.

>>> import time
>>> time.localtime()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
RuntimeError: RTC is not supported on this board

@jerryneedell
Copy link
Contributor

AH -- they may have just been stubs. Not really implemented.

@makermelissa
Copy link
Collaborator Author

Oh, ok. That would explain the odd functionality.

@jerryneedell
Copy link
Contributor

so -- is the "unixtime' getter/seterr the only issue on the nrf boards?

@dhalbert
Copy link
Contributor

dhalbert commented Feb 17, 2019

It's true there's no real rtc support in nrf yet. I turned it off for that reason, but it appears that there are helper functions needed by other stuff. Could you write this up as an issue for adafruit/circuitpython listing the specific missing functionality and I'll try to make it work again.

@makermelissa
Copy link
Collaborator Author

No. The DS3231 library will not work at all on NRF boards.

@makermelissa
Copy link
Collaborator Author

Thanks for chiming in Dan. Sure, I can write something up.

@jerryneedell
Copy link
Contributor

I was able to read mine with rtc.now

@dhalbert
Copy link
Contributor

But it is in process: adafruit/circuitpython#1534

@jerryneedell
Copy link
Contributor

BTW -- Nice job on the library @makermelissa ! It makes the wing very easy to use! Thanks for creating it.

@makermelissa
Copy link
Collaborator Author

Ok, maybe there's some newer code that is addressing this functionality that hasn't been released.

@makermelissa
Copy link
Collaborator Author

Thanks Jerry. I'm aiming for code that's easy to use, but still very flexible and powerful.

@makermelissa
Copy link
Collaborator Author

Since we now know the issue is really at the level of the DS3231 library or possibly even lower than that, I'm not really sure what to do since fixing the actual problem should propagate the fix to this library.

@jerryneedell
Copy link
Contributor

It is not clear to me if there is a fundamental problem on the nrf boards supporting this library In my test, only the unixtime getter/setter seem to be an issue -- is it likely they will also work with a little magic by @dhalbert . If not, perhaps a try/except should be added for them so they can fail more gracefully. I guess it is not clear to me how using this library is impacted by the "builtin" etc module being implemented. Does that only impact the availability of mtkime/localtime?

@makermelissa
Copy link
Collaborator Author

I have added the try/except blocks as you suggested. Please try it again when you have some time (no pun intended). Thanks.

Copy link
Contributor

@jerryneedell jerryneedell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no concerns with the library so I'll go ahead and approve. There are still issues to be resolved with the nrf52840 but they are understood and in work and I don't think there is any reason to hold this up.

@makermelissa makermelissa merged commit dfa20cc into adafruit:master Feb 17, 2019
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Feb 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants