Skip to content

Commit e3777b3

Browse files
committed
word_clock.py: handling of 'secrets.py' related errors
1 parent dd69f45 commit e3777b3

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

examples/word_clock.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,30 @@
3030
words = ["it", "d", "is", "m", "about", "lv", "half", "c", "quarter", "b", "to", "past", "n", "one",
3131
"two", "three", "four", "five", "six", "eleven", "ten", "d", "qdh", "eight", "seven", "rm", "twelve", "nine", "p", "ncsnheypresto", "O'Clock", "agrdsp"]
3232

33-
# WiFi setup
34-
wifi = presto.connect()
33+
34+
def show_message(text):
35+
display.set_pen(BLACK)
36+
display.clear()
37+
display.set_pen(WHITE)
38+
display.text(f"{text}", 5, 10, WIDTH, 2)
39+
presto.update()
40+
41+
42+
show_message("Connecting...")
43+
44+
try:
45+
wifi = presto.connect()
46+
except ValueError as e:
47+
while True:
48+
show_message(e)
49+
except ImportError as e:
50+
while True:
51+
show_message(e)
3552

3653
# Set the correct time using the NTP service.
3754
ntptime.settime()
3855

56+
3957
def approx_time(hours, minutes):
4058
nums = {0: "twelve", 1: "one", 2: "two",
4159
3: "three", 4: "four", 5: "five", 6: "six",

0 commit comments

Comments
 (0)