Skip to content

Commit

Permalink
ui: speedometer customization (commaai#38)
Browse files Browse the repository at this point in the history
* ui: speedometer customizations

* change param name

* bruh

* cereal: fix duplicate ordinals
  • Loading branch information
sunnyhaibin authored Feb 19, 2023
1 parent 9ccc152 commit c97b3b5
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 5 deletions.
18 changes: 18 additions & 0 deletions selfdrive/ui/qt/offroad/sunnypilot_settings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
14 changes: 9 additions & 5 deletions selfdrive/ui/qt/onroad.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 4 additions & 0 deletions selfdrive/ui/qt/onroad.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -188,6 +190,8 @@ class AnnotatedCameraWidget : public CameraWidget {
int curveSign = 0;
int speedLimitStyle;

bool hideVEgoUi;

protected:
void paintGL() override;
void initializeGL() override;
Expand Down
2 changes: 2 additions & 0 deletions selfdrive/ui/ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions selfdrive/ui/ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit c97b3b5

Please sign in to comment.