Skip to content

Commit 79a0122

Browse files
author
brentru
committed
add pylinted code and fonts
1 parent 04e58fd commit 79a0122

File tree

3 files changed

+13206
-27
lines changed

3 files changed

+13206
-27
lines changed

PyPortal_Quarantine_Clock/code.py

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
import time
2-
import gc
32
import board
4-
import displayio
53
import busio
4+
import digitalio
65
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
87
import adafruit_requests as requests
9-
import digitalio
10-
from analogio import AnalogIn
118
from adafruit_pyportal import PyPortal
129
from adafruit_bitmap_font import bitmap_font
1310
from adafruit_display_text import label
14-
import adafruit_touchscreen
1511

1612
try:
1713
from secrets import secrets
@@ -20,9 +16,9 @@
2016
the secrets dictionary must contain 'ssid' and 'password' at a minimum""")
2117
raise
2218

23-
# Colors for each label
19+
# Label colors
2420
LABEL_DAY_COLOR = 0xFFFFFF
25-
LABEL_TIME_COLOR = 0x8f42f4
21+
LABEL_TIME_COLOR = 0x2a8eba
2622

2723
# the current working directory (where this file is)
2824
cwd = ("/"+__file__).rsplit('/', 1)[0]
@@ -32,12 +28,12 @@
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

4238
esp32_cs = digitalio.DigitalInOut(board.ESP_CS)
4339
esp32_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

Comments
 (0)