Screen Management
Added toggles to adjust the screen brightness, timeout settings, and other UI changes.
This commit is contained in:
@@ -303,12 +303,15 @@ void ui_update_frogpilot_params(UIState *s) {
|
||||
UIScene &scene = s->scene;
|
||||
|
||||
scene.always_on_lateral = params.getBool("AlwaysOnLateral");
|
||||
scene.hide_aol_status_bar = scene.always_on_lateral && params.getBool("HideAOLStatusBar");
|
||||
|
||||
scene.camera_view = params.getInt("CameraView");
|
||||
scene.compass = params.getBool("Compass");
|
||||
|
||||
scene.conditional_experimental = params.getBool("ConditionalExperimental");
|
||||
scene.conditional_speed = params.getInt("CESpeed");
|
||||
scene.conditional_speed_lead = params.getInt("CESpeedLead");
|
||||
scene.conditional_speed = scene.conditional_experimental ? params.getInt("CESpeed") : 0;
|
||||
scene.conditional_speed_lead = scene.conditional_experimental ? params.getInt("CESpeedLead") : 0;
|
||||
scene.hide_cem_status_bar = scene.conditional_experimental && params.getBool("HideCEMStatusBar");
|
||||
|
||||
bool custom_onroad_ui = params.getBool("CustomUI");
|
||||
scene.acceleration_path = custom_onroad_ui && params.getBool("AccelerationPath");
|
||||
@@ -334,6 +337,7 @@ void ui_update_frogpilot_params(UIState *s) {
|
||||
|
||||
scene.model_ui = params.getBool("ModelUI");
|
||||
scene.dynamic_path_width = scene.model_ui && params.getBool("DynamicPathWidth");
|
||||
scene.hide_lead_marker = scene.model_ui && params.getBool("HideLeadMarker");
|
||||
scene.lane_line_width = params.getInt("LaneLinesWidth") * (scene.is_metric ? 1.0f : INCH_TO_CM) / 200.0f;
|
||||
scene.path_edge_width = params.getInt("PathEdgeWidth");
|
||||
scene.path_width = params.getInt("PathWidth") / 10.0f * (scene.is_metric ? 1.0f : FOOT_TO_METER) / 2.0f;
|
||||
@@ -352,7 +356,18 @@ void ui_update_frogpilot_params(UIState *s) {
|
||||
scene.hide_speed_ui = scene.hide_speed && params.getBool("HideSpeedUI");
|
||||
|
||||
scene.rotating_wheel = params.getBool("RotatingWheel");
|
||||
scene.screen_brightness = params.getInt("ScreenBrightness");
|
||||
|
||||
bool screen_management = params.getBool("ScreenManagement");
|
||||
bool hide_ui_elements = screen_management && params.getBool("HideUIElements");
|
||||
scene.hide_alerts = hide_ui_elements && params.getBool("HideAlerts");
|
||||
scene.hide_map_icon = hide_ui_elements && params.getBool("HideMapIcon");
|
||||
scene.hide_max_speed = hide_ui_elements && params.getBool("HideMaxSpeed");
|
||||
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.screen_timeout_onroad = screen_management ? params.getInt("ScreenTimeoutOnroad") : 10;
|
||||
scene.standby_mode = screen_management && params.getBool("StandbyMode");
|
||||
}
|
||||
|
||||
void UIState::updateStatus() {
|
||||
@@ -366,6 +381,12 @@ void UIState::updateStatus() {
|
||||
} else {
|
||||
status = controls_state.getEnabled() ? STATUS_ENGAGED : STATUS_DISENGAGED;
|
||||
}
|
||||
|
||||
// Trigger standby mode on alerts and status changes
|
||||
scene.active_alert = controls_state.getAlertStatus() != cereal::ControlsState::AlertStatus::NORMAL;
|
||||
scene.status_changed = status != previous_status;
|
||||
|
||||
previous_status = status;
|
||||
}
|
||||
|
||||
// Handle onroad/offroad transition
|
||||
@@ -468,9 +489,11 @@ void Device::setAwake(bool on) {
|
||||
}
|
||||
}
|
||||
|
||||
void Device::resetInteractiveTimeout(int timeout) {
|
||||
void Device::resetInteractiveTimeout(int timeout, int timeout_onroad) {
|
||||
if (timeout == -1) {
|
||||
timeout = 30;
|
||||
timeout = (ignition_on ? 10 : 30);
|
||||
} else {
|
||||
timeout = (ignition_on ? timeout_onroad : timeout);
|
||||
}
|
||||
interactive_timeout = timeout * UI_FREQ;
|
||||
}
|
||||
@@ -494,8 +517,10 @@ void Device::updateBrightness(const UIState &s) {
|
||||
int brightness = brightness_filter.update(clipped_brightness);
|
||||
if (!awake) {
|
||||
brightness = 0;
|
||||
} else if (s.scene.screen_brightness <= 100) {
|
||||
} else if (s.scene.started && s.scene.screen_brightness_onroad != 101) {
|
||||
// Bring the screen brightness up to 5% upon screen tap
|
||||
brightness = interactive_timeout > 0 ? fmax(5, s.scene.screen_brightness_onroad) : s.scene.screen_brightness_onroad;
|
||||
} else if (s.scene.screen_brightness != 101) {
|
||||
brightness = fmax(5, s.scene.screen_brightness);
|
||||
}
|
||||
|
||||
@@ -508,16 +533,27 @@ 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();
|
||||
if (ignition_on && s.scene.standby_mode) {
|
||||
if (s.scene.active_alert || s.scene.speed_limit_changed || s.scene.status_changed) {
|
||||
resetInteractiveTimeout(s.scene.screen_timeout, s.scene.screen_timeout_onroad);
|
||||
}
|
||||
}
|
||||
|
||||
if (ignition_state_changed) {
|
||||
// Instantly turn off the screen if the onroad brightness is set to 0%
|
||||
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();
|
||||
}
|
||||
|
||||
if (s.scene.screen_brightness != 0) {
|
||||
if (s.scene.screen_brightness_onroad != 0) {
|
||||
setAwake(s.scene.ignition || interactive_timeout > 0);
|
||||
} else {
|
||||
setAwake(interactive_timeout > 0);
|
||||
|
||||
Reference in New Issue
Block a user