From 6cbbfe4b9b2ce8b76c215b7f031f5474e743e364 Mon Sep 17 00:00:00 2001 From: FrogAi <91348155+FrogAi@users.noreply.github.com> Date: Tue, 26 Mar 2024 23:41:39 -0700 Subject: [PATCH] Hide current speed in onroad UI Added toggle to hide the current speed from the onroad UI and an additional function to enable/disable it by clicking on it via the onroad UI. --- common/params.cc | 2 ++ .../frogpilot/ui/qt/offroad/visual_settings.cc | 5 +++++ .../frogpilot/ui/qt/offroad/visual_settings.h | 2 +- selfdrive/ui/qt/onroad.cc | 15 +++++++++++++-- selfdrive/ui/ui.cc | 2 ++ selfdrive/ui/ui.h | 2 ++ 6 files changed, 25 insertions(+), 3 deletions(-) diff --git a/common/params.cc b/common/params.cc index 77ca6a1a4..743ac9844 100644 --- a/common/params.cc +++ b/common/params.cc @@ -282,6 +282,8 @@ std::unordered_map keys = { {"HideCEMStatusBar", PERSISTENT}, {"HideDisableOpenpilotLongitudinal", PERSISTENT}, {"HideLeadMarker", PERSISTENT}, + {"HideSpeed", PERSISTENT}, + {"HideSpeedUI", PERSISTENT}, {"IncreaseThermalLimits", PERSISTENT}, {"LaneLinesWidth", PERSISTENT}, {"LateralTune", PERSISTENT}, diff --git a/selfdrive/frogpilot/ui/qt/offroad/visual_settings.cc b/selfdrive/frogpilot/ui/qt/offroad/visual_settings.cc index db7dd5d4a..42da6d70c 100644 --- a/selfdrive/frogpilot/ui/qt/offroad/visual_settings.cc +++ b/selfdrive/frogpilot/ui/qt/offroad/visual_settings.cc @@ -42,6 +42,7 @@ FrogPilotVisualsPanel::FrogPilotVisualsPanel(SettingsWindow *parent) : FrogPilot {"BigMap", tr("Big Map"), tr("Increase the size of the map in the onroad UI."), ""}, {"CameraView", tr("Camera View"), tr("Choose your preferred camera view for the onroad UI. This is purely a visual change and doesn't impact how openpilot drives."), ""}, {"DriverCamera", tr("Driver Camera On Reverse"), tr("Show the driver camera feed when in reverse."), ""}, + {"HideSpeed", tr("Hide Speed"), tr("Hide the speed indicator in the onroad UI. Additional toggle allows it to be hidden/shown via tapping the speed itself."), ""}, }; for (const auto &[param, title, desc, icon] : visualToggles) { @@ -172,6 +173,10 @@ FrogPilotVisualsPanel::FrogPilotVisualsPanel(SettingsWindow *parent) : FrogPilot std::vector mapToggles{"FullMap"}; std::vector mapToggleNames{tr("Full Map")}; toggle = new FrogPilotParamToggleControl(param, title, desc, icon, mapToggles, mapToggleNames); + } else if (param == "HideSpeed") { + std::vector hideSpeedToggles{"HideSpeedUI"}; + std::vector hideSpeedToggleNames{tr("Control Via UI")}; + toggle = new FrogPilotParamToggleControl(param, title, desc, icon, hideSpeedToggles, hideSpeedToggleNames); } else { toggle = new ParamControl(param, title, desc, icon, this); diff --git a/selfdrive/frogpilot/ui/qt/offroad/visual_settings.h b/selfdrive/frogpilot/ui/qt/offroad/visual_settings.h index a251cb60b..94910695e 100644 --- a/selfdrive/frogpilot/ui/qt/offroad/visual_settings.h +++ b/selfdrive/frogpilot/ui/qt/offroad/visual_settings.h @@ -28,7 +28,7 @@ private: std::set customOnroadUIKeys = {"CustomPaths", "DeveloperUI", "FPSCounter", "LeadInfo"}; std::set customThemeKeys = {"CustomColors", "CustomIcons", "CustomSignals", "CustomSounds"}; std::set modelUIKeys = {"DynamicPathWidth", "HideLeadMarker", "LaneLinesWidth", "PathEdgeWidth", "PathWidth", "RoadEdgesWidth", "UnlimitedLength"}; - std::set qolKeys = {"BigMap", "CameraView", "DriverCamera", "FullMap"}; + std::set qolKeys = {"BigMap", "CameraView", "DriverCamera", "FullMap", "HideSpeed"}; std::set screenKeys = {}; std::map toggles; diff --git a/selfdrive/ui/qt/onroad.cc b/selfdrive/ui/qt/onroad.cc index 34ffa46f9..ad75688c0 100644 --- a/selfdrive/ui/qt/onroad.cc +++ b/selfdrive/ui/qt/onroad.cc @@ -103,8 +103,19 @@ void OnroadWindow::mousePressEvent(QMouseEvent* e) { // FrogPilot clickable widgets bool widgetClicked = false; + // Hide speed button + QRect hideSpeedRect(rect().center().x() - 175, 50, 350, 350); + bool isSpeedClicked = hideSpeedRect.contains(e->pos()) && scene.hide_speed_ui; + + if (isSpeedClicked) { + bool currentHideSpeed = scene.hide_speed; + + uiState()->scene.hide_speed = !currentHideSpeed; + params.putBoolNonBlocking("HideSpeed", !currentHideSpeed); + + widgetClicked = true; // If the click wasn't for anything specific, change the value of "ExperimentalMode" - if (scene.experimental_mode_via_screen && e->pos() != timeoutPoint) { + } else if (scene.experimental_mode_via_screen && e->pos() != timeoutPoint) { if (clickTimer.isActive()) { clickTimer.stop(); @@ -557,7 +568,7 @@ void AnnotatedCameraWidget::drawHud(QPainter &p) { } // current speed - if (!bigMapOpen) { + if (!(scene.hide_speed || bigMapOpen)) { p.setFont(InterFont(176, QFont::Bold)); drawText(p, rect().center().x(), 210, speedStr); p.setFont(InterFont(66)); diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index 867151412..7ba36f2d6 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -336,6 +336,8 @@ void ui_update_frogpilot_params(UIState *s) { scene.full_map = scene.big_map && params.getBool("FullMap"); scene.camera_view = quality_of_life_visuals ? params.getInt("CameraView") : 0; scene.driver_camera = quality_of_life_visuals && params.getBool("DriverCamera"); + scene.hide_speed = quality_of_life_visuals && params.getBool("HideSpeed"); + scene.hide_speed_ui = scene.hide_speed && params.getBool("HideSpeedUI"); } void UIState::updateStatus() { diff --git a/selfdrive/ui/ui.h b/selfdrive/ui/ui.h index 90f6e22fb..b76a67ea2 100644 --- a/selfdrive/ui/ui.h +++ b/selfdrive/ui/ui.h @@ -189,6 +189,8 @@ typedef struct UIScene { bool full_map; bool has_auto_tune; bool hide_lead_marker; + bool hide_speed; + bool hide_speed_ui; bool lead_info; bool live_valid; bool map_open;