diff --git a/selfdrive/ui/qt/onroad.cc b/selfdrive/ui/qt/onroad.cc index e549f62a23..ce61c094bd 100644 --- a/selfdrive/ui/qt/onroad.cc +++ b/selfdrive/ui/qt/onroad.cc @@ -166,6 +166,7 @@ void OnroadAlerts::paintEvent(QPaintEvent *event) { NvgWindow::NvgWindow(VisionStreamType type, QWidget* parent) : fps_filter(UI_FREQ, 3, 1. / UI_FREQ), CameraViewWidget("camerad", type, true, parent) { engage_img = loadPixmap("../assets/img_chffr_wheel.png", {img_size, img_size}); + dm_img = loadPixmap("../assets/img_driver_face.png", {img_size, img_size}); } void NvgWindow::updateState(const UIState &s) { @@ -185,11 +186,13 @@ void NvgWindow::updateState(const UIState &s) { setProperty("speed", QString::number(std::nearbyint(cur_speed))); setProperty("maxSpeed", maxspeed_str); setProperty("speedUnit", s.scene.is_metric ? "km/h" : "mph"); + setProperty("hideDM", cs.getAlertSize() != cereal::ControlsState::AlertSize::NONE); setProperty("status", s.status); - // update engageability at 2Hz + // update engageability and DM icons at 2Hz if (sm.frame % (UI_FREQ / 2) == 0) { setProperty("engageable", cs.getEngageable() || cs.getEnabled()); + setProperty("dmActive", sm["driverMonitoringState"].getDriverMonitoringState().getIsActiveMode()); } } @@ -231,6 +234,11 @@ void NvgWindow::drawHud(QPainter &p) { engage_img, bg_colors[status], 1.0); } + // dm icon + if (!hideDM) { + drawIcon(p, radius / 2 + (bdr_s * 2), rect().bottom() - footer_h / 2, + dm_img, QColor(0, 0, 0, 70), dmActive ? 1.0 : 0.2); + } p.restore(); } diff --git a/selfdrive/ui/qt/onroad.h b/selfdrive/ui/qt/onroad.h index e1f665149e..6ca2b3c738 100644 --- a/selfdrive/ui/qt/onroad.h +++ b/selfdrive/ui/qt/onroad.h @@ -32,6 +32,8 @@ class NvgWindow : public CameraViewWidget { Q_PROPERTY(QString maxSpeed MEMBER maxSpeed); Q_PROPERTY(bool is_cruise_set MEMBER is_cruise_set); Q_PROPERTY(bool engageable MEMBER engageable); + Q_PROPERTY(bool dmActive MEMBER dmActive); + Q_PROPERTY(bool hideDM MEMBER hideDM); Q_PROPERTY(int status MEMBER status); public: @@ -43,6 +45,7 @@ private: void drawText(QPainter &p, int x, int y, const QString &text, int alpha = 255); QPixmap engage_img; + QPixmap dm_img; const int radius = 192; const int img_size = (radius / 2) * 1.5; QString speed; @@ -50,6 +53,8 @@ private: QString maxSpeed; bool is_cruise_set = false; bool engageable = false; + bool dmActive = false; + bool hideDM = false; int status = STATUS_DISENGAGED; protected: diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index f7c2c90437..c1af4ed6f4 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -231,7 +231,7 @@ void UIState::updateStatus() { UIState::UIState(QObject *parent) : QObject(parent) { sm = std::make_unique>({ "modelV2", "controlsState", "liveCalibration", "radarState", "deviceState", "roadCameraState", - "pandaStates", "carParams", "sensorEvents", "carState", "liveLocationKalman", + "pandaStates", "carParams", "driverMonitoringState", "sensorEvents", "carState", "liveLocationKalman", "wideRoadCameraState", "managerState", "navInstruction", "navRoute", });