Big UI : Conditional Drive Update

This commit is contained in:
firestarsdog
2026-07-25 18:18:06 -04:00
parent f0e3414d1f
commit 3932dd9fe2
2 changed files with 33 additions and 23 deletions
@@ -1989,11 +1989,13 @@ def draw_section_header(
title_color: rl.Color | None = None,
trailing_color: rl.Color | None = None,
style: PanelStyle = DEFAULT_PANEL_STYLE,
align_center: bool = False,
):
if title:
trailing_reserved = min(320.0, rect.width * 0.38) if trailing_text else 0.0
title_rect = rl.Rectangle(rect.x, rect.y + (rect.height - title_size) / 2, max(1.0, rect.width - trailing_reserved), title_size + 4)
gui_label(title_rect, title, title_size, title_color or style.subtitle_color, FontWeight.MEDIUM)
alignment = rl.GuiTextAlignment.TEXT_ALIGN_CENTER if align_center else rl.GuiTextAlignment.TEXT_ALIGN_LEFT
gui_label(title_rect, title, title_size, title_color or style.subtitle_color, FontWeight.MEDIUM, alignment=alignment)
if trailing_text:
trailing_rect = rl.Rectangle(rect.x, rect.y + (rect.height - trailing_size) / 2, rect.width, trailing_size + 4)
@@ -2729,7 +2731,7 @@ class AetherAdjustorRow(Widget):
value_fs, 0, self._style.title_color)
if self._subtitle:
sub_fs = 20
sub_fs = 26
sub_y = bar_rect.y - sub_fs - 4
gui_label(rl.Rectangle(content_left, sub_y, bar_width, sub_fs),
self._subtitle, sub_fs, self._style.subtitle_color, FontWeight.NORMAL)
@@ -3753,13 +3755,13 @@ class AetherTile(Widget):
rx, ry, rw, rh = face.x, face.y, face.width, face.height
content_pad = max(24, int(rh * 0.15))
title_size = max(20, min(26, int(rh * 0.22)))
status_size = max(16, min(24, int(rh * 0.18)))
title_size = max(26, min(32, int(rh * 0.26)))
status_size = max(20, min(25, int(rh * 0.20)))
title_color = rl.WHITE if (enabled and is_active) else rl.Color(220, 220, 230, 255)
title_y = ry + (rh / 2) - title_size - 2
status_y = ry + (rh / 2) + 12
title_y = ry + (rh / 2) - title_size - 4
status_y = ry + (rh / 2) + 8
max_text_width = rw - (content_pad * 2) - int(rh * 0.40) - 10
font = getattr(self, "_font", gui_app.font(FontWeight.BOLD))
@@ -3968,12 +3970,12 @@ class ToggleTile(AetherTile):
content_pad = SPACING.tile_content
max_w = rw - content_pad * 2
text_scale = max(0.82, min(1.12, rh / 205.0))
title_size = max(32, int(round(41 * text_scale)))
text_scale = max(0.92, min(1.15, rh / 185.0))
title_size = max(36, int(round(44 * text_scale)))
if not enabled:
title_lines = wrap_text(self._font, self.title, max_w, title_size, max_lines=2)
desc_size = max(25, int(round(26 * text_scale)))
desc_size = max(26, int(round(28 * text_scale)))
disabled_text = tr(self._disabled_label) if self._disabled_label else tr("LOCKED")
desc_lines = wrap_text(self._font_desc, disabled_text, max_w, desc_size, max_lines=2)
@@ -3992,11 +3994,11 @@ class ToggleTile(AetherTile):
title_color = rl.WHITE if active else _HUD_TEXT_DIM
if self.desc:
title_lines = wrap_text(self._font, self.title, max_w, title_size, max_lines=2)
desc_size = max(25, int(round(26 * text_scale)))
desc_size = max(26, int(round(28 * text_scale)))
desc_lines = wrap_text(self._font_desc, self.desc, max_w, desc_size, max_lines=2)
if len(title_lines) == 1:
title_y = ry + int(rh * 0.22)
title_y = ry + int(rh * 0.20)
else:
title_y = ry + int(rh * 0.16)
@@ -11,12 +11,14 @@ from openpilot.system.ui.lib.multilang import tr, tr_noop
from openpilot.system.ui.widgets import DialogResult
from openpilot.system.ui.widgets.confirm_dialog import ConfirmDialog
from openpilot.system.ui.widgets.keyboard import Keyboard
from openpilot.system.ui.widgets.label import gui_label
from openpilot.system.ui.widgets.option_dialog import MultiOptionDialog
from openpilot.selfdrive.ui.layouts.settings.starpilot.panel import _SettingsPage
from openpilot.selfdrive.ui.layouts.settings.starpilot.aethergrid import (
AETHER_LIST_METRICS,
AetherListColors,
COMPACT_PANEL_METRICS,
AdjustorTogglesPanelView,
AetherAdjustorRow,
@@ -267,13 +269,13 @@ class ConditionalDriveModeView(AdjustorTogglesPanelView):
max_speed = 150.0 if is_metric else 100.0
specs = {
"CESpeed": {"title": tr("Below Speed"), "subtitle": tr("Switch to Experimental Mode below this speed."), "min": 0, "max": max_speed, "step": 1.0, "unit": speed_unit, "presets": [0, 20, 35, 55, 75], "labels": {}, "get": lambda: float(self._controller._params.get_int("CESpeed"))},
"CESpeedLead": {"title": tr("Speed w/ Lead"), "subtitle": tr("Switch below this speed when following a lead."), "min": 0, "max": max_speed, "step": 1.0, "unit": speed_unit, "presets": [0, 20, 35, 55, 75], "labels": {}, "get": lambda: float(self._controller._params.get_int("CESpeedLead"))},
"CESignalSpeed": {"title": tr("Turn Signal Below"), "subtitle": tr("Switch when turn signal is on below this speed."), "min": 0, "max": max_speed, "step": 1.0, "unit": speed_unit, "presets": [0, 20, 35, 55, 75], "labels": {0.0: tr("Off")}, "get": lambda: float(self._controller._params.get_int("CESignalSpeed"))},
"CEModelStopTime": {"title": tr("Predicted Stop In"), "subtitle": tr("Switch when openpilot predicts a stop within time."), "min": 0, "max": 10.0, "step": 1.0, "unit": "s", "presets": [0, 3, 5, 7, 10], "labels": {0.0: tr("Off")}, "get": lambda: float(self._controller._params.get_int("CEModelStopTime"))},
"CCMSpeed": {"title": tr("Above Speed"), "subtitle": tr("Switch to Chill Mode on open roads above this speed."), "min": 0, "max": max_speed, "step": 1.0, "unit": speed_unit, "presets": [0, 35, 55, 65, 80], "labels": {}, "get": lambda: float(self._controller._params.get_int("CCMSpeed"))},
"CCMSpeedLead": {"title": tr("Speed w/ Lead"), "subtitle": tr("Switch when following a stable lead above this speed."), "min": 0, "max": max_speed, "step": 1.0, "unit": speed_unit, "presets": [0, 35, 55, 65, 80], "labels": {}, "get": lambda: float(self._controller._params.get_int("CCMSpeedLead"))},
"CCMSetSpeedMargin": {"title": tr("Set Speed Margin"), "subtitle": tr("How far below set speed before Chill engages."), "min": 0, "max": 30.0 if is_metric else 15.0, "step": 1.0, "unit": speed_unit, "presets": [0, 5, 10, 15], "labels": {}, "get": lambda: float(self._controller._params.get_int("CCMSetSpeedMargin"))},
"CESpeed": {"title": tr("Below Speed"), "subtitle": "", "min": 0, "max": max_speed, "step": 1.0, "unit": speed_unit, "presets": [0, 20, 35, 55, 75], "labels": {}, "get": lambda: float(self._controller._params.get_int("CESpeed"))},
"CESpeedLead": {"title": tr("Speed w/ Lead"), "subtitle": "", "min": 0, "max": max_speed, "step": 1.0, "unit": speed_unit, "presets": [0, 20, 35, 55, 75], "labels": {}, "get": lambda: float(self._controller._params.get_int("CESpeedLead"))},
"CESignalSpeed": {"title": tr("Turn Signal Below"), "subtitle": "", "min": 0, "max": max_speed, "step": 1.0, "unit": speed_unit, "presets": [0, 20, 35, 55, 75], "labels": {0.0: tr("Off")}, "get": lambda: float(self._controller._params.get_int("CESignalSpeed"))},
"CEModelStopTime": {"title": tr("Predicted Stop In"), "subtitle": "", "min": 0, "max": 10.0, "step": 1.0, "unit": "s", "presets": [0, 3, 5, 7, 10], "labels": {0.0: tr("Off")}, "get": lambda: float(self._controller._params.get_int("CEModelStopTime"))},
"CCMSpeed": {"title": tr("Above Speed"), "subtitle": "", "min": 0, "max": max_speed, "step": 1.0, "unit": speed_unit, "presets": [0, 35, 55, 65, 80], "labels": {}, "get": lambda: float(self._controller._params.get_int("CCMSpeed"))},
"CCMSpeedLead": {"title": tr("Speed w/ Lead"), "subtitle": "", "min": 0, "max": max_speed, "step": 1.0, "unit": speed_unit, "presets": [0, 35, 55, 65, 80], "labels": {}, "get": lambda: float(self._controller._params.get_int("CCMSpeedLead"))},
"CCMSetSpeedMargin": {"title": tr("Set Speed Margin"), "subtitle": "", "min": 0, "max": 30.0 if is_metric else 15.0, "step": 1.0, "unit": speed_unit, "presets": [0, 5, 10, 15], "labels": {}, "get": lambda: float(self._controller._params.get_int("CCMSetSpeedMargin"))},
}
self._cem_keys = ["CESpeed", "CESpeedLead", "CESignalSpeed", "CEModelStopTime"]
@@ -357,9 +359,10 @@ class ConditionalDriveModeView(AdjustorTogglesPanelView):
right_h = tiles_h
banner_overhead = 52.0
if self._uses_two_columns(content_width):
max_natural_h = max(left_h, right_h)
section_overhead = SECTION_HEADER_HEIGHT + SECTION_HEADER_GAP
section_overhead = banner_overhead + SECTION_HEADER_HEIGHT + SECTION_HEADER_GAP
if self._scroll_rect:
available_h = self._scroll_rect.height - section_overhead - self.TAB_HEIGHT - self.TAB_BOTTOM_GAP - 6.0
@@ -379,7 +382,7 @@ class ConditionalDriveModeView(AdjustorTogglesPanelView):
else:
self._left_container_h = left_h
self._tiles_container_h = right_h
total = left_h + SECTION_GAP + right_h + SECTION_HEADER_HEIGHT * 2 + SECTION_HEADER_GAP * 2
total = banner_overhead + left_h + SECTION_GAP + right_h + SECTION_HEADER_HEIGHT * 2 + SECTION_HEADER_GAP * 2
return total + self.TAB_HEIGHT + self.TAB_BOTTOM_GAP
def _draw_scroll_content(self, rect: rl.Rectangle, content_width: float):
@@ -395,14 +398,19 @@ class ConditionalDriveModeView(AdjustorTogglesPanelView):
if mode == 0:
return
banner_text = tr("Switch to Experimental Mode") if mode == 1 else tr("Switch to Chill Mode")
banner_rect = rl.Rectangle(rect.x, y, content_width, 40)
gui_label(banner_rect, banner_text, 40, AetherListColors.HEADER, FontWeight.BOLD, alignment=rl.GuiTextAlignment.TEXT_ALIGN_CENTER)
y += 40 + 12
keys = self._cem_keys if mode == 1 else self._ccm_keys
grid = self._toggle_grid
col_width = (content_width - SECTION_GAP) / 2 if self._uses_two_columns(content_width) else content_width
draw_section_header(rl.Rectangle(rect.x, y, col_width, SECTION_HEADER_HEIGHT), tr("Values"), style=PANEL_STYLE)
draw_section_header(rl.Rectangle(rect.x, y, col_width, SECTION_HEADER_HEIGHT), tr("When"), style=PANEL_STYLE, title_size=38, align_center=True)
if self._uses_two_columns(content_width):
draw_section_header(rl.Rectangle(rect.x + col_width + SECTION_GAP, y, col_width, SECTION_HEADER_HEIGHT), tr("Triggers"), style=PANEL_STYLE)
draw_section_header(rl.Rectangle(rect.x + col_width + SECTION_GAP, y, col_width, SECTION_HEADER_HEIGHT), tr("For"), style=PANEL_STYLE, title_size=38, align_center=True)
y += SECTION_HEADER_HEIGHT + SECTION_HEADER_GAP
@@ -416,7 +424,7 @@ class ConditionalDriveModeView(AdjustorTogglesPanelView):
columns=tg_columns)
else:
y += self._left_container_h + SECTION_GAP
draw_section_header(rl.Rectangle(rect.x, y, col_width, SECTION_HEADER_HEIGHT), tr("Triggers"), style=PANEL_STYLE)
draw_section_header(rl.Rectangle(rect.x, y, col_width, SECTION_HEADER_HEIGHT), tr("For"), style=PANEL_STYLE, title_size=38, align_center=True)
y += SECTION_HEADER_HEIGHT + SECTION_HEADER_GAP
self._draw_two_column_tile_grid(
grid, rect.x, y, col_width,