1
1
import time
2
- import gc
3
2
import board
4
- import displayio
5
3
import busio
4
+ import digitalio
6
5
from 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
8
7
import adafruit_requests as requests
9
- import digitalio
10
- from analogio import AnalogIn
11
8
from adafruit_pyportal import PyPortal
12
9
from adafruit_bitmap_font import bitmap_font
13
10
from adafruit_display_text import label
14
- import adafruit_touchscreen
15
11
16
12
try :
17
13
from secrets import secrets
20
16
the secrets dictionary must contain 'ssid' and 'password' at a minimum""" )
21
17
raise
22
18
23
- # Colors for each label
19
+ # Label colors
24
20
LABEL_DAY_COLOR = 0xFFFFFF
25
- LABEL_TIME_COLOR = 0x8f42f4
21
+ LABEL_TIME_COLOR = 0x2a8eba
26
22
27
23
# the current working directory (where this file is)
28
24
cwd = ("/" + __file__ ).rsplit ('/' , 1 )[0 ]
32
28
33
29
# Descriptions of each hour
34
30
# 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" ]
41
37
42
38
esp32_cs = digitalio .DigitalInOut (board .ESP_CS )
43
39
esp32_ready = digitalio .DigitalInOut (board .ESP_BUSY )
@@ -53,13 +49,13 @@ def wday_to_weekday_name(tm_wday):
53
49
54
50
"""
55
51
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" ,}
63
59
return switch .get (tm_wday , "Day not found" )
64
60
65
61
# initialize pyportal
@@ -111,18 +107,19 @@ def wday_to_weekday_name(tm_wday):
111
107
refresh_time = time .monotonic ()
112
108
# set the_time
113
109
the_time = time .localtime ()
114
- # Convert tm_wday to name of day
115
- weekday = wday_to_weekday_name (the_time .tm_wday )
116
110
except (ValueError , RuntimeError ) as error :
117
111
print ("Failed to get data, retrying\n " , e )
118
- wifi .reset ()
112
+ esp .reset ()
119
113
continue
120
114
115
+ # Convert tm_wday to name of day
116
+ weekday = wday_to_weekday_name (the_time .tm_wday )
117
+
121
118
# set the day label's text
122
119
label_day .text = weekday
123
120
124
121
# 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 ])
126
123
127
- # update every minute.
128
- time .sleep (60 )
124
+ # update every minute
125
+ time .sleep (60 )
0 commit comments