From 96e847e0518aa8375adfc3a1fd4e687949522dbe Mon Sep 17 00:00:00 2001 From: FrogAi <91348155+FrogAi@users.noreply.github.com> Date: Sat, 11 May 2024 15:58:46 -0700 Subject: [PATCH] Visuals - Screen Management - Standby Mode Turn the screen off after your screen times out when onroad, but wake it back up when engagement state changes or important alerts are triggered. --- selfdrive/ui/ui.cc | 18 +++++++++++++++++- selfdrive/ui/ui.h | 2 ++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index 7d29dfa0..ab275bc8 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -438,6 +438,7 @@ void ui_update_frogpilot_params(UIState *s, Params ¶ms) { scene.screen_recorder = screen_management && params.getBool("ScreenRecorder"); scene.screen_timeout = screen_management ? params.getInt("ScreenTimeout") : 30; scene.screen_timeout_onroad = screen_management ? params.getInt("ScreenTimeoutOnroad") : 10; + scene.standby_mode = screen_management && params.getBool("StandbyMode"); scene.speed_limit_controller = scene.longitudinal_control && params.getBool("SpeedLimitController"); scene.show_slc_offset = scene.speed_limit_controller && params.getBool("ShowSLCOffset"); @@ -454,6 +455,7 @@ void UIState::updateStatus() { if (scene.started && sm->updated("controlsState")) { auto controls_state = (*sm)["controlsState"].getControlsState(); auto state = controls_state.getState(); + auto previous_status = status; if (state == cereal::ControlsState::OpenpilotState::PRE_ENABLED || state == cereal::ControlsState::OpenpilotState::OVERRIDING) { status = STATUS_OVERRIDE; } else if (scene.always_on_lateral_active) { @@ -463,6 +465,8 @@ void UIState::updateStatus() { } else { status = scene.enabled ? STATUS_ENGAGED : STATUS_DISENGAGED; } + + scene.wake_up_screen = controls_state.getAlertStatus() != cereal::ControlsState::AlertStatus::NORMAL || status != previous_status; } scene.started |= paramsMemory.getBool("ForceOnroad"); @@ -609,6 +613,8 @@ void Device::updateBrightness(const UIState &s) { int brightness = brightness_filter.update(clipped_brightness); if (!awake) { brightness = 0; + } else if (s.scene.started && s.scene.standby_mode && !s.scene.wake_up_screen && interactive_timeout == 0) { + brightness = 0; } else if (s.scene.started && s.scene.screen_brightness_onroad != 101) { brightness = interactive_timeout > 0 ? fmax(5, s.scene.screen_brightness_onroad) : s.scene.screen_brightness_onroad; } else if (s.scene.screen_brightness != 101) { @@ -627,8 +633,18 @@ void Device::updateWakefulness(const UIState &s) { bool ignition_state_changed = s.scene.ignition != ignition_on; ignition_on = s.scene.ignition; + if (ignition_on && s.scene.standby_mode) { + if (s.scene.wake_up_screen) { + resetInteractiveTimeout(s.scene.screen_timeout, s.scene.screen_timeout_onroad); + } + } + if (ignition_state_changed) { - resetInteractiveTimeout(s.scene.screen_timeout, s.scene.screen_timeout_onroad); + if (ignition_on && s.scene.screen_brightness_onroad == 0 && !s.scene.standby_mode) { + resetInteractiveTimeout(0, 0); + } else { + resetInteractiveTimeout(s.scene.screen_timeout, s.scene.screen_timeout_onroad); + } } else if (interactive_timeout > 0 && --interactive_timeout == 0) { emit interactiveTimeout(); } diff --git a/selfdrive/ui/ui.h b/selfdrive/ui/ui.h index 6a77e617..f22420b9 100644 --- a/selfdrive/ui/ui.h +++ b/selfdrive/ui/ui.h @@ -193,6 +193,7 @@ typedef struct UIScene { bool speed_limit_changed; bool speed_limit_controller; bool speed_limit_overridden; + bool standby_mode; bool standstill; bool static_pedals_on_ui; bool stopped_timer; @@ -206,6 +207,7 @@ typedef struct UIScene { bool use_si; bool use_vienna_slc_sign; bool vtsc_controlling_curve; + bool wake_up_screen; bool wheel_speed; double fps;