Screen Management
Added toggles to adjust the screen brightness, timeout settings, and other UI changes.
This commit is contained in:
@@ -289,6 +289,11 @@ void OnroadAlerts::paintEvent(QPaintEvent *event) {
|
||||
if (alert.size == cereal::ControlsState::AlertSize::NONE || scene.show_driver_camera && alert.status != cereal::ControlsState::AlertStatus::CRITICAL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (scene.hide_alerts && alert.size == cereal::ControlsState::AlertSize::SMALL) {
|
||||
return;
|
||||
}
|
||||
|
||||
static std::map<cereal::ControlsState::AlertSize, const int> alert_heights = {
|
||||
{cereal::ControlsState::AlertSize::SMALL, 271},
|
||||
{cereal::ControlsState::AlertSize::MID, 420},
|
||||
@@ -390,6 +395,10 @@ void ExperimentalButton::updateState(const UIState &s, bool leadInfo) {
|
||||
}
|
||||
|
||||
void ExperimentalButton::paintEvent(QPaintEvent *event) {
|
||||
if (wheelIcon < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
QPainter p(this);
|
||||
QPixmap img = experimental_mode ? experimental_img : engage_img;
|
||||
|
||||
@@ -499,7 +508,7 @@ void AnnotatedCameraWidget::updateState(const UIState &s) {
|
||||
|
||||
// hide map settings button for alerts and flip for right hand DM
|
||||
if (map_settings_btn->isEnabled()) {
|
||||
map_settings_btn->setVisible(!hideBottomIcons && compass);
|
||||
map_settings_btn->setVisible(!hideBottomIcons && compass && !scene.hide_map_icon);
|
||||
main_layout->setAlignment(map_settings_btn, (rightHandDM ? Qt::AlignLeft : Qt::AlignRight) | (compass ? Qt::AlignTop : Qt::AlignBottom));
|
||||
}
|
||||
}
|
||||
@@ -517,7 +526,7 @@ void AnnotatedCameraWidget::drawHud(QPainter &p) {
|
||||
QString speedStr = QString::number(std::nearbyint(speed));
|
||||
QString setSpeedStr = is_cruise_set ? QString::number(std::nearbyint(setSpeed - cruiseAdjustment)) : "–";
|
||||
|
||||
if (!showDriverCamera) {
|
||||
if (!(scene.hide_max_speed || showDriverCamera)) {
|
||||
// Draw outer box + border to contain set speed and speed limit
|
||||
const int sign_margin = 12;
|
||||
const int us_sign_height = 186;
|
||||
@@ -1005,17 +1014,19 @@ void AnnotatedCameraWidget::paintGL() {
|
||||
CameraWidget::setStreamType(cameraView == 3 || showDriverCamera ? VISION_STREAM_DRIVER :
|
||||
cameraView == 2 || wide_cam_requested ? VISION_STREAM_WIDE_ROAD :
|
||||
VISION_STREAM_ROAD);
|
||||
|
||||
s->scene.wide_cam = CameraWidget::getStreamType() == VISION_STREAM_WIDE_ROAD;
|
||||
if (s->scene.calibration_valid) {
|
||||
auto calib = s->scene.wide_cam ? s->scene.view_from_wide_calib : s->scene.view_from_calib;
|
||||
CameraWidget::updateCalibration(calib);
|
||||
} else {
|
||||
CameraWidget::updateCalibration(DEFAULT_CALIBRATION);
|
||||
}
|
||||
CameraWidget::setFrameId(model.getFrameId());
|
||||
CameraWidget::paintGL();
|
||||
|
||||
s->scene.wide_cam = CameraWidget::getStreamType() == VISION_STREAM_WIDE_ROAD;
|
||||
if (s->scene.calibration_valid) {
|
||||
auto calib = s->scene.wide_cam ? s->scene.view_from_wide_calib : s->scene.view_from_calib;
|
||||
CameraWidget::updateCalibration(calib);
|
||||
} else {
|
||||
CameraWidget::updateCalibration(DEFAULT_CALIBRATION);
|
||||
}
|
||||
painter.beginNativePainting();
|
||||
CameraWidget::setFrameId(model.getFrameId());
|
||||
CameraWidget::paintGL();
|
||||
painter.endNativePainting();
|
||||
|
||||
QPainter painter(this);
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
@@ -1025,7 +1036,7 @@ void AnnotatedCameraWidget::paintGL() {
|
||||
update_model(s, model, sm["uiPlan"].getUiPlan());
|
||||
drawLaneLines(painter, s);
|
||||
|
||||
if (s->scene.longitudinal_control && sm.rcv_frame("radarState") > s->scene.started_frame) {
|
||||
if (s->scene.longitudinal_control && sm.rcv_frame("radarState") > s->scene.started_frame && !scene.hide_lead_marker) {
|
||||
auto radar_state = sm["radarState"].getRadarState();
|
||||
update_leads(s, radar_state, model.getPosition());
|
||||
auto lead_one = radar_state.getLeadOne();
|
||||
@@ -1145,7 +1156,7 @@ void AnnotatedCameraWidget::initializeFrogPilotWidgets() {
|
||||
}
|
||||
|
||||
void AnnotatedCameraWidget::updateFrogPilotWidgets(QPainter &p) {
|
||||
alwaysOnLateral = scene.always_on_lateral;
|
||||
alwaysOnLateral = scene.always_on_lateral && !scene.hide_aol_status_bar;
|
||||
alwaysOnLateralActive = scene.always_on_lateral_active;
|
||||
|
||||
blindSpotLeft = scene.blind_spot_left;
|
||||
@@ -1155,7 +1166,7 @@ void AnnotatedCameraWidget::updateFrogPilotWidgets(QPainter &p) {
|
||||
|
||||
compass = scene.compass;
|
||||
|
||||
conditionalExperimental = scene.conditional_experimental;
|
||||
conditionalExperimental = scene.conditional_experimental && !scene.hide_cem_status_bar;
|
||||
conditionalSpeed = scene.conditional_speed;
|
||||
conditionalSpeedLead = scene.conditional_speed_lead;
|
||||
conditionalStatus = scene.conditional_status;
|
||||
@@ -1220,10 +1231,12 @@ void AnnotatedCameraWidget::updateFrogPilotWidgets(QPainter &p) {
|
||||
|
||||
map_settings_btn_bottom->setEnabled(map_settings_btn->isEnabled());
|
||||
if (map_settings_btn_bottom->isEnabled()) {
|
||||
map_settings_btn_bottom->setVisible(!hideBottomIcons && !compass);
|
||||
map_settings_btn_bottom->setVisible(!hideBottomIcons && !compass && !scene.hide_map_icon);
|
||||
bottom_layout->setAlignment(map_settings_btn_bottom, rightHandDM ? Qt::AlignLeft : Qt::AlignRight);
|
||||
}
|
||||
|
||||
recorder_btn->setVisible(scene.screen_recorder && !mapOpen);
|
||||
|
||||
// Update the turn signal animation images upon toggle change
|
||||
if (customSignals != scene.custom_signals || currentHolidayTheme != scene.current_holiday_theme) {
|
||||
currentHolidayTheme = scene.current_holiday_theme;
|
||||
|
||||
@@ -92,7 +92,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, uiState()->scene.screen_timeout_onroad);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -176,6 +176,7 @@ typedef struct UIScene {
|
||||
|
||||
// FrogPilot variables
|
||||
bool acceleration_path;
|
||||
bool active_alert;
|
||||
bool adjacent_path;
|
||||
bool adjacent_path_metrics;
|
||||
bool always_on_lateral;
|
||||
@@ -194,6 +195,12 @@ typedef struct UIScene {
|
||||
bool fahrenheit;
|
||||
bool fps_counter;
|
||||
bool full_map;
|
||||
bool hide_alerts;
|
||||
bool hide_aol_status_bar;
|
||||
bool hide_cem_status_bar;
|
||||
bool hide_lead_marker;
|
||||
bool hide_map_icon;
|
||||
bool hide_max_speed;
|
||||
bool hide_speed;
|
||||
bool hide_speed_ui;
|
||||
bool holiday_themes;
|
||||
@@ -207,8 +214,11 @@ typedef struct UIScene {
|
||||
bool reverse_cruise_ui;
|
||||
bool road_name_ui;
|
||||
bool rotating_wheel;
|
||||
bool screen_recorder;
|
||||
bool show_driver_camera;
|
||||
bool standby_mode;
|
||||
bool standstill;
|
||||
bool status_changed;
|
||||
bool tethering_enabled;
|
||||
bool turn_signal_left;
|
||||
bool turn_signal_right;
|
||||
@@ -237,6 +247,9 @@ typedef struct UIScene {
|
||||
int obstacle_distance;
|
||||
int obstacle_distance_stock;
|
||||
int screen_brightness;
|
||||
int screen_brightness_onroad;
|
||||
int screen_timeout;
|
||||
int screen_timeout_onroad;
|
||||
int steering_angle_deg;
|
||||
int stopped_equivalence;
|
||||
|
||||
@@ -270,8 +283,11 @@ public:
|
||||
|
||||
QTransform car_space_transform;
|
||||
|
||||
// FrogPilot variables
|
||||
WifiManager *wifi = nullptr;
|
||||
|
||||
UIStatus previous_status;
|
||||
|
||||
signals:
|
||||
void uiUpdate(const UIState &s);
|
||||
void offroadTransition(bool offroad);
|
||||
@@ -319,7 +335,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);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user