Skip to content

Commit 5e26102

Browse files
RickDnampsclaude
andcommitted
Fix: RP2040 draw_ok() incremental — supprime le flicker toutes les 10s
tft.fill(BLACK) uniquement sur changement d'etat (full=True). Mise à jour BUS health = redraw incrémental : barre + % seulement, sans effacer l'écran. Anneau et label couleur mis à jour si seuil 80% franchi. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 88e5320 commit 5e26102

2 files changed

Lines changed: 38 additions & 19 deletions

File tree

rp2040/firmware/display.py

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,17 @@
9393
))
9494

9595
# 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
9899

99100

100101
def reset_animations():
101102
"""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
105107

106108

107109
# ------------------------------------------------------------------
@@ -216,23 +218,40 @@ def draw_locked(tft, full=False):
216218
_draw_ring(tft, CENTER_X, CENTER_Y, 115, 8, ring_color)
217219

218220

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
230247
_progress_bar(tft, 34, 118, 172, 10, bus_pct / 100.0, bus_color)
248+
tft.fill_rect(CENTER_X - 24, 133, 48, 9, BLACK)
231249
_text_center(tft, '{:.0f}%'.format(bus_pct), 133, bus_color)
232250
if bus_pct < 80.0:
233251
_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+
236255
reset_animations()
237256

238257

rp2040/firmware/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def apply_state():
8686
if state == STATE_BOOTING:
8787
disp.draw_booting(tft, full=full)
8888
elif state == STATE_OK:
89-
disp.draw_ok(tft, version, bus_health_pct)
89+
disp.draw_ok(tft, version, bus_health_pct, full=full)
9090
elif state == STATE_NET:
9191
disp.draw_net(tft, net_sub_state)
9292
elif state == STATE_LOCKED:

0 commit comments

Comments
 (0)