From d2ea0590136698a4a3ad961d4906981cb87a79d8 Mon Sep 17 00:00:00 2001 From: FrogAi <91348155+FrogAi@users.noreply.github.com> Date: Wed, 6 Mar 2024 18:53:46 -0700 Subject: [PATCH] Screen Management Added toggles to adjust the screen brightness, timeout settings, and other UI changes. --- common/params.cc | 13 +++++ selfdrive/frogpilot/fleetmanager/helpers.py | 32 ++++++------ selfdrive/frogpilot/ui/control_settings.cc | 33 ++++++------ selfdrive/frogpilot/ui/control_settings.h | 3 +- selfdrive/frogpilot/ui/visual_settings.cc | 30 +++++++++-- selfdrive/frogpilot/ui/visual_settings.h | 3 +- selfdrive/ui/qt/onroad.cc | 43 ++++++++++------ selfdrive/ui/qt/window.cc | 2 +- selfdrive/ui/ui.cc | 56 +++++++++++++++++---- selfdrive/ui/ui.h | 18 ++++++- 10 files changed, 173 insertions(+), 60 deletions(-) diff --git a/common/params.cc b/common/params.cc index dbdd3d4..d2ce7b1 100644 --- a/common/params.cc +++ b/common/params.cc @@ -280,8 +280,15 @@ std::unordered_map keys = { {"GMapKey", PERSISTENT}, {"GoatScream", PERSISTENT}, {"GreenLightAlert", PERSISTENT}, + {"HideAlerts", PERSISTENT}, + {"HideAOLStatusBar", PERSISTENT}, + {"HideCEMStatusBar", PERSISTENT}, + {"HideLeadMarker", PERSISTENT}, + {"HideMapIcon", PERSISTENT}, + {"HideMaxSpeed", PERSISTENT}, {"HideSpeed", PERSISTENT}, {"HideSpeedUI", PERSISTENT}, + {"HideUIElements", PERSISTENT}, {"HigherBitrate", PERSISTENT}, {"HolidayThemes", PERSISTENT}, {"LaneChangeTime", PERSISTENT}, @@ -343,6 +350,11 @@ std::unordered_map keys = { {"RotatingWheel", PERSISTENT}, {"SchedulePending", PERSISTENT}, {"ScreenBrightness", PERSISTENT}, + {"ScreenBrightnessOnroad", PERSISTENT}, + {"ScreenManagement", PERSISTENT}, + {"ScreenRecorder", PERSISTENT}, + {"ScreenTimeout", PERSISTENT}, + {"ScreenTimeoutOnroad", PERSISTENT}, {"SearchInput", PERSISTENT}, {"SilentMode", PERSISTENT}, {"ShowCPU", PERSISTENT}, @@ -352,6 +364,7 @@ std::unordered_map keys = { {"ShowStorageUsed", PERSISTENT}, {"StandardFollow", PERSISTENT}, {"StandardJerk", PERSISTENT}, + {"StandbyMode", PERSISTENT}, {"StockTune", PERSISTENT}, {"StoppingDistance", PERSISTENT}, {"TetheringEnabled", PERSISTENT}, diff --git a/selfdrive/frogpilot/fleetmanager/helpers.py b/selfdrive/frogpilot/fleetmanager/helpers.py index 273efd0..65f1ce7 100644 --- a/selfdrive/frogpilot/fleetmanager/helpers.py +++ b/selfdrive/frogpilot/fleetmanager/helpers.py @@ -441,26 +441,30 @@ def transform_lng(lng, lat): def get_all_toggle_values(): all_keys = [ - "AdjustablePersonalities", "PersonalitiesViaWheel", "PersonalitiesViaScreen", "AlwaysOnLateral", "AlwaysOnLateralMain", + "AdjustablePersonalities", "PersonalitiesViaWheel", "PersonalitiesViaScreen", "AlwaysOnLateral", "AlwaysOnLateralMain", "HideAOLStatusBar", "ConditionalExperimental", "CESpeed", "CESpeedLead", "CECurves", "CECurvesLead", "CENavigation", "CENavigationIntersections", - "CENavigationLead", "CENavigationTurns", "CESlowerLead", "CEStopLights", "CEStopLightsLead", "CESignal", "CustomPersonalities", - "AggressiveFollow", "AggressiveJerk", "StandardFollow", "StandardJerk", "RelaxedFollow", "RelaxedJerk", "DeviceShutdown", + "CENavigationLead", "CENavigationTurns", "CESlowerLead", "CEStopLights", "CEStopLightsLead", "CESignal", "HideCEMStatusBar", + "CustomPersonalities", "AggressiveFollow", "AggressiveJerk", "StandardFollow", "StandardJerk", "RelaxedFollow", "RelaxedJerk", "DeviceShutdown", "ExperimentalModeActivation", "ExperimentalModeViaDistance", "ExperimentalModeViaLKAS", "ExperimentalModeViaScreen", "FireTheBabysitter", - "NoLogging", "MuteOverheated", "OfflineMode", "LateralTune", "ForceAutoTune", "NNFF", "SteerRatio", "UseLateralJerk", "LongitudinalTune", + "NoLogging", "NoUploads", "MuteOverheated", "OfflineMode", "LateralTune", "ForceAutoTune", "NNFF", "SteerRatio", "UseLateralJerk", "LongitudinalTune", "AccelerationProfile", "DecelerationProfile", "AggressiveAcceleration", "StoppingDistance", "SmoothBraking", "Model", "MTSCEnabled", "DisableMTSCSmoothing", "MTSCAggressiveness", "MTSCCurvatureCheck", "MTSCLimit", "NudgelessLaneChange", "LaneChangeTime", "LaneDetection", "LaneDetectionWidth", "OneLaneChange", "QOLControls", "DisableOnroadUploads", "HigherBitrate", "NavChill", "PauseLateralOnSignal", "ReverseCruise", "ReverseCruiseUI", "SetSpeedLimit", "SetSpeedOffset", "SpeedLimitController", "Offset1", "Offset2", "Offset3", "Offset4", - "SLCConfirmation", "SLCFallback", "SLCPriority1", "SLCPriority2", "SLCPriority3", "SLCOverride", "TurnDesires", "VisionTurnControl", - "DisableVTSCSmoothing", "CurveSensitivity", "TurnAggressiveness", "EVTable", "GasRegenCmd", "LongPitch", "LowerVolt", "CrosstrekTorque", - "CydiaTune", "DragonPilotTune", "FrogsGoMooTune", "LockDoors", "SNGHack", "CustomTheme", "CustomColors", "CustomIcons", "CustomSignals", - "CustomSounds", "GoatScream", "AlertVolumeControl", "DisengageVolume", "EngageVolume", "PromptVolume", "PromptDistractedVolume", "RefuseVolume", - "WarningSoftVolume", "WarningImmediateVolume", "CameraView", "Compass", "CustomAlerts", "GreenLightAlert", "LeadDepartingAlert", "LoudBlindspotAlert", - "SpeedLimitChangedAlert", "CustomUI", "AccelerationPath", "AdjacentPath", "AdjacentPathMetrics", "BlindSpotPath", "FPSCounter", "LeadInfo", "UseSI", - "PedalsOnUI", "RoadNameUI", "UseVienna", "DriverCamera", "ModelUI", "DynamicPathWidth", "LaneLinesWidth", "PathEdgeWidth", "PathWidth", - "RoadEdgesWidth", "UnlimitedLength", "QOLVisuals", "DriveStats", "FullMap", "HideSpeed", "HideSpeedUI", "ShowSLCOffset", "WheelSpeed", - "RandomEvents", "ScreenBrightness", "WheelIcon", "RotatingWheel", "NumericalTemp", "Fahrenheit", "ShowCPU", "ShowGPU", "ShowIP", "ShowMemoryUsage", - "ShowStorageLeft", "ShowStorageUsed", "Sidebar" + "SLCConfirmation", "SLCConfirmationLower", "SLCConfirmationHigher", "SLCFallback", "SLCPriority1", "SLCPriority2", "SLCPriority3", "SLCOverride", + "TurnDesires", "VisionTurnControl", "DisableVTSCSmoothing", "CurveSensitivity", "TurnAggressiveness", + + "EVTable", "GasRegenCmd", "LongPitch", "LowerVolt", "CrosstrekTorque", "CydiaTune", "DragonPilotTune", "FrogsGoMooTune", "LockDoors", "SNGHack", + + "CustomTheme", "CustomColors", "CustomIcons", "CustomSignals", "CustomSounds", "GoatScream", "AlertVolumeControl", "DisengageVolume", + "EngageVolume", "PromptVolume", "PromptDistractedVolume", "RefuseVolume", "WarningSoftVolume", "WarningImmediateVolume", "CameraView", + "Compass", "CustomAlerts", "GreenLightAlert", "LeadDepartingAlert", "LoudBlindspotAlert", "SpeedLimitChangedAlert", "CustomUI", "AccelerationPath", + "AdjacentPath", "AdjacentPathMetrics", "BlindSpotPath", "FPSCounter", "LeadInfo", "UseSI", "PedalsOnUI", "RoadNameUI", "UseVienna", "DriverCamera", + "ModelUI", "DynamicPathWidth", "HideLeadMarker", "LaneLinesWidth", "PathEdgeWidth", "PathWidth", "RoadEdgesWidth", "UnlimitedLength", "QOLVisuals", + "DriveStats", "FullMap", "HideSpeed", "HideSpeedUI", "ShowSLCOffset", "SpeedLimitChangedAlert", "WheelSpeed", "RandomEvents", "ScreenManagement", + "HideUIElements", "HideAlerts", "HideMapIcon", "HideMaxSpeed", "ScreenBrightness", "ScreenBrightnessOnroad", "ScreenTimeout", "ScreenTimeoutOnroad", + "ScreenRecorder", "StandbyMode", "WheelIcon", "RotatingWheel", "NumericalTemp", "Fahrenheit", "ShowCPU", "ShowGPU", "ShowIP", "ShowMemoryUsage", + "ShowStorageLeft", "ShowStorageUsed", "Sidebar", ] toggle_values = {} diff --git a/selfdrive/frogpilot/ui/control_settings.cc b/selfdrive/frogpilot/ui/control_settings.cc index 38e7c5e..0ae1bb3 100644 --- a/selfdrive/frogpilot/ui/control_settings.cc +++ b/selfdrive/frogpilot/ui/control_settings.cc @@ -3,6 +3,8 @@ FrogPilotControlsPanel::FrogPilotControlsPanel(SettingsWindow *parent) : FrogPilotListWidget(parent) { const std::vector> controlToggles { {"AlwaysOnLateral", "Always on Lateral", "Maintain openpilot lateral control when the brake or gas pedals are used.\n\nDeactivation occurs only through the 'Cruise Control' button.", "../frogpilot/assets/toggle_icons/icon_always_on_lateral.png"}, + {"AlwaysOnLateralMain", "Enable On Cruise Main", "Enable 'Always On Lateral' by simply turning on 'Cruise Control'.", ""}, + {"HideAOLStatusBar", "Hide the Status Bar", "Don't use the status bar for 'Always On Lateral'.", ""}, {"ConditionalExperimental", "Conditional Experimental Mode", "Automatically switches to 'Experimental Mode' under predefined conditions.", "../frogpilot/assets/toggle_icons/icon_conditional.png"}, {"CECurves", "Curve Detected Ahead", "Switch to 'Experimental Mode' when a curve is detected.", ""}, @@ -10,6 +12,7 @@ FrogPilotControlsPanel::FrogPilotControlsPanel(SettingsWindow *parent) : FrogPil {"CESlowerLead", "Slower Lead Detected Ahead", "Switch to 'Experimental Mode' when a slower lead vehicle is detected ahead.", ""}, {"CEStopLights", "Stop Lights and Stop Signs", "Switch to 'Experimental Mode' when a stop light or stop sign is detected.", ""}, {"CESignal", "Turn Signal When Below Highway Speeds", "Switch to 'Experimental Mode' when using turn signals below highway speeds to help assit with turns.", ""}, + {"HideCEMStatusBar", "Hide the Status Bar", "Don't use the status bar for 'Conditional Experimental Mode'.", ""}, {"CustomPersonalities", "Custom Driving Personalities", "Customize the driving personality profiles to your driving style.", "../frogpilot/assets/toggle_icons/icon_custom.png"}, {"DeviceShutdown", "Device Shutdown Timer", "Configure the timer for automatic device shutdown when offroad conserving energy and preventing battery drain.", "../frogpilot/assets/toggle_icons/icon_time.png"}, @@ -61,21 +64,14 @@ FrogPilotControlsPanel::FrogPilotControlsPanel(SettingsWindow *parent) : FrogPil ParamControl *toggle; if (param == "AlwaysOnLateral") { - std::vector aolToggles{"AlwaysOnLateralMain"}; - std::vector aolToggleNames{tr("Enable On Cruise Main")}; - toggle = new FrogPilotParamToggleControl(param, title, desc, icon, aolToggles, aolToggleNames); - - QObject::connect(static_cast(toggle), &FrogPilotParamToggleControl::buttonClicked, [this](const bool checked) { - if (checked) { - FrogPilotConfirmationDialog::toggleAlert("WARNING: This is very experimental and isn't guaranteed to work. If you run into any issues, please report it in the FrogPilot Discord!", - "I understand the risks.", this); - } - if (started) { - if (FrogPilotConfirmationDialog::toggle("Reboot required to take effect.", "Reboot Now", this)) { - Hardware::soft_reboot(); - } + FrogPilotParamManageControl *aolToggle = new FrogPilotParamManageControl(param, title, desc, icon, this); + QObject::connect(aolToggle, &FrogPilotParamManageControl::manageButtonClicked, this, [this]() { + parentToggleClicked(); + for (auto &[key, toggle] : toggles) { + toggle->setVisible(aolKeys.find(key.c_str()) != aolKeys.end()); } }); + toggle = aolToggle; } else if (param == "ConditionalExperimental") { FrogPilotParamManageControl *conditionalExperimentalToggle = new FrogPilotParamManageControl(param, title, desc, icon, this); @@ -335,6 +331,14 @@ FrogPilotControlsPanel::FrogPilotControlsPanel(SettingsWindow *parent) : FrogPil }); } + QObject::connect(toggles["AlwaysOnLateralMain"], &ToggleControl::toggleFlipped, [this]() { + if (params.getBool("AlwaysOnLateralMain")) { + FrogPilotConfirmationDialog::toggleAlert( + "WARNING: This isn't guaranteed to work, so if you run into any issues, please report it in the FrogPilot Discord!", + "I understand the risks.", this); + } + }); + QObject::connect(toggles["MuteOverheated"], &ToggleControl::toggleFlipped, [this]() { if (params.getBool("MuteOverheated")) { FrogPilotConfirmationDialog::toggleAlert( @@ -448,7 +452,8 @@ void FrogPilotControlsPanel::hideSubToggles() { relaxedProfile->setVisible(false); for (auto &[key, toggle] : toggles) { - bool subToggles = conditionalExperimentalKeys.find(key.c_str()) != conditionalExperimentalKeys.end() || + bool subToggles = aolKeys.find(key.c_str()) != aolKeys.end() || + conditionalExperimentalKeys.find(key.c_str()) != conditionalExperimentalKeys.end() || experimentalModeActivationKeys.find(key.c_str()) != experimentalModeActivationKeys.end() || fireTheBabysitterKeys.find(key.c_str()) != fireTheBabysitterKeys.end() || laneChangeKeys.find(key.c_str()) != laneChangeKeys.end() || diff --git a/selfdrive/frogpilot/ui/control_settings.h b/selfdrive/frogpilot/ui/control_settings.h index 3aa7209..82570db 100644 --- a/selfdrive/frogpilot/ui/control_settings.h +++ b/selfdrive/frogpilot/ui/control_settings.h @@ -37,7 +37,8 @@ private: FrogPilotDualParamControl *standardProfile; FrogPilotDualParamControl *relaxedProfile; - std::set conditionalExperimentalKeys = {"CECurves", "CECurvesLead", "CESlowerLead", "CENavigation", "CEStopLights", "CESignal"}; + std::set aolKeys = {"AlwaysOnLateralMain", "HideAOLStatusBar"}; + std::set conditionalExperimentalKeys = {"CECurves", "CECurvesLead", "CESlowerLead", "CENavigation", "CEStopLights", "CESignal", "HideCEMStatusBar"}; std::set experimentalModeActivationKeys = {"ExperimentalModeViaDistance", "ExperimentalModeViaLKAS", "ExperimentalModeViaScreen"}; std::set fireTheBabysitterKeys = {"NoLogging", "MuteOverheated", "NoUploads", "OfflineMode"}; std::set laneChangeKeys = {"LaneChangeTime", "LaneDetection", "LaneDetectionWidth", "OneLaneChange"}; diff --git a/selfdrive/frogpilot/ui/visual_settings.cc b/selfdrive/frogpilot/ui/visual_settings.cc index 681572a..9da8368 100644 --- a/selfdrive/frogpilot/ui/visual_settings.cc +++ b/selfdrive/frogpilot/ui/visual_settings.cc @@ -39,6 +39,7 @@ FrogPilotVisualsPanel::FrogPilotVisualsPanel(SettingsWindow *parent) : FrogPilot {"ModelUI", "Model UI", "Personalize how the model's visualizations appear on your screen.", "../assets/offroad/icon_calibration.png"}, {"DynamicPathWidth", "Dynamic Path Width", "Have the path width dynamically adjust based on the current engagement state of openpilot.", ""}, + {"HideLeadMarker", "Hide Lead Marker", "Hide the lead marker from the onroad UI.", ""}, {"LaneLinesWidth", "Lane Lines", "Adjust the visual thickness of lane lines on your display.\n\nDefault matches the MUTCD average of 4 inches.", ""}, {"PathEdgeWidth", "Path Edges", "Adjust the width of the path edges shown on your UI to represent different driving modes and statuses.\n\nDefault is 20% of the total path.\n\nBlue = Navigation\nLight Blue = Always On Lateral\nGreen = Default with 'FrogPilot Colors'\nLight Green = Default with stock colors\nOrange = Experimental Mode Active\nYellow = Conditional Overriden", ""}, {"PathWidth", "Path Width", "Customize the width of the driving path shown on your UI.\n\nDefault matches the width of a 2019 Lexus ES 350.", ""}, @@ -52,7 +53,14 @@ FrogPilotVisualsPanel::FrogPilotVisualsPanel(SettingsWindow *parent) : FrogPilot {"FullMap", "Full Sized Map", "Maximize the size of the map in the onroad UI.", ""}, {"HideSpeed", "Hide Speed", "Hide the speed indicator in the onroad UI. Additional toggle allows it to be hidden/shown via tapping the speed itself.", ""}, - {"ScreenBrightness", "Screen Brightness", "Customize your screen brightness.", "../frogpilot/assets/toggle_icons/icon_light.png"}, + {"ScreenManagement", "Screen Management", "Manage your screen's brightness, timeout settings, and hide specific onroad UI elements.", "../frogpilot/assets/toggle_icons/icon_light.png"}, + {"HideUIElements", "Hide UI Elements", "Hide the selected UI elements from the onroad screen.", ""}, + {"ScreenBrightness", "Screen Brightness", "Customize your screen brightness when offroad.", ""}, + {"ScreenBrightnessOnroad", "Screen Brightness (Onroad)", "Customize your screen brightness when onroad.", ""}, + {"ScreenRecorder", "Screen Recorder", "Enable the screen recorder button to record the screen.", ""}, + {"ScreenTimeout", "Screen Timeout", "Customize how long it takes for your screen to turn off.", ""}, + {"ScreenTimeoutOnroad", "Screen Timeout (Onroad)", "Customize how long it takes for your screen to turn off after going onroad.", ""}, + {"StandbyMode", "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.", ""}, }; for (const auto &[param, title, desc, icon] : visualToggles) { @@ -168,12 +176,27 @@ FrogPilotVisualsPanel::FrogPilotVisualsPanel(SettingsWindow *parent) : FrogPilot std::vector hideSpeedToggleNames{tr("Control Via UI")}; toggle = new FrogPilotParamToggleControl(param, title, desc, icon, hideSpeedToggles, hideSpeedToggleNames); - } else if (param == "ScreenBrightness") { + } else if (param == "ScreenManagement") { + FrogPilotParamManageControl *screenToggle = new FrogPilotParamManageControl(param, title, desc, icon, this); + QObject::connect(screenToggle, &FrogPilotParamManageControl::manageButtonClicked, this, [this]() { + parentToggleClicked(); + for (auto &[key, toggle] : toggles) { + toggle->setVisible(screenKeys.find(key.c_str()) != screenKeys.end()); + } + }); + toggle = screenToggle; + } else if (param == "HideUIElements") { + std::vector uiElementsToggles{"HideAlerts", "HideMapIcon", "HideMaxSpeed"}; + std::vector uiElementsToggleNames{tr("Alerts"), tr("Map Icon"), tr("Max Speed")}; + toggle = new FrogPilotParamToggleControl(param, title, desc, icon, uiElementsToggles, uiElementsToggleNames); + } else if (param == "ScreenBrightness" || param == "ScreenBrightnessOnroad") { std::map brightnessLabels; for (int i = 0; i <= 101; ++i) { brightnessLabels[i] = i == 0 ? "Screen Off" : i == 101 ? "Auto" : QString::number(i) + "%"; } toggle = new FrogPilotParamValueControl(param, title, desc, icon, 0, 101, brightnessLabels, this, false); + } else if (param == "ScreenTimeout" || param == "ScreenTimeoutOnroad") { + toggle = new FrogPilotParamValueControl(param, title, desc, icon, 5, 60, std::map(), this, false, " seconds"); } else { toggle = new ParamControl(param, title, desc, icon, this); @@ -289,7 +312,8 @@ void FrogPilotVisualsPanel::hideSubToggles() { customOnroadUIKeys.find(key.c_str()) != customOnroadUIKeys.end() || customThemeKeys.find(key.c_str()) != customThemeKeys.end() || modelUIKeys.find(key.c_str()) != modelUIKeys.end() || - qolKeys.find(key.c_str()) != qolKeys.end(); + qolKeys.find(key.c_str()) != qolKeys.end() || + screenKeys.find(key.c_str()) != screenKeys.end(); toggle->setVisible(!subToggles); } diff --git a/selfdrive/frogpilot/ui/visual_settings.h b/selfdrive/frogpilot/ui/visual_settings.h index 600c7e1..611a26b 100644 --- a/selfdrive/frogpilot/ui/visual_settings.h +++ b/selfdrive/frogpilot/ui/visual_settings.h @@ -32,8 +32,9 @@ private: std::set customAlertsKeys = {"GreenLightAlert", "LeadDepartingAlert", "LoudBlindspotAlert"}; std::set customOnroadUIKeys = {"AccelerationPath", "AdjacentPath", "BlindSpotPath", "FPSCounter", "LeadInfo", "PedalsOnUI", "RoadNameUI"}; std::set customThemeKeys = {"HolidayThemes", "CustomColors", "CustomIcons", "CustomSignals", "CustomSounds"}; - std::set modelUIKeys = {"DynamicPathWidth", "LaneLinesWidth", "PathEdgeWidth", "PathWidth", "RoadEdgesWidth", "UnlimitedLength"}; + std::set modelUIKeys = {"DynamicPathWidth", "HideLeadMarker", "LaneLinesWidth", "PathEdgeWidth", "PathWidth", "RoadEdgesWidth", "UnlimitedLength"}; std::set qolKeys = {"DriveStats", "FullMap", "HideSpeed"}; + std::set screenKeys = {"HideUIElements", "ScreenBrightness", "ScreenBrightnessOnroad", "ScreenRecorder", "ScreenTimeout", "ScreenTimeoutOnroad", "StandbyMode"}; std::map toggles; diff --git a/selfdrive/ui/qt/onroad.cc b/selfdrive/ui/qt/onroad.cc index 724d0f4..293da4c 100644 --- a/selfdrive/ui/qt/onroad.cc +++ b/selfdrive/ui/qt/onroad.cc @@ -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 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; diff --git a/selfdrive/ui/qt/window.cc b/selfdrive/ui/qt/window.cc index 74fd05e..ecc5780 100644 --- a/selfdrive/ui/qt/window.cc +++ b/selfdrive/ui/qt/window.cc @@ -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: diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index 675427c..453c982 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -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); diff --git a/selfdrive/ui/ui.h b/selfdrive/ui/ui.h index fc8a395..61426be 100644 --- a/selfdrive/ui/ui.h +++ b/selfdrive/ui/ui.h @@ -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); };