This commit is contained in:
royjr
2025-11-28 00:56:47 -05:00
parent 67345f59b7
commit 2067dbd823
2 changed files with 27 additions and 5 deletions
+26 -4
View File
@@ -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)
+1 -1
View File
@@ -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'])