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

Add hints to pick a local NTP server, geographic and behind a NAT: examples/clock.py #37

Open
niftyhacking opened this issue Jul 21, 2023 · 1 comment

Comments

@niftyhacking
Copy link

Consider adding hints to pick a local NTP server, geographic and behind a NAT in examples/clock.py

Also:
a) Is it silly to wrap the Thonny bit in a conditional. I could not sync until I commented it out. Did Thonny change?
Does this argue with rshell use?
b) Since there are multiple fonts in examples/fonts.py hint that there are more.

% diff Current-Git-clock.py ./clock.py
16c16,24
< if display.isconnected():

    if display.isconnected(): 
        print("default NTP host is: ",ntptime.host)
        # Uncomment or edit for a 
        # local choice see https://www.ntppool.org/
        #ntptime.host = 'pool.ntp.org'
        #ntptime.host = 'server 1.north-america.pool.ntp.org'
        #ntptime.host = '2.north-america.pool.ntp.org'
        ntptime.host = '10.0.4.94'  #local behind NAT
        print("new and current NTP host is: ",ntptime.host)

22,25c30,33
< try:
< badger2040.pcf_to_pico_rtc()
< except RuntimeError:
< pass

#try:

badger2040.pcf_to_pico_rtc()

#except RuntimeError:

pass

29c37,38
< display.set_font("gothic")

#display.set_font("gothic")
display.set_font("serif")

@niftyhacking
Copy link
Author

Minor changes after updating to and testing the recent update
"MicroPython 856e08b-dirty on 2023-07-21; Pimoroni Badger2040W 2MB with RP2040"
I wanted a way to show local time so added bit from "guyd" https://forum.micropython.org/viewtopic.php?t=5145
Thank you, all is working nicely for me.

`% diff Current-Git-clock.py clock.py
16a17,25

        print("default NTP host is: ",ntptime.host)
        # Uncomment or edit one of the below
        # if default is not desired set a local choice
        # local choice see https://www.ntppool.org/
        #ntptime.host = 'pool.ntp.org'
        #ntptime.host = 'server 1.north-america.pool.ntp.org'
        #ntptime.host = '2.north-america.pool.ntp.org'
        ntptime.host = '10.0.4.94'  #local behind NAT
        print("new and current NTP host is: ",ntptime.host)

22,25c31,34
< try:
< badger2040.pcf_to_pico_rtc()
< except RuntimeError:
< pass

#try:

badger2040.pcf_to_pico_rtc()

#except RuntimeError:

pass

29c38,39
< display.set_font("gothic")

#display.set_font("gothic")
display.set_font("serif")
187a198,203
import utime
utc_shift = -7 # edit for local TZ offset.
tm = utime.localtime(utime.mktime(utime.localtime()) + utc_shift*3600)
tm = tm[0:3] + (0,) + tm[3:6] + (0,)
rtc.datetime(tm)

`

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

1 participant