From ce44830b22af11e9953819763f5d1d2b2ca47fea Mon Sep 17 00:00:00 2001 From: firestarsdog <229254897+firestarsdog@users.noreply.github.com> Date: Sun, 19 Jul 2026 00:49:23 -0400 Subject: [PATCH] Big UI: No flicker --- selfdrive/ui/onroad/starpilot/aethergauge.py | 24 +++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/selfdrive/ui/onroad/starpilot/aethergauge.py b/selfdrive/ui/onroad/starpilot/aethergauge.py index ab0eb70ee..32ff7f0ee 100644 --- a/selfdrive/ui/onroad/starpilot/aethergauge.py +++ b/selfdrive/ui/onroad/starpilot/aethergauge.py @@ -380,12 +380,30 @@ class AetherGauge: self._sources.insert(0, (_cem_demo_active, _cem_demo_data)) self._chevron_accum = 0.0 self._lead_chevron_accum = 0.0 + self._active_priority = 999 + self._cached_data = None + self._last_active_time = 0.0 + self._cooldown = 0.5 def get_active_data(self) -> AetherGaugeData | None: - for is_active, get_data in self._sources: + now = rl.get_time() + best_priority = 999 + new_data = None + + for i, (is_active, get_data) in enumerate(self._sources): if is_active(): - return get_data() - return None + best_priority = i + new_data = get_data() + break + + # Treat None as a priority 999 state: switch immediately if higher/equal priority, + # or wait for cooldown to downgrade/hide. + if best_priority <= self._active_priority or (now - self._last_active_time > self._cooldown): + self._cached_data = new_data + self._active_priority = best_priority + self._last_active_time = now if new_data is not None else 0.0 + + return self._cached_data def render(self, rect: rl.Rectangle, font_bold: rl.Font, font_medium: rl.Font, current_speed: float, cx: float | None = None, bottom: float | None = None): data = self.get_active_data()