mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-09-29 15:03:43 +08:00
ui: speedometer customization (#38)
* ui: speedometer customizations * change param name * bruh * cereal: fix duplicate ordinals
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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 @@ private:
|
||||
int curveSign = 0;
|
||||
int speedLimitStyle;
|
||||
|
||||
bool hideVEgoUi;
|
||||
|
||||
protected:
|
||||
void paintGL() override;
|
||||
void initializeGL() override;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user