mirror of
https://github.com/infiniteCable2/openpilot.git
synced 2026-10-13 09:53:41 +08:00
dark mode and inactivity onroad
This commit is contained in:
@@ -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,
|
||||
),
|
||||
}
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user