11import time
2- import gc
32import board
4- import displayio
53import busio
4+ import digitalio
65from adafruit_esp32spi import adafruit_esp32spi_socket as socket
7- from adafruit_esp32spi import adafruit_esp32spi , adafruit_esp32spi_wifimanager
6+ from adafruit_esp32spi import adafruit_esp32spi
87import adafruit_requests as requests
9- import digitalio
10- from analogio import AnalogIn
118from adafruit_pyportal import PyPortal
129from adafruit_bitmap_font import bitmap_font
1310from adafruit_display_text import label
14- import adafruit_touchscreen
1511
1612try :
1713 from secrets import secrets
2016the secrets dictionary must contain 'ssid' and 'password' at a minimum""" )
2117 raise
2218
23- # Colors for each label
19+ # Label colors
2420LABEL_DAY_COLOR = 0xFFFFFF
25- LABEL_TIME_COLOR = 0x8f42f4
21+ LABEL_TIME_COLOR = 0x2a8eba
2622
2723# the current working directory (where this file is)
2824cwd = ("/" + __file__ ).rsplit ('/' , 1 )[0 ]
3228
3329# Descriptions of each hour
3430# https://github.com/mwfisher3/QuarantineClock/blob/master/today.html
35- time_name = ["midnight-ish" , "late night" , "late" , "super late" ,
36- "super early" ,"really early" ,"dawn" ,"morning" ,
37- "morning" ,"mid-morning" ,"mid-morning" ,"late morning" ,
38- "noon-ish" ,"afternoon" ,"afternoon" ,"mid-afternoon" ,
39- "late afternoon" ,"early evening" ,"early evening" ,"dusk-ish" ,
40- "evening" ,"evening" ,"late evening" ,"late evening" ]
31+ time_names = ["midnight-ish" , "late night" , "late" , "super late" ,
32+ "super early" ,"really early" ,"dawn" ,"morning" ,
33+ "morning" ,"mid-morning" ,"mid-morning" ,"late morning" ,
34+ "noon-ish" ,"afternoon" ,"afternoon" ,"mid-afternoon" ,
35+ "late afternoon" ,"early evening" ,"early evening" ,"dusk-ish" ,
36+ "evening" ,"evening" ,"late evening" ,"late evening" ]
4137
4238esp32_cs = digitalio .DigitalInOut (board .ESP_CS )
4339esp32_ready = digitalio .DigitalInOut (board .ESP_BUSY )
@@ -53,13 +49,13 @@ def wday_to_weekday_name(tm_wday):
5349
5450 """
5551 switch = {
56- 0 : "Monday" ,
57- 1 : "Tuesday" ,
58- 2 : "Wednesday" ,
59- 3 : "Thursday" ,
60- 4 : "Friday" ,
61- 5 : "Saturday" ,
62- 6 : "Sunday" ,}
52+ 0 : "Monday" ,
53+ 1 : "Tuesday" ,
54+ 2 : "Wednesday" ,
55+ 3 : "Thursday" ,
56+ 4 : "Friday" ,
57+ 5 : "Saturday" ,
58+ 6 : "Sunday" ,}
6359 return switch .get (tm_wday , "Day not found" )
6460
6561# initialize pyportal
@@ -111,18 +107,19 @@ def wday_to_weekday_name(tm_wday):
111107 refresh_time = time .monotonic ()
112108 # set the_time
113109 the_time = time .localtime ()
114- # Convert tm_wday to name of day
115- weekday = wday_to_weekday_name (the_time .tm_wday )
116110 except (ValueError , RuntimeError ) as error :
117111 print ("Failed to get data, retrying\n " , e )
118- wifi .reset ()
112+ esp .reset ()
119113 continue
120114
115+ # Convert tm_wday to name of day
116+ weekday = wday_to_weekday_name (the_time .tm_wday )
117+
121118 # set the day label's text
122119 label_day .text = weekday
123120
124121 # set the time label's text
125- label_time .text = "({})" .format (time_name [the_time .tm_hour ])
122+ label_time .text = "({})" .format (time_names [the_time .tm_hour ])
126123
127- # update every minute.
128- time .sleep (60 )
124+ # update every minute
125+ time .sleep (60 )
0 commit comments