Skip to content

RTC enabled #3422

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 4 commits into from
Sep 16, 2020
Merged

RTC enabled #3422

merged 4 commits into from
Sep 16, 2020

Conversation

askpatrickw
Copy link

@askpatrickw askpatrickw commented Sep 15, 2020

I looked at the other ports, picked the simplest one that had RTC an copied it.
In the original port it used tv in the espressif docs it used tv_now.
This is a partial implemenation for #3321

NOTES:

  • I'm not sure if the calibration stuff which was essentially n\a in the one I copied should be implemented for the ESP32S2
  • In the Espessif config you can configure different sources for the RTC to run off. Currently we're using ESP32S2_RTC_CLK_SRC_INT_RC. It might be better (but more power hungry) to use ESP32S2_RTC_CLK_SRC_INT_8MD256 as they claim it has less wander. I'm not 100% sure if that's going to be true with CP today as I believe this has to do with lower power modes.

Seems like its working... Tested on a Kaluga

>>> import time
>>> import rtc
>>> r = rtc.RTC()
>>> r.datetime = time.struct_time((2020, 9, 14, 23, 22, 15, 0, -1, -1))
>>> current_time = r.datetime
>>> print(current_time)
struct_time(tm_year=2020, tm_mon=9, tm_mday=14, tm_hour=23, tm_min=22, tm_sec=25, tm_wday=0, tm_yday=258, tm_isdst=-1)
>>> help("modules")
__main__          errno             neopixel_write    struct
_os               espidf            os                supervisor
_pixelbuf         fontio            pulseio           sys
_time             framebufferio     pwmio             terminalio
array             gamepad           random            time
bitbangio         gc                re                touchio
board             io                rtc               ulab
builtins          ipaddress         sdcardio          usb_hid
busio             json              sharpdisplay      vectorio
collections       math              socketpool        wifi
digitalio         microcontroller   ssl
displayio         micropython       storage
Plus any modules on the filesystem

@tannewt tannewt self-requested a review September 15, 2020 18:06
@tannewt tannewt added enhancement espressif applies to multiple Espressif chips labels Sep 15, 2020
@tannewt tannewt added this to the 6.x.0 - Features milestone Sep 15, 2020
Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

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

One question. Otherwise, this looks good. Thank you!

@askpatrickw askpatrickw requested a review from tannewt September 15, 2020 18:30
Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

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

Great! Thank you!

@tannewt tannewt merged commit fb90daa into adafruit:main Sep 16, 2020
@askpatrickw askpatrickw deleted the rtc-support branch September 16, 2020 18:14
@anecdata
Copy link
Member

fwiw, calibration is enabled on SAMD51, but it's a small adjustment relative to some typical drifts. For example, my PyPortal gains about a second per minute, well outside of the calibration range.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement espressif applies to multiple Espressif chips
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants