Skip to content
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

badger2040w clock example time zone offset? #721

Closed
pketelaar opened this issue Mar 21, 2023 · 4 comments
Closed

badger2040w clock example time zone offset? #721

pketelaar opened this issue Mar 21, 2023 · 4 comments

Comments

@pketelaar
Copy link

https://github.com/pimoroni/pimoroni-pico/blob/main/micropython/examples/badger2040w/examples/clock.py

Doesn't include anything for a time zone offset, manually putting in an hour adjustment will not work. Can you update with the code from the non-wireless version to adjust the time to local?

@Gadgetoid
Copy link
Member

This code has been deprecated and Badger moved over to https://github.com/pimoroni/badger2040

However, your issue is still valid. It looks like the canonical way to apply a timezone offset in this case would be to get the correct time in the first place from the ntp server, since ntptime.settime() accepts an offset value: https://mpython.readthedocs.io/en/master/library/micropython/ntptime.html

So you can just change the line ntptime.settime() to ntptime.settime(timezone=HOURS) where HOURS is your desired offset (the default is 8), and replug the battery (give it a few seconds to discharge) so it syncs the time again.

@Gadgetoid
Copy link
Member

I've made some changes to clock in the new repo, including bringing back the time set functionality (which persists on a Badger W even if Thonny tries to reset the time) and surfacing a TIME_OFFSET value which I might have to do more with at some point. (Maybe making it part of WIFI_CONFIG)

Test builds and discussion here: pimoroni/badger2040#2

@pketelaar
Copy link
Author

pketelaar commented Mar 21, 2023 via email

@Gadgetoid
Copy link
Member

Oh good grief. What on earth are these docs I’ve linked to? Sorry, you’re right; I’m barking up the wrong tree here.

Nonetheless the next release of Badger 2040 should help by giving you the manual time setting back. Bear with me! And watch this space: https://github.com/pimoroni/badger2040

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

No branches or pull requests

2 participants