Visuals - Screen Management - Screen Timeout (Onroad)

Customize how long it takes for your screen to turn off when onroad.
This commit is contained in:
FrogAi 2024-05-11 15:56:23 -07:00
parent f6aaedd9c9
commit 5269efbf3d
3 changed files with 9 additions and 7 deletions

View File

@ -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(uiState()->scene.screen_timeout;
device()->resetInteractiveTimeout(uiState()->scene.screen_timeout, uiState()->scene.screen_timeout_onroad);
break;
}
default:

View File

@ -437,6 +437,7 @@ void ui_update_frogpilot_params(UIState *s, Params &params) {
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.screen_timeout_onroad = screen_management ? params.getInt("ScreenTimeoutOnroad") : 10;
scene.speed_limit_controller = scene.longitudinal_control && params.getBool("SpeedLimitController");
scene.show_slc_offset = scene.speed_limit_controller && params.getBool("ShowSLCOffset");
@ -580,11 +581,11 @@ void Device::setAwake(bool on) {
}
}
void Device::resetInteractiveTimeout(int timeout) {
void Device::resetInteractiveTimeout(int timeout, int timeout_onroad) {
if (timeout == -1) {
timeout = (ignition_on ? 10 : 30);
} else {
timeout = timeout;
timeout = (ignition_on ? timeout_onroad : timeout);
}
interactive_timeout = timeout * UI_FREQ;
}
@ -623,11 +624,11 @@ void Device::updateBrightness(const UIState &s) {
}
void Device::updateWakefulness(const UIState &s) {
bool ignition_just_turned_off = !s.scene.ignition && ignition_on;
bool ignition_state_changed = s.scene.ignition != ignition_on;
ignition_on = s.scene.ignition;
if (ignition_just_turned_off) {
resetInteractiveTimeout(s.scene.screen_timeout);
if (ignition_state_changed) {
resetInteractiveTimeout(s.scene.screen_timeout, s.scene.screen_timeout_onroad);
} else if (interactive_timeout > 0 && --interactive_timeout == 0) {
emit interactiveTimeout();
}

View File

@ -252,6 +252,7 @@ typedef struct UIScene {
int screen_brightness;
int screen_brightness_onroad;
int screen_timeout;
int screen_timeout_onroad;
int started_timer;
int steering_angle_deg;
int stopped_equivalence;
@ -344,7 +345,7 @@ signals:
void interactiveTimeout();
public slots:
void resetInteractiveTimeout(int timeout = -1);
void resetInteractiveTimeout(int timeout = -1, int timeout_onroad = -1);
void update(const UIState &s);
};