|
93 | 93 | )) |
94 | 94 |
|
95 | 95 | # Flags pour eviter le full-redraw a chaque frame d'animation |
96 | | -_booting_bg_drawn = False |
97 | | -_locked_bg_drawn = False |
| 96 | +_booting_bg_drawn = False |
| 97 | +_locked_bg_drawn = False |
| 98 | +_ok_prev_bus_color = None # suivi couleur pour draw_ok() incremental |
98 | 99 |
|
99 | 100 |
|
100 | 101 | def reset_animations(): |
101 | 102 | """Appeler quand on quitte un etat anime pour forcer un full redraw au retour.""" |
102 | | - global _booting_bg_drawn, _locked_bg_drawn |
103 | | - _booting_bg_drawn = False |
104 | | - _locked_bg_drawn = False |
| 103 | + global _booting_bg_drawn, _locked_bg_drawn, _ok_prev_bus_color |
| 104 | + _booting_bg_drawn = False |
| 105 | + _locked_bg_drawn = False |
| 106 | + _ok_prev_bus_color = None |
105 | 107 |
|
106 | 108 |
|
107 | 109 | # ------------------------------------------------------------------ |
@@ -216,23 +218,40 @@ def draw_locked(tft, full=False): |
216 | 218 | _draw_ring(tft, CENTER_X, CENTER_Y, 115, 8, ring_color) |
217 | 219 |
|
218 | 220 |
|
219 | | -def draw_ok(tft, version, bus_pct=100.0): |
220 | | - tft.fill(BLACK) |
221 | | - bus_color = GREEN if bus_pct >= 80.0 else ORANGE |
222 | | - ring_color = GREEN if bus_pct >= 80.0 else ORANGE |
223 | | - _draw_ring(tft, CENTER_X, CENTER_Y, 115, 4, ring_color) |
224 | | - _text_center(tft, 'SYSTEM STATUS:', 50, GREEN) |
225 | | - _text_center(tft, 'OPERATIONAL', 64, GREEN) |
226 | | - tft.fill_rect(CENTER_X - 50, 78, 100, 1, DK_GRAY) |
227 | | - if version: |
228 | | - _text_center(tft, 'v' + version[:11], 88, GREEN) |
229 | | - _text_center(tft, 'UART BUS HEALTH', 106, bus_color) |
| 221 | +def draw_ok(tft, version, bus_pct=100.0, full=False): |
| 222 | + """Redraw complet si full=True (changement d'etat), sinon incremental (bus update).""" |
| 223 | + global _ok_prev_bus_color |
| 224 | + bus_color = GREEN if bus_pct >= 80.0 else ORANGE |
| 225 | + color_changed = (bus_color != _ok_prev_bus_color) |
| 226 | + _ok_prev_bus_color = bus_color |
| 227 | + |
| 228 | + if full: |
| 229 | + # Redraw complet — changement d'etat (pas de flicker, appel rare) |
| 230 | + tft.fill(BLACK) |
| 231 | + _draw_ring(tft, CENTER_X, CENTER_Y, 115, 4, bus_color) |
| 232 | + _text_center(tft, 'SYSTEM STATUS:', 50, GREEN) |
| 233 | + _text_center(tft, 'OPERATIONAL', 64, GREEN) |
| 234 | + tft.fill_rect(CENTER_X - 50, 78, 100, 1, DK_GRAY) |
| 235 | + if version: |
| 236 | + _text_center(tft, 'v' + version[:11], 88, GREEN) |
| 237 | + _text_center(tft, 'UART BUS HEALTH', 106, bus_color) |
| 238 | + tft.fill_rect(CENTER_X - 50, 156, 100, 1, DK_GRAY) |
| 239 | + _text_center(tft, '< swipe > TELEM', 164, GRAY) |
| 240 | + elif color_changed: |
| 241 | + # Couleur franchit le seuil 80% : redessiner anneau + label uniquement |
| 242 | + _draw_ring(tft, CENTER_X, CENTER_Y, 115, 4, bus_color) |
| 243 | + tft.fill_rect(0, 106, 240, 9, BLACK) |
| 244 | + _text_center(tft, 'UART BUS HEALTH', 106, bus_color) |
| 245 | + |
| 246 | + # Parties dynamiques : toujours mises a jour sans effacer tout l'ecran |
230 | 247 | _progress_bar(tft, 34, 118, 172, 10, bus_pct / 100.0, bus_color) |
| 248 | + tft.fill_rect(CENTER_X - 24, 133, 48, 9, BLACK) |
231 | 249 | _text_center(tft, '{:.0f}%'.format(bus_pct), 133, bus_color) |
232 | 250 | if bus_pct < 80.0: |
233 | 251 | _text_center(tft, 'PARASITES DETECTES', 147, ORANGE) |
234 | | - tft.fill_rect(CENTER_X - 50, 156, 100, 1, DK_GRAY) |
235 | | - _text_center(tft, '< swipe > TELEM', 164, GRAY) |
| 252 | + elif not full: |
| 253 | + tft.fill_rect(0, 147, 240, 9, BLACK) # efface avertissement si recupere |
| 254 | + |
236 | 255 | reset_animations() |
237 | 256 |
|
238 | 257 |
|
|
0 commit comments