-
Notifications
You must be signed in to change notification settings - Fork 502
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
Comments
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 So you can just change the line |
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 Test builds and discussion here: pimoroni/badger2040#2 |
I tried that but getting the following error:
import time
import machine
import ntptime
import badger2040
display = badger2040.Badger2040()
display.set_update_speed(2)
display.set_thickness(4)
WIDTH, HEIGHT = display.get_bounds()
try:
display.connect()
if display.isconnected():
ntptime.settime(timezone=-4)
except (RuntimeError, OSError):
pass # no WiFI
rtc = machine.RTC()
display.set_font("sans")
———
>> %Run -c $EDITOR_CONTENT
Client True 192.168.7.141
Traceback (most recent call last):
File "<stdin>", line 16, in <module>
TypeError: unexpected keyword argument 'timezone'
…>>
On Mar 21, 2023, at 10:21 AM, Philip Howard ***@***.***> wrote:
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.
—
Reply to this email directly, view it on GitHub <#721 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ALLFSBLTFJGTPQYMUZS3SUTW5G2NBANCNFSM6AAAAAAWBY3AI4>.
You are receiving this because you authored the thread.
|
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 |
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?
The text was updated successfully, but these errors were encountered: