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.
This commit is contained in:
FrogAi
2024-02-27 16:34:47 -07:00
parent f2cd6e256a
commit 7437d97c2e
6 changed files with 25 additions and 3 deletions

View File

@@ -273,6 +273,8 @@ std::unordered_map<std::string, uint32_t> keys = {
{"GasRegenCmd", PERSISTENT}, {"GasRegenCmd", PERSISTENT},
{"GoatScream", PERSISTENT}, {"GoatScream", PERSISTENT},
{"GreenLightAlert", PERSISTENT}, {"GreenLightAlert", PERSISTENT},
{"HideSpeed", PERSISTENT},
{"HideSpeedUI", PERSISTENT},
{"LaneLinesWidth", PERSISTENT}, {"LaneLinesWidth", PERSISTENT},
{"LateralTune", PERSISTENT}, {"LateralTune", PERSISTENT},
{"LeadInfo", PERSISTENT}, {"LeadInfo", PERSISTENT},

View File

@@ -42,6 +42,7 @@ FrogPilotVisualsPanel::FrogPilotVisualsPanel(SettingsWindow *parent) : FrogPilot
{"QOLVisuals", "Quality of Life", "Miscellaneous quality of life changes to improve your overall openpilot experience.", "../frogpilot/assets/toggle_icons/quality_of_life.png"}, {"QOLVisuals", "Quality of Life", "Miscellaneous quality of life changes to improve your overall openpilot experience.", "../frogpilot/assets/toggle_icons/quality_of_life.png"},
{"DriveStats", "Drive Stats In Home Screen", "Display your device's drive stats in the home screen.", ""}, {"DriveStats", "Drive Stats In Home Screen", "Display your device's drive stats in the home screen.", ""},
{"FullMap", "Full Sized Map", "Maximize the size of the map in the onroad UI.", ""}, {"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.", ""},
}; };
for (const auto &[param, title, desc, icon] : visualToggles) { for (const auto &[param, title, desc, icon] : visualToggles) {
@@ -147,6 +148,10 @@ FrogPilotVisualsPanel::FrogPilotVisualsPanel(SettingsWindow *parent) : FrogPilot
} }
}); });
toggle = qolToggle; toggle = qolToggle;
} else if (param == "HideSpeed") {
std::vector<QString> hideSpeedToggles{"HideSpeedUI"};
std::vector<QString> hideSpeedToggleNames{tr("Control Via UI")};
toggle = new FrogPilotParamToggleControl(param, title, desc, icon, hideSpeedToggles, hideSpeedToggleNames);
} else { } else {
toggle = new ParamControl(param, title, desc, icon, this); toggle = new ParamControl(param, title, desc, icon, this);

View File

@@ -33,7 +33,7 @@ private:
std::set<QString> customOnroadUIKeys = {"AccelerationPath", "AdjacentPath", "BlindSpotPath", "FPSCounter", "LeadInfo"}; std::set<QString> customOnroadUIKeys = {"AccelerationPath", "AdjacentPath", "BlindSpotPath", "FPSCounter", "LeadInfo"};
std::set<QString> customThemeKeys = {"CustomColors", "CustomIcons", "CustomSignals", "CustomSounds"}; std::set<QString> customThemeKeys = {"CustomColors", "CustomIcons", "CustomSignals", "CustomSounds"};
std::set<QString> modelUIKeys = {"DynamicPathWidth", "LaneLinesWidth", "PathEdgeWidth", "PathWidth", "RoadEdgesWidth", "UnlimitedLength"}; std::set<QString> modelUIKeys = {"DynamicPathWidth", "LaneLinesWidth", "PathEdgeWidth", "PathWidth", "RoadEdgesWidth", "UnlimitedLength"};
std::set<QString> qolKeys = {"DriveStats", "FullMap"}; std::set<QString> qolKeys = {"DriveStats", "FullMap", "HideSpeed"};
std::map<std::string, ParamControl*> toggles; std::map<std::string, ParamControl*> toggles;

View File

@@ -105,8 +105,19 @@ void OnroadWindow::mousePressEvent(QMouseEvent* e) {
// FrogPilot clickable widgets // FrogPilot clickable widgets
bool widgetClicked = false; bool widgetClicked = false;
// Hide speed button
QRect hideSpeedRect(rect().center().x() - 175, 50, 350, 350);
bool isSpeedClicked = hideSpeedRect.contains(e->pos());
if (isSpeedClicked && scene.hide_speed_ui) {
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 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()) { if (clickTimer.isActive()) {
clickTimer.stop(); clickTimer.stop();
@@ -533,7 +544,7 @@ void AnnotatedCameraWidget::drawHud(QPainter &p) {
} }
// current speed // current speed
if (!(fullMapOpen || showDriverCamera)) { if (!(scene.hide_speed || fullMapOpen || showDriverCamera)) {
p.setFont(InterFont(176, QFont::Bold)); p.setFont(InterFont(176, QFont::Bold));
drawText(p, rect().center().x(), 210, speedStr); drawText(p, rect().center().x(), 210, speedStr);
p.setFont(InterFont(66)); p.setFont(InterFont(66));

View File

@@ -321,6 +321,8 @@ void ui_update_frogpilot_params(UIState *s) {
bool quality_of_life_visuals = params.getBool("QOLVisuals"); bool quality_of_life_visuals = params.getBool("QOLVisuals");
scene.full_map = quality_of_life_visuals && params.getBool("FullMap"); scene.full_map = quality_of_life_visuals && params.getBool("FullMap");
scene.hide_speed = quality_of_life_visuals && params.getBool("HideSpeed");
scene.hide_speed_ui = scene.hide_speed && params.getBool("HideSpeedUI");
} }
void UIState::updateStatus() { void UIState::updateStatus() {

View File

@@ -185,6 +185,8 @@ typedef struct UIScene {
bool experimental_mode_via_screen; bool experimental_mode_via_screen;
bool fps_counter; bool fps_counter;
bool full_map; bool full_map;
bool hide_speed;
bool hide_speed_ui;
bool lead_info; bool lead_info;
bool map_open; bool map_open;
bool model_ui; bool model_ui;