From 2067dbd8232dd21962cba133e53b73ee47baaa35 Mon Sep 17 00:00:00 2001 From: royjr Date: Fri, 28 Nov 2025 00:56:47 -0500 Subject: [PATCH] bar --- selfdrive/ui/mici/onroad/confidence_ball.py | 30 ++++++++++++++++++--- selfdrive/ui/onroad/augmented_road_view.py | 2 +- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/selfdrive/ui/mici/onroad/confidence_ball.py b/selfdrive/ui/mici/onroad/confidence_ball.py index ade468dad8..91129e3128 100644 --- a/selfdrive/ui/mici/onroad/confidence_ball.py +++ b/selfdrive/ui/mici/onroad/confidence_ball.py @@ -22,10 +22,11 @@ def draw_circle_gradient(center_x: float, center_y: float, radius: int, class ConfidenceBall(Widget): - def __init__(self, demo: bool = True, scale: float = 1.0): + def __init__(self, demo: bool = False, scale: float = 1.0, bar: bool = False): super().__init__() self._demo = demo self._scale = scale + self._bar = bar self._confidence_filter = FirstOrderFilter(-0.5, 0.5, 1 / gui_app.target_fps) def update_filter(self, value: float): @@ -74,6 +75,27 @@ class ConfidenceBall(Widget): top_dot_color = rl.Color(50, 50, 50, 255) bottom_dot_color = rl.Color(13, 13, 13, 255) - draw_circle_gradient(content_rect.x + content_rect.width - status_dot_radius, - dot_height, status_dot_radius, - top_dot_color, bottom_dot_color) + if (self._bar): + bar_width = int(20 * self._scale) + bar_x = content_rect.x + content_rect.width - bar_width + fill_h = int(content_rect.height * self._confidence_filter.x) + fill_y = int(content_rect.y + (content_rect.height - fill_h)) + rl.draw_rectangle( + int(bar_x), + int(content_rect.y), + bar_width, + int(content_rect.height), + rl.Color(20, 20, 20, 180), + ) + rl.draw_rectangle_gradient_v( + int(bar_x), + fill_y, + bar_width, + fill_h, + top_dot_color, + bottom_dot_color, + ) + else: + draw_circle_gradient(content_rect.x + content_rect.width - status_dot_radius, + dot_height, status_dot_radius, + top_dot_color, bottom_dot_color) diff --git a/selfdrive/ui/onroad/augmented_road_view.py b/selfdrive/ui/onroad/augmented_road_view.py index e877f906e9..0cba9f4d2d 100644 --- a/selfdrive/ui/onroad/augmented_road_view.py +++ b/selfdrive/ui/onroad/augmented_road_view.py @@ -49,7 +49,7 @@ class AugmentedRoadView(CameraView): self._hud_renderer = HudRenderer() self.alert_renderer = AlertRenderer() self.driver_state_renderer = DriverStateRenderer() - self._confidence_ball = ConfidenceBall(scale = 2.0) + self._confidence_ball = ConfidenceBall(scale = 1.0, bar = True) # debug self._pm = messaging.PubMaster(['uiDebug'])