From fb11cc7ff4e352e6a5743981a888a944f783e2f8 Mon Sep 17 00:00:00 2001 From: FrogAi <91348155+FrogAi@users.noreply.github.com> Date: Sat, 11 May 2024 15:53:46 -0700 Subject: [PATCH] Visuals - Screen Management - Screen Timeout Customize how long it takes for your screen to turn off. --- selfdrive/ui/qt/window.cc | 2 +- selfdrive/ui/ui.cc | 5 ++++- selfdrive/ui/ui.h | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/selfdrive/ui/qt/window.cc b/selfdrive/ui/qt/window.cc index 985021a..b6d90d4 100644 --- a/selfdrive/ui/qt/window.cc +++ b/selfdrive/ui/qt/window.cc @@ -93,7 +93,7 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *event) { case QEvent::MouseMove: { // ignore events when device is awakened by resetInteractiveTimeout ignore = !device()->isAwake(); - device()->resetInteractiveTimeout(); + device()->resetInteractiveTimeout(uiState()->scene.screen_timeout; break; } default: diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index e90eca8..4da6736 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -416,6 +416,7 @@ void ui_update_frogpilot_params(UIState *s) { scene.screen_brightness = screen_management ? params.getInt("ScreenBrightness") : 101; scene.screen_brightness_onroad = screen_management ? params.getInt("ScreenBrightnessOnroad") : 101; scene.screen_recorder = screen_management && params.getBool("ScreenRecorder"); + scene.screen_timeout = screen_management ? params.getInt("ScreenTimeout") : 30; scene.speed_limit_controller = scene.longitudinal_control && params.getBool("SpeedLimitController"); scene.show_slc_offset = scene.speed_limit_controller && params.getBool("ShowSLCOffset"); @@ -537,6 +538,8 @@ void Device::setAwake(bool on) { void Device::resetInteractiveTimeout(int timeout) { if (timeout == -1) { timeout = (ignition_on ? 10 : 30); + } else { + timeout = timeout; } interactive_timeout = timeout * UI_FREQ; } @@ -579,7 +582,7 @@ void Device::updateWakefulness(const UIState &s) { ignition_on = s.scene.ignition; if (ignition_just_turned_off) { - resetInteractiveTimeout(); + resetInteractiveTimeout(s.scene.screen_timeout); } else if (interactive_timeout > 0 && --interactive_timeout == 0) { emit interactiveTimeout(); } diff --git a/selfdrive/ui/ui.h b/selfdrive/ui/ui.h index 34bfe10..8d402e3 100644 --- a/selfdrive/ui/ui.h +++ b/selfdrive/ui/ui.h @@ -306,6 +306,7 @@ typedef struct UIScene { int obstacle_distance_stock; int screen_brightness; int screen_brightness_onroad; + int screen_timeout; int steering_angle_deg; int stopped_equivalence; int wheel_icon;