@@ -274,12 +274,12 @@ class DownloadView:
274274 }
275275
276276 def __init__ (self ) -> None :
277- board_id = M5 .getBoard ()
278- self .view_info = self .view_info_table .get (board_id , None )
277+ self . board_id = M5 .getBoard ()
278+ self .view_info = self .view_info_table .get (self . board_id , None )
279279
280280 def on_view (self ):
281281 if self .view_info :
282- if M5 . getBoard () == M5 .BOARD .M5Tab5 :
282+ if self . board_id == M5 .BOARD .M5Tab5 :
283283 M5 .Lcd .setRotation (3 )
284284 M5 .Lcd .clear (0xFFFFFF )
285285 self .title_label = Label (
@@ -309,13 +309,16 @@ def on_view(self):
309309 self .progress_label .set_text ("0%" )
310310 else :
311311 self .rgb = RGB ()
312+ if self .board_id == M5 .BOARD .M5Unit_PoEP4 :
313+ self .rgb = None
312314 if self .rgb :
313- if M5 . getBoard () == M5 .BOARD .M5PowerHub :
315+ if self . board_id == M5 .BOARD .M5PowerHub :
314316 _rgb_index = 5
315317 else :
316318 _rgb_index = 0
317319 self .rgb .set_color (_rgb_index , self .COLOR_YELLOW )
318320 else :
321+ self ._unit_poep4_rgb_show ("yellow" )
319322 print ("Sync..." )
320323 print ("0%" )
321324
@@ -339,6 +342,10 @@ def update_progress(self, size):
339342 self .rgb .set_color (_rgb_index , self .COLOR_BLUE )
340343 time .sleep (0.02 )
341344 else :
345+ self ._unit_poep4_rgb_show ("black" )
346+ time .sleep (0.02 )
347+ self ._unit_poep4_rgb_show ("blue" )
348+ time .sleep (0.02 )
342349 print (f"{ percent } %" )
343350
344351 def on_success (self ):
@@ -352,6 +359,7 @@ def on_success(self):
352359 _rgb_index = 0
353360 self .rgb .set_color (_rgb_index , self .COLOR_GREEN )
354361 else :
362+ self ._unit_poep4_rgb_show ("green" )
355363 print ("Success" )
356364 time .sleep (1 )
357365
@@ -366,13 +374,43 @@ def on_failed(self):
366374 _rgb_index = 0
367375 self .rgb .set_color (_rgb_index , self .COLOR_RED )
368376 else :
377+ self ._unit_poep4_rgb_show ("red" )
369378 print ("Failed" )
370379
371380 def on_exit (self ):
372381 if self .view_info :
373382 M5 .Lcd .clear (0x000000 )
374383 M5 .Lcd .setTextColor (0xFFFFFF , 0 )
375384
385+ def _unit_poep4_rgb_show (self , color : str ):
386+ if self .board_id != M5 .BOARD .M5Unit_PoEP4 :
387+ return
388+ from machine import Pin
389+
390+ if not hasattr (self , "_poep4_led" ):
391+ self ._poep4_led = {
392+ "r" : Pin (17 , Pin .OUT , value = 1 ),
393+ "g" : Pin (15 , Pin .OUT , value = 1 ),
394+ "b" : Pin (16 , Pin .OUT , value = 1 ),
395+ }
396+
397+ _color_table = {
398+ "black" : (1 , 1 , 1 ),
399+ "red" : (0 , 1 , 1 ),
400+ "green" : (1 , 0 , 1 ),
401+ "blue" : (1 , 1 , 0 ),
402+ "yellow" : (0 , 0 , 1 ),
403+ }
404+
405+ color = color .lower ()
406+ if color not in _color_table :
407+ raise ValueError ("Unsupported color: " + color )
408+
409+ r , g , b = _color_table [color ]
410+ self ._poep4_led ["r" ].value (r )
411+ self ._poep4_led ["g" ].value (g )
412+ self ._poep4_led ["b" ].value (b )
413+
376414
377415class M5Sync :
378416 RECORD_JSON_PATH = "/flash/res/record.json"
0 commit comments