added exception handling

inkyframe7-launch
thirdr 2023-02-23 10:23:30 +00:00
rodzic 9f8596c031
commit 797c0bbfd4
1 zmienionych plików z 4 dodań i 1 usunięć

Wyświetl plik

@ -34,7 +34,10 @@ def approx_time(hours, minutes):
def update():
global time_string
# 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()
time_string = approx_time(current_t[4] - 12 if current_t[4] > 12 else current_t[4], current_t[5])