@@ -88,15 +88,22 @@ def reset_on_error(delay, error):
8888 # print(now)
8989 # print(event_time)
9090 remaining = time .mktime (event_time ) - time .mktime (now )
91+ # if it's the day of the event...
9192 if remaining < 0 :
93+ # scroll the event message on a loop
9294 display .marquee (EVENT_MSG , scroll_speed , loop = True )
95+ # calculate the seconds remaining
9396 secs_remaining = remaining % 60
9497 remaining //= 60
98+ # calculate the minutes remaining
9599 mins_remaining = remaining % 60
96100 remaining //= 60
101+ # calculate the hours remaining
97102 hours_remaining = remaining % 24
98103 remaining //= 24
104+ # calculate the days remaining
99105 days_remaining = remaining
106+ # pack the calculated times into a string to scroll
100107 countdown_string = (
101108 "* %d Days, %d Hours, %d Minutes & %s Seconds until %s *"
102109 % (
@@ -107,11 +114,15 @@ def reset_on_error(delay, error):
107114 EVENT_NAME ,
108115 )
109116 )
117+ # get the length of the packed string
110118 display_length = len (countdown_string )
111119 # print(display_length)
120+ # calculate the amount of time needed to scroll the string
112121 scroll_time = display_length * scroll_speed
113122 # print(scroll_time)
123+ # reset the clock
114124 clock = time .monotonic ()
125+ # scroll the string once
115126 display .marquee (countdown_string , scroll_speed , loop = False )
116127
117128 # any errors, reset MCU
0 commit comments