Skip to content

Commit

Permalink
UI: DM Icon shows engaged IF always-on
Browse files Browse the repository at this point in the history
  • Loading branch information
ugtthis committed Aug 5, 2024
1 parent 54cd2a6 commit 65965cf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 13 additions & 3 deletions selfdrive/ui/qt/onroad/annotated_camera.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <algorithm>
#include <cmath>

#include "common/params.h"
#include "common/swaglog.h"
#include "selfdrive/ui/qt/onroad/buttons.h"
#include "selfdrive/ui/qt/util.h"
Expand All @@ -23,6 +24,12 @@ AnnotatedCameraWidget::AnnotatedCameraWidget(VisionStreamType type, QWidget* par
dm_img = loadPixmap("../assets/img_driver_face.png", {img_size + 5, img_size + 5});
}

// Checks if "Always-On Driver Monitoring" toggle is enabled in settings
bool AnnotatedCameraWidget::isDMAlwaysOn() const {
Params params;
return params.getBool("AlwaysOnDM");
}

void AnnotatedCameraWidget::updateState(const UIState &s) {
const int SET_SPEED_NA = 255;
const SubMaster &sm = *(s.sm);
Expand Down Expand Up @@ -236,9 +243,12 @@ void AnnotatedCameraWidget::drawDriverState(QPainter &painter, const UIState *s)
const int arc_l = 133;
const float arc_t_default = 6.7;
const float arc_t_extend = 12.0;
QColor arc_color = QColor::fromRgbF(0.545 - 0.445 * s->engaged(),
0.545 + 0.4 * s->engaged(),
0.545 - 0.285 * s->engaged(),

bool show_dm_engaged = s->engaged() || isDMAlwaysOn();

QColor arc_color = QColor::fromRgbF(0.545 - 0.445 * show_dm_engaged,
0.545 + 0.4 * show_dm_engaged,
0.545 - 0.285 * show_dm_engaged,
0.4 * (1.0 - dm_fade_state));
float delta_x = -scene.driver_pose_sins[1] * arc_l / 2;
float delta_y = -scene.driver_pose_sins[0] * arc_l / 2;
Expand Down
2 changes: 2 additions & 0 deletions selfdrive/ui/qt/onroad/annotated_camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class AnnotatedCameraWidget : public CameraWidget {
int skip_frame_count = 0;
bool wide_cam_requested = false;

bool isDMAlwaysOn() const;

protected:
void paintGL() override;
void initializeGL() override;
Expand Down

0 comments on commit 65965cf

Please sign in to comment.