@@ -30,7 +30,7 @@ class Pyloton:
30
30
PURPLE = 0x64337E
31
31
WHITE = 0xFFFFFF
32
32
33
- splash_group = displayio .Group ()
33
+ loading_group = displayio .Group ()
34
34
35
35
cyc_connections = []
36
36
cyc_services = []
@@ -66,21 +66,24 @@ def show_splash(self):
66
66
if self .debug :
67
67
return
68
68
with open ('biketrace.bmp' , 'rb' ) as bitmap_file :
69
- bitmap = displayio .OnDiskBitmap (bitmap_file )
69
+ bitmap1 = displayio .OnDiskBitmap (bitmap_file )
70
70
71
- tile_grid = displayio .TileGrid (bitmap , pixel_shader = displayio .ColorConverter ())
71
+ tile_grid = displayio .TileGrid (bitmap1 , pixel_shader = displayio .ColorConverter ())
72
72
73
73
74
- self .splash_group .append (tile_grid )
74
+ self .loading_group .append (tile_grid )
75
+
76
+ self .display .show (self .loading_group )
75
77
76
78
status_heading = label .Label (font = self .arial16 , x = 80 , y = 175 ,
77
79
text = "Status" , color = self .YELLOW )
80
+
78
81
rect = Rect (0 , 165 , 240 , 75 , fill = self .PURPLE )
79
82
80
- self .splash_group .append (rect )
81
- self .splash_group .append (status_heading )
83
+ self .loading_group .append (rect )
84
+ self .loading_group .append (status_heading )
82
85
83
- self .display .show (self .splash_group )
86
+ self .display .show (self .loading_group )
84
87
time .sleep (.01 )
85
88
86
89
@@ -115,12 +118,12 @@ def _status_update(self, message):
115
118
text_group .append (status )
116
119
117
120
118
- if len (self .splash_group ) == 3 :
119
- self .splash_group .append (text_group )
121
+ if len (self .loading_group ) < 4 :
122
+ self .loading_group .append (text_group )
120
123
else :
121
- self .splash_group [3 ] = text_group
124
+ self .loading_group [3 ] = text_group
122
125
123
- self .display .show (self .splash_group )
126
+ self .display .show (self .loading_group )
124
127
time .sleep (0.01 )
125
128
126
129
def timeout (self ):
@@ -147,17 +150,17 @@ def speed_cad_connect(self):
147
150
"""
148
151
Connects to speed and cadence sensor
149
152
"""
150
- print ("Scanning..." )
153
+ self . _status_update ("Scanning..." )
151
154
# Save advertisements, indexed by address
152
155
advs = {}
153
156
for adv in self .ble .start_scan (ProvideServicesAdvertisement , timeout = 5 ):
154
157
if CyclingSpeedAndCadenceService in adv .services :
155
- print ("found a CyclingSpeedAndCadenceService advertisement" )
158
+ self . _status_update ("found a CyclingSpeedAndCadenceService advertisement" )
156
159
# Save advertisement. Overwrite duplicates from same address (device).
157
160
advs [adv .address ] = adv
158
161
159
162
self .ble .stop_scan ()
160
- print ( " Stopped scanning" )
163
+ self . _status_update ( "Speed and Cadence: Stopped scanning" )
161
164
if not advs :
162
165
# Nothing found. Go back and keep looking.
163
166
return []
@@ -166,14 +169,14 @@ def speed_cad_connect(self):
166
169
self .cyc_connections = []
167
170
for adv in advs .values ():
168
171
self .cyc_connections .append (self .ble .connect (adv ))
169
- print ("Connected" , len (self .cyc_connections ))
172
+ self . _status_update ("Connected {}" . format ( len (self .cyc_connections ) ))
170
173
171
174
172
175
self .cyc_services = []
173
176
for conn in self .cyc_connections :
174
177
175
178
self .cyc_services .append (conn [CyclingSpeedAndCadenceService ])
176
- print ( "Done " )
179
+ self . _status_update ( "Finishing up... " )
177
180
return self .cyc_connections
178
181
179
182
@@ -286,7 +289,7 @@ def update_display(self, hr_service):
286
289
self .splash [3 ] = hr_label
287
290
288
291
if self .speed_enabled :
289
- sp_label = self ._label_maker ('{} rpm ' .format (speed ), 50 , 120 )
292
+ sp_label = self ._label_maker ('{} mph ' .format (speed ), 50 , 120 )
290
293
if not self .setup :
291
294
self .splash .append (sp_label )
292
295
else :
@@ -307,6 +310,6 @@ def update_display(self, hr_service):
307
310
self .splash [6 ] = ams_label
308
311
309
312
self .setup = True
310
- time .sleep (0.2 )
313
+ # time.sleep(0.2)
311
314
312
315
self .display .show (self .splash )
0 commit comments