mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-10-04 18:43:42 +08:00
bar
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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'])
|
||||
|
||||
Reference in New Issue
Block a user