kopia lustrzana https://github.com/pimoroni/pimoroni-pico
added exception handling
rodzic
9f8596c031
commit
797c0bbfd4
|
@ -34,7 +34,10 @@ def approx_time(hours, minutes):
|
||||||
def update():
|
def update():
|
||||||
global time_string
|
global time_string
|
||||||
# grab the current time from the ntp server and update the Pico RTC
|
# grab the current time from the ntp server and update the Pico RTC
|
||||||
ntptime.settime()
|
try:
|
||||||
|
ntptime.settime()
|
||||||
|
except OSError:
|
||||||
|
print("Unable to contact NTP server")
|
||||||
|
|
||||||
current_t = rtc.datetime()
|
current_t = rtc.datetime()
|
||||||
time_string = approx_time(current_t[4] - 12 if current_t[4] > 12 else current_t[4], current_t[5])
|
time_string = approx_time(current_t[4] - 12 if current_t[4] > 12 else current_t[4], current_t[5])
|
||||||
|
|
Ładowanie…
Reference in New Issue