diff --git a/selfdrive/ui/mici/onroad/confidence_ball.py b/selfdrive/ui/mici/onroad/confidence_ball.py index 4a081159c6..7f7db2cf9f 100644 --- a/selfdrive/ui/mici/onroad/confidence_ball.py +++ b/selfdrive/ui/mici/onroad/confidence_ball.py @@ -83,9 +83,7 @@ class ConfidenceBall(Widget, ConfidenceBallSP): top_dot_color = rl.Color(50, 50, 50, 255) bottom_dot_color = rl.Color(13, 13, 13, 255) - if self._visual == 0: + if not self.update_confidence_visual(content_rect, status_dot_radius, dot_height, top_dot_color, bottom_dot_color): draw_circle_gradient(content_rect.x + content_rect.width - status_dot_radius, dot_height, status_dot_radius, top_dot_color, bottom_dot_color) - else: - self.update_confidence_visual(content_rect, status_dot_radius, dot_height, top_dot_color, bottom_dot_color) diff --git a/selfdrive/ui/sunnypilot/mici/onroad/confidence_ball.py b/selfdrive/ui/sunnypilot/mici/onroad/confidence_ball.py index 159f3dc11b..2d5007fd23 100644 --- a/selfdrive/ui/sunnypilot/mici/onroad/confidence_ball.py +++ b/selfdrive/ui/sunnypilot/mici/onroad/confidence_ball.py @@ -27,7 +27,7 @@ class ConfidenceBallSP: # UIStatus.LONG_ONLY return BORDER_COLORS[UIStatus.LONG_ONLY] - def update_confidence_visual(self, content_rect, status_dot_radius, dot_height, top_dot_color, bottom_dot_color): + def update_confidence_visual(self, content_rect, status_dot_radius, dot_height, top_dot_color, bottom_dot_color) -> bool: if self._visual == 2: bar_width = int(20 * self._scale) bar_x = content_rect.x + content_rect.width - bar_width @@ -35,7 +35,10 @@ class ConfidenceBallSP: 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) + return True elif self._visual == 1: rl.draw_circle_gradient(int(content_rect.x + content_rect.width - status_dot_radius), int(dot_height), status_dot_radius, top_dot_color, bottom_dot_color) + return True + return False diff --git a/selfdrive/ui/sunnypilot/onroad/augmented_road_view.py b/selfdrive/ui/sunnypilot/onroad/augmented_road_view.py index c3ef86dcbd..b0ddc1cd82 100644 --- a/selfdrive/ui/sunnypilot/onroad/augmented_road_view.py +++ b/selfdrive/ui/sunnypilot/onroad/augmented_road_view.py @@ -20,7 +20,7 @@ class AugmentedRoadViewSP: def __init__(self): self._fade_texture = gui_app.texture("icons_mici/onroad/onroad_fade.png") self._fade_alpha_filter = FirstOrderFilter(0, 0.1, 1 / gui_app.target_fps) - self._confidence_visual = ConfidenceBall(scale=1.5, visual=False) + self._confidence_visual = ConfidenceBall(scale=1.5) def update_fade_out_bottom_overlay(self, _content_rect): # Fade out bottom of overlays for looks (only when engaged) @@ -34,9 +34,6 @@ class AugmentedRoadViewSP: def update_confidence_visual(self, _content_rect): mode = ui_state.confidence_visual - if mode == 1: - self._confidence_visual._visual = 1 - self._confidence_visual.render(_content_rect) - elif mode == 2: - self._confidence_visual._visual = 2 - self._confidence_visual.render(_content_rect) + if mode in (1, 2): + self._confidence_visual._visual = mode + self._confidence_visual.render(_content_rect)