60
60
except :
61
61
TIME_ZONE = None # Use IP geolocation
62
62
63
- # Battery level to indicate near-empty, time to recharge.
64
- LOW_BATT_VOLTAGE = 2.45
65
-
66
63
67
64
# SOME UTILITY FUNCTIONS ---------------------------------------------------
68
65
@@ -150,12 +147,11 @@ def hh_mm(time_struct, twelve_hour=True):
150
147
GRAPHICS = Graphics (auto_refresh = False )
151
148
DISPLAY = GRAPHICS .display
152
149
153
- FONT_SMALL = bitmap_font .load_font ('/fonts/Impact-16.bdf ' )
154
- FONT_MEDIUM = bitmap_font .load_font ('/fonts/Impact-24.bdf ' )
155
- FONT_LARGE = bitmap_font .load_font ('/fonts/Impact-30.bdf ' )
150
+ FONT_SMALL = bitmap_font .load_font ('/fonts/Impact-16.pcf ' )
151
+ FONT_MEDIUM = bitmap_font .load_font ('/fonts/Impact-24.pcf ' )
152
+ FONT_LARGE = bitmap_font .load_font ('/fonts/Impact-30.pcf ' )
156
153
157
- # Two displayio groups are created. First is the "main" group which holds
158
- # all the labels for the stops and predictions...
154
+ # displayio group holds all the labels for the stops and predictions...
159
155
GROUP = displayio .Group (max_size = 14 )
160
156
GROUP .append (fillrect (0 , 0 , DISPLAY .width , DISPLAY .height , 0xFFFFFF ))
161
157
# Clear the screen ASAP before populating rest of group (erase any old
@@ -164,32 +160,6 @@ def hh_mm(time_struct, twelve_hour=True):
164
160
DISPLAY .refresh ()
165
161
time .sleep (5 ) # Don't allow another refresh() too soon
166
162
167
- # Second group is the low battery display. Populate this one now,
168
- # then we'll get back to the main group with the stop data in a moment...
169
- BATT_GROUP = displayio .Group (max_size = 3 )
170
- BATT_GROUP .append (fillrect (0 , 0 , DISPLAY .width , DISPLAY .height , 0xFFFFFF ))
171
- try :
172
- # Attempt loading low-battery icon, centered on screen
173
- # pylint: disable=no-member
174
- FILE = open ('bitmaps/lowbatt.bmp' , 'rb' )
175
- BATT_BITMAP = displayio .OnDiskBitmap (FILE )
176
- BATT_ICON_TILEGRID = displayio .TileGrid (
177
- BATT_BITMAP , pixel_shader = displayio .ColorConverter ())
178
- BATT_ICON_TILEGRID .x = (DISPLAY .width - BATT_BITMAP .width + 1 ) // 2
179
- BATT_ICON_TILEGRID .y = (DISPLAY .height - BATT_BITMAP .height + 1 ) // 2
180
- # onDiskBitmap seems to treat black as transparent...image won't
181
- # show correctly on white background, so make an in-between rect
182
- # to fill the area behind the battery icon with black.
183
- BATT_GROUP .append (fillrect (BATT_ICON_TILEGRID .x , BATT_ICON_TILEGRID .y ,
184
- BATT_BITMAP .width , BATT_BITMAP .height , 0 ))
185
- BATT_GROUP .append (BATT_ICON_TILEGRID )
186
- except :
187
- # If load fails, fall back on text low-batt message
188
- TEXT = Label (FONT_MEDIUM , text = 'LOW BATTERY' , color = 0 )
189
- TEXT .anchor_point = (0.5 , 0.5 )
190
- TEXT .anchored_position = (DISPLAY .width // 2 , DISPLAY .height // 2 )
191
- BATT_GROUP .append (TEXT )
192
-
193
163
# Populate list of NextBus objects from STOPS[] and generate initial text
194
164
# labels (these get positioned in a second pass later)...
195
165
STOP_LIST = []
@@ -247,17 +217,6 @@ def hh_mm(time_struct, twelve_hour=True):
247
217
248
218
while True :
249
219
250
- # If battery is low, DO NOT SHOW PREDICTIONS. Because the display
251
- # persists without power, information shown could "look right" but
252
- # actually be WAY out of date. Instead, display low-battery indicator
253
- # once and then wait for battery recharge or USB power.
254
- if PERIPHERALS .battery < LOW_BATT_VOLTAGE :
255
- DISPLAY .show (BATT_GROUP )
256
- DISPLAY .refresh ()
257
- while PERIPHERALS .battery < LOW_BATT_VOLTAGE :
258
- time .sleep (60 )
259
- DISPLAY .show (GROUP )
260
-
261
220
# Periodically sync clock with time server
262
221
if time .monotonic () - LAST_SYNC_TIME >= CLOCK_SYNC_INTERVAL :
263
222
try :
0 commit comments