This commit is contained in:
firestar5683
2026-08-25 10:51:35 -05:00
parent 9eb5768d2a
commit 71f35601d7
3 changed files with 18 additions and 50 deletions
@@ -21,6 +21,7 @@ from openpilot.selfdrive.ui.mici.onroad.starpilot_status import (
)
from openpilot.selfdrive.ui.mici.onroad.cameraview import CameraView
from openpilot.selfdrive.ui.onroad.starpilot.pip_sidecam import PipSideCamera
from openpilot.selfdrive.ui.onroad.starpilot.pulse_glide import get_pulse_glide_border_color
from openpilot.selfdrive.ui.onroad.starpilot.starpilot_border import get_traffic_border_colors
from openpilot.selfdrive.ui.lib.starpilot_visuals import get_border_width
from openpilot.starpilot.common.favorite_slots import (
@@ -842,7 +843,8 @@ class AugmentedRoadView(CameraView):
int(self._content_rect.width),
int(self._content_rect.height),
)
rl.draw_rectangle_rounded_lines_ex(border_rect, 0.12, 16, border_size, get_border_color(ui_state))
border_color = get_pulse_glide_border_color(ui_state.sm, get_border_color(ui_state))
rl.draw_rectangle_rounded_lines_ex(border_rect, 0.12, 16, border_size, border_color)
if (colors := get_traffic_border_colors()) is not None:
for x, w, color in (
+13 -34
View File
@@ -6,7 +6,19 @@ from openpilot.system.ui.lib.text_measure import draw_text_with_shadow, measure_
PULSE_COLOR = rl.Color(52, 190, 112, 255)
GLIDE_COLOR = rl.Color(65, 155, 235, 255)
BANNER_BACKGROUND = rl.Color(0, 0, 0, 210)
DEEP_GLIDE_BORDER_COLOR = rl.Color(24, 72, 150, 255)
def get_pulse_glide_border_color(sm, default_color: rl.Color) -> rl.Color:
"""Use a deep-blue outer border only while developer P&G is gliding."""
if not sm.valid.get("starpilotCarState", False) or not sm.valid.get("starpilotPlan", False):
return default_color
car_state = sm["starpilotCarState"]
plan = sm["starpilotPlan"]
if bool(getattr(car_state, "pulseAndGlide", False)) and bool(getattr(plan, "pulseGlideCoasting", False)):
return DEEP_GLIDE_BORDER_COLOR
return default_color
def render_pulse_glide(rect: rl.Rectangle, coasting: bool) -> None:
@@ -26,36 +38,3 @@ def render_pulse_glide(rect: rl.Rectangle, coasting: bool) -> None:
font_size,
rl.WHITE,
)
def render_pulse_glide_banner(content_rect: rl.Rectangle, coasting: bool) -> None:
"""Render a non-alert on-road status banner while developer P&G is armed."""
border = GLIDE_COLOR if coasting else PULSE_COLOR
state_label = "GLIDING" if coasting else "PULSE"
title_font = gui_app.font(FontWeight.MEDIUM)
state_font = gui_app.font(FontWeight.BOLD)
title_size = measure_text_cached(title_font, "PULSE & GLIDE", 22)
state_size = measure_text_cached(state_font, state_label, 34)
banner_w = max(340.0, title_size.x + 48.0, state_size.x + 96.0)
banner_h = 86.0
banner_rect = rl.Rectangle(
content_rect.x + (content_rect.width - banner_w) / 2.0,
content_rect.y + 28.0,
banner_w,
banner_h,
)
rl.draw_rectangle_rounded(banner_rect, 0.25, 12, BANNER_BACKGROUND)
rl.draw_rectangle_rounded_lines_ex(banner_rect, 0.25, 12, 4, border)
title_pos = rl.Vector2(
banner_rect.x + (banner_rect.width - title_size.x) / 2.0,
banner_rect.y + 10.0,
)
state_pos = rl.Vector2(
banner_rect.x + (banner_rect.width - state_size.x) / 2.0,
banner_rect.y + 38.0,
)
draw_text_with_shadow(title_font, "PULSE & GLIDE", title_pos, 22, rl.WHITE)
draw_text_with_shadow(state_font, state_label, state_pos, 34, rl.WHITE)
@@ -14,7 +14,7 @@ from openpilot.selfdrive.ui.onroad.starpilot.widgets import (
)
from openpilot.selfdrive.ui.onroad.starpilot.stopping_point import render_stopping_point
from openpilot.selfdrive.ui.onroad.starpilot.pause_indicators import render_lateral_paused, render_longitudinal_paused
from openpilot.selfdrive.ui.onroad.starpilot.pulse_glide import render_pulse_glide, render_pulse_glide_banner
from openpilot.selfdrive.ui.onroad.starpilot.pulse_glide import get_pulse_glide_border_color, render_pulse_glide
from openpilot.selfdrive.ui.onroad.starpilot.pip_sidecam import PipSideCamera
from openpilot.selfdrive.ui.onroad.starpilot.favorite_radial_menu import FavoriteRadialMenu
from openpilot.selfdrive.ui.onroad.starpilot.weather_icon import render_weather_icon
@@ -97,7 +97,7 @@ class StarPilotOnroadView(AugmentedRoadView):
def _render(self, rect: rl.Rectangle):
border_width = self._get_border_width()
border_color = get_screen_edge_color(ui_state)
border_color = get_pulse_glide_border_color(ui_state.sm, get_screen_edge_color(ui_state))
rl.draw_rectangle_rounded(rect, 0.12, 10, border_color)
render_background_effects(rect, border_width)
@@ -178,7 +178,6 @@ class StarPilotOnroadView(AugmentedRoadView):
if alert_showing is not None:
return
self._render_pulse_glide_banner()
self._render_developer_metrics()
self.layout_manager.render_widgets(exclude={"speed_limit", "set_speed"})
@@ -186,18 +185,6 @@ class StarPilotOnroadView(AugmentedRoadView):
self._render_torque_bar()
self._render_bottom_row_widgets()
def _render_pulse_glide_banner(self) -> None:
starpilot_car_state = (
ui_state.sm["starpilotCarState"]
if ui_state.sm.valid.get("starpilotCarState", False) else None
)
if not starpilot_car_state or not starpilot_car_state.pulseAndGlide:
return
plan = ui_state.sm["starpilotPlan"] if ui_state.sm.valid.get("starpilotPlan", False) else None
coasting = bool(getattr(plan, "pulseGlideCoasting", False)) if plan else False
render_pulse_glide_banner(self._content_rect, coasting)
def _render_torque_bar(self) -> None:
"""Draw the curved torque-utilization indicator at the bottom of the screen."""
if not self._params.get_bool("EnableTorqueBarWidget", default=True):