@@ -88,15 +88,22 @@ def reset_on_error(delay, error):
88
88
# print(now)
89
89
# print(event_time)
90
90
remaining = time .mktime (event_time ) - time .mktime (now )
91
+ # if it's the day of the event...
91
92
if remaining < 0 :
93
+ # scroll the event message on a loop
92
94
display .marquee (EVENT_MSG , scroll_speed , loop = True )
95
+ # calculate the seconds remaining
93
96
secs_remaining = remaining % 60
94
97
remaining //= 60
98
+ # calculate the minutes remaining
95
99
mins_remaining = remaining % 60
96
100
remaining //= 60
101
+ # calculate the hours remaining
97
102
hours_remaining = remaining % 24
98
103
remaining //= 24
104
+ # calculate the days remaining
99
105
days_remaining = remaining
106
+ # pack the calculated times into a string to scroll
100
107
countdown_string = (
101
108
"* %d Days, %d Hours, %d Minutes & %s Seconds until %s *"
102
109
% (
@@ -107,11 +114,15 @@ def reset_on_error(delay, error):
107
114
EVENT_NAME ,
108
115
)
109
116
)
117
+ # get the length of the packed string
110
118
display_length = len (countdown_string )
111
119
# print(display_length)
120
+ # calculate the amount of time needed to scroll the string
112
121
scroll_time = display_length * scroll_speed
113
122
# print(scroll_time)
123
+ # reset the clock
114
124
clock = time .monotonic ()
125
+ # scroll the string once
115
126
display .marquee (countdown_string , scroll_speed , loop = False )
116
127
117
128
# any errors, reset MCU
0 commit comments