From 187aa04ca9fd71f5bba0c3033701867c3ef56a1b Mon Sep 17 00:00:00 2001 From: infiniteCable2 Date: Sun, 16 Nov 2025 17:15:55 +0100 Subject: [PATCH] dark mode and inactivity onroad --- selfdrive/ui/layouts/settings/ictoggles.py | 20 ++++++++++++++++---- selfdrive/ui/ui_state.py | 11 ++++++++++- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/selfdrive/ui/layouts/settings/ictoggles.py b/selfdrive/ui/layouts/settings/ictoggles.py index d50d818c1..72a469dd5 100644 --- a/selfdrive/ui/layouts/settings/ictoggles.py +++ b/selfdrive/ui/layouts/settings/ictoggles.py @@ -36,6 +36,12 @@ DESCRIPTIONS = { "EnableSmoothSteer": tr_noop( "Enables S-curving on lateral control for smoother steering" ), + "DarkMode": tr_noop( + "Force brightness to a minimal value" + ), + "DisableScreenTimer": tr_noop( + "The onroad screen is turned of after 10 seconds. It will be temporarily enabled on alerts" + ), } @@ -94,10 +100,16 @@ class ICTogglesLayout(Widget): "chffr_wheel.png", False, ), - "EnableSmoothSteer": ( - lambda: tr("Steer Smoothing"), - DESCRIPTIONS["EnableSmoothSteer"], - "chffr_wheel.png", + "DarkMode": ( + lambda: tr("Dark Mode"), + DESCRIPTIONS["DarkMode"], + "eye_closed.png", + False, + ), + "DisableScreenTimer": ( + lambda: tr("Onroad Screen Timeout"), + DESCRIPTIONS["DisableScreenTimer"], + "eye_closed.png", False, ), } diff --git a/selfdrive/ui/ui_state.py b/selfdrive/ui/ui_state.py index b08b8ef28..3647643c0 100644 --- a/selfdrive/ui/ui_state.py +++ b/selfdrive/ui/ui_state.py @@ -73,6 +73,9 @@ class UIState: self.CP: car.CarParams | None = None self.light_sensor: float = -1.0 self._param_update_time: float = 0.0 + + self.dark_mode: bool = False + self.onroad_screen_timeout = False # Callbacks self._offroad_transition_callbacks: list[Callable[[], None]] = [] @@ -173,6 +176,8 @@ class UIState: else: self.has_longitudinal_control = self.CP.openpilotLongitudinalControl self._param_update_time = time.monotonic() + self.dark_mode = self.params.get_bool("DarkMode") + self.onroad_screen_timeout = self.params.get_bool("DisableScreenTimer") class Device: @@ -222,7 +227,11 @@ class Device: clipped_brightness = float(np.clip(100 * clipped_brightness, 10, 100)) + if ui_state.started and ui_state.dark_mode: + clipped_brightness = 1.0 + brightness = round(self._brightness_filter.update(clipped_brightness)) + if not self._awake: brightness = 0 @@ -246,7 +255,7 @@ class Device: callback() self._prev_timed_out = interaction_timeout - self._set_awake(ui_state.ignition or not interaction_timeout) + self._set_awake((ui_state.ignition and not ui_state.onroad_screen_timeout) or not interaction_timeout) def _set_awake(self, on: bool): if on != self._awake: