Skip to content

Commit 4cae13f

Browse files
author
brentru
committed
remove day of the week function in favor of a list
1 parent 79a0122 commit 4cae13f

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

PyPortal_Quarantine_Clock/code.py

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535
"late afternoon","early evening","early evening","dusk-ish",
3636
"evening","evening","late evening","late evening"]
3737

38+
# Days of the week
39+
week_days = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"]
40+
3841
esp32_cs = digitalio.DigitalInOut(board.ESP_CS)
3942
esp32_ready = digitalio.DigitalInOut(board.ESP_BUSY)
4043
esp32_reset = digitalio.DigitalInOut(board.ESP_RESET)
@@ -43,21 +46,6 @@
4346
esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset, debug=False)
4447
requests.set_socket(socket, esp)
4548

46-
def wday_to_weekday_name(tm_wday):
47-
"""Returns the name of the weekday based on tm_wday value.
48-
:param int tm_wday: Days since Sunday.
49-
50-
"""
51-
switch = {
52-
0: "Monday",
53-
1: "Tuesday",
54-
2: "Wednesday",
55-
3: "Thursday",
56-
4: "Friday",
57-
5: "Saturday",
58-
6: "Sunday",}
59-
return switch.get(tm_wday, "Day not found")
60-
6149
# initialize pyportal
6250
pyportal = PyPortal(esp=esp,
6351
external_spi=spi,
@@ -113,7 +101,7 @@ def wday_to_weekday_name(tm_wday):
113101
continue
114102

115103
# Convert tm_wday to name of day
116-
weekday = wday_to_weekday_name(the_time.tm_wday)
104+
weekday = week_days[the_time.tm_wday]
117105

118106
# set the day label's text
119107
label_day.text = weekday

0 commit comments

Comments
 (0)