kopia lustrzana https://github.com/pimoroni/pimoroni-pico
Merge pull request #678 from pimoroni/patch-cosmic-example
Patch: fixed error caused by missing secrets.pypull/680/head
commit
b08cf1fba0
|
@ -24,11 +24,12 @@ rtc = machine.RTC()
|
||||||
|
|
||||||
DAYS = ["Mon", "Tue", "Wed", "Thur", "Fri", "Sat", "Sun"]
|
DAYS = ["Mon", "Tue", "Wed", "Thur", "Fri", "Sat", "Sun"]
|
||||||
|
|
||||||
|
# Enable the Wireless
|
||||||
|
wlan = network.WLAN(network.STA_IF)
|
||||||
|
wlan.active(True)
|
||||||
|
|
||||||
|
|
||||||
def network_connect(SSID, PSK):
|
def network_connect(SSID, PSK):
|
||||||
# Enable the Wireless
|
|
||||||
wlan = network.WLAN(network.STA_IF)
|
|
||||||
wlan.active(True)
|
|
||||||
|
|
||||||
# Number of attempts to make before timeout
|
# Number of attempts to make before timeout
|
||||||
max_wait = 5
|
max_wait = 5
|
||||||
|
@ -52,12 +53,16 @@ def network_connect(SSID, PSK):
|
||||||
# Function to sync the Pico RTC using NTP
|
# Function to sync the Pico RTC using NTP
|
||||||
def sync_time():
|
def sync_time():
|
||||||
|
|
||||||
network_connect(WIFI_SSID, WIFI_PASSWORD)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ntptime.settime()
|
network_connect(WIFI_SSID, WIFI_PASSWORD)
|
||||||
except OSError:
|
except NameError:
|
||||||
print("Unable to sync with NTP server. Check network and try again.")
|
print("Create secrets.py with your WiFi credentials")
|
||||||
|
|
||||||
|
if wlan.status() < 0 or wlan.status() >= 3:
|
||||||
|
try:
|
||||||
|
ntptime.settime()
|
||||||
|
except OSError:
|
||||||
|
print("Unable to sync with NTP server. Check network and try again.")
|
||||||
|
|
||||||
|
|
||||||
def init():
|
def init():
|
||||||
|
|
Ładowanie…
Reference in New Issue