From c97b3b56a9bea845ed52f86f629bf48925737f76 Mon Sep 17 00:00:00 2001 From: Jason Wen <47793918+sunnyhaibin@users.noreply.github.com> Date: Sun, 19 Feb 2023 12:24:18 -0500 Subject: [PATCH] ui: speedometer customization (#38) * ui: speedometer customizations * change param name * bruh * cereal: fix duplicate ordinals --- selfdrive/ui/qt/offroad/sunnypilot_settings.cc | 18 ++++++++++++++++++ selfdrive/ui/qt/onroad.cc | 14 +++++++++----- selfdrive/ui/qt/onroad.h | 4 ++++ selfdrive/ui/ui.cc | 2 ++ selfdrive/ui/ui.h | 2 ++ 5 files changed, 35 insertions(+), 5 deletions(-) diff --git a/selfdrive/ui/qt/offroad/sunnypilot_settings.cc b/selfdrive/ui/qt/offroad/sunnypilot_settings.cc index f1c95fa4f2258d..f983ec8e23a8ee 100644 --- a/selfdrive/ui/qt/offroad/sunnypilot_settings.cc +++ b/selfdrive/ui/qt/offroad/sunnypilot_settings.cc @@ -646,6 +646,24 @@ SPVisualsPanel::SPVisualsPanel(QWidget *parent) : QWidget(parent) { main_layout->addWidget(horizontal_line()); main_layout->addWidget(customMapbox); main_layout->addWidget(mapboxMain); + + // Visuals: Speedometer: Display True Speed + main_layout->addWidget(horizontal_line()); + main_layout->addWidget(new ParamControl( + "TrueVEgoUi", + tr("Speedometer: Display True Speed"), + tr("Display the true vehicle current speed from wheel speed sensors."), + "../assets/offroad/icon_openpilot.png" + )); + + // Visuals: Speedometer: Hide from Onroad Screen + main_layout->addWidget(horizontal_line()); + main_layout->addWidget(new ParamControl( + "HideVEgoUi", + tr("Speedometer: Hide from Onroad Screen"), + "", + "../assets/offroad/icon_openpilot.png" + )); } void SPVisualsPanel::showEvent(QShowEvent *event) { diff --git a/selfdrive/ui/qt/onroad.cc b/selfdrive/ui/qt/onroad.cc index bb93208a919db0..d40d9baeb94b07 100644 --- a/selfdrive/ui/qt/onroad.cc +++ b/selfdrive/ui/qt/onroad.cc @@ -378,7 +378,7 @@ void AnnotatedCameraWidget::updateState(const UIState &s) { // Handle older routes where vEgoCluster is not set float v_ego; - if (sm["carState"].getCarState().getVEgoCluster() == 0.0 && !v_ego_cluster_seen) { + if ((sm["carState"].getCarState().getVEgoCluster() == 0.0 && !v_ego_cluster_seen) || s.scene.true_vego_ui) { v_ego = sm["carState"].getCarState().getVEgo(); } else { v_ego = sm["carState"].getCarState().getVEgoCluster(); @@ -420,6 +420,8 @@ void AnnotatedCameraWidget::updateState(const UIState &s) { setProperty("standStill", car_state.getStandstill()); setProperty("standstillElapsedTime", sm["lateralPlan"].getLateralPlan().getStandstillElapsed()); + setProperty("hideVEgoUi", s.scene.hide_vego_ui); + // update engageability/experimental mode button experimental_btn->updateState(s); @@ -667,10 +669,12 @@ void AnnotatedCameraWidget::drawHud(QPainter &p) { } // current speed - configFont(p, "Inter", 176, "Bold"); - drawColoredText(p, rect().center().x(), 210, speedStr, brakeLights ? QColor(0xff, 0, 0, 255) : QColor(0xff, 0xff, 0xff, 255)); - configFont(p, "Inter", 66, "Regular"); - drawText(p, rect().center().x(), 290, speedUnit, 200); + if (!hideVEgoUi) { + configFont(p, "Inter", 176, "Bold"); + drawColoredText(p, rect().center().x(), 210, speedStr, brakeLights ? QColor(0xff, 0, 0, 255) : QColor(0xff, 0xff, 0xff, 255)); + configFont(p, "Inter", 66, "Regular"); + drawText(p, rect().center().x(), 290, speedUnit, 200); + } // Dynamic Lane Profile Button if (dynamicLaneProfileToggle) { diff --git a/selfdrive/ui/qt/onroad.h b/selfdrive/ui/qt/onroad.h index 11a01adf303693..855f319b74f447 100644 --- a/selfdrive/ui/qt/onroad.h +++ b/selfdrive/ui/qt/onroad.h @@ -104,6 +104,8 @@ class AnnotatedCameraWidget : public CameraWidget { Q_PROPERTY(bool tscActive MEMBER tscActive); Q_PROPERTY(int curveSign MEMBER curveSign); + Q_PROPERTY(bool hideVEgoUi MEMBER hideVEgoUi); + public: explicit AnnotatedCameraWidget(VisionStreamType type, QWidget* parent = 0); void updateState(const UIState &s); @@ -188,6 +190,8 @@ class AnnotatedCameraWidget : public CameraWidget { int curveSign = 0; int speedLimitStyle; + bool hideVEgoUi; + protected: void paintGL() override; void initializeGL() override; diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index 27652827ade7c7..0fcba55b9ccddf 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -233,6 +233,8 @@ void ui_update_params(UIState *s) { s->scene.show_debug_ui = params.getBool("ShowDebugUI"); s->scene.debug_snapshot_enabled = params.getBool("EnableDebugSnapshot"); s->scene.speed_limit_style = std::atoi(params.get("SpeedLimitStyle").c_str()); + s->scene.hide_vego_ui = params.getBool("HideVEgoUi"); + s->scene.true_vego_ui = params.getBool("TrueVEgoUi"); if (s->scene.onroadScreenOff > 0) { s->scene.osoTimer = s->scene.onroadScreenOff * 60 * UI_FREQ; diff --git a/selfdrive/ui/ui.h b/selfdrive/ui/ui.h index 667a511c634ba6..b24c8a54c8fccf 100644 --- a/selfdrive/ui/ui.h +++ b/selfdrive/ui/ui.h @@ -162,6 +162,8 @@ typedef struct UIScene { bool touched2 = false; bool stand_still_timer; + + bool hide_vego_ui, true_vego_ui; } UIScene; class UIState : public QObject {