Skip to content

Commit 86ce2f8

Browse files
committed
Revert "UI: remove DM icon (#24771)"
This reverts commit 4d836c6.
1 parent 1fe5826 commit 86ce2f8

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

selfdrive/ui/qt/onroad.cc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ void OnroadAlerts::paintEvent(QPaintEvent *event) {
166166

167167
NvgWindow::NvgWindow(VisionStreamType type, QWidget* parent) : fps_filter(UI_FREQ, 3, 1. / UI_FREQ), CameraViewWidget("camerad", type, true, parent) {
168168
engage_img = loadPixmap("../assets/img_chffr_wheel.png", {img_size, img_size});
169+
dm_img = loadPixmap("../assets/img_driver_face.png", {img_size, img_size});
169170
}
170171

171172
void NvgWindow::updateState(const UIState &s) {
@@ -185,11 +186,13 @@ void NvgWindow::updateState(const UIState &s) {
185186
setProperty("speed", QString::number(std::nearbyint(cur_speed)));
186187
setProperty("maxSpeed", maxspeed_str);
187188
setProperty("speedUnit", s.scene.is_metric ? "km/h" : "mph");
189+
setProperty("hideDM", cs.getAlertSize() != cereal::ControlsState::AlertSize::NONE);
188190
setProperty("status", s.status);
189191

190-
// update engageability at 2Hz
192+
// update engageability and DM icons at 2Hz
191193
if (sm.frame % (UI_FREQ / 2) == 0) {
192194
setProperty("engageable", cs.getEngageable() || cs.getEnabled());
195+
setProperty("dmActive", sm["driverMonitoringState"].getDriverMonitoringState().getIsActiveMode());
193196
}
194197
}
195198

@@ -231,6 +234,11 @@ void NvgWindow::drawHud(QPainter &p) {
231234
engage_img, bg_colors[status], 1.0);
232235
}
233236

237+
// dm icon
238+
if (!hideDM) {
239+
drawIcon(p, radius / 2 + (bdr_s * 2), rect().bottom() - footer_h / 2,
240+
dm_img, QColor(0, 0, 0, 70), dmActive ? 1.0 : 0.2);
241+
}
234242
p.restore();
235243
}
236244

selfdrive/ui/qt/onroad.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ class NvgWindow : public CameraViewWidget {
3232
Q_PROPERTY(QString maxSpeed MEMBER maxSpeed);
3333
Q_PROPERTY(bool is_cruise_set MEMBER is_cruise_set);
3434
Q_PROPERTY(bool engageable MEMBER engageable);
35+
Q_PROPERTY(bool dmActive MEMBER dmActive);
36+
Q_PROPERTY(bool hideDM MEMBER hideDM);
3537
Q_PROPERTY(int status MEMBER status);
3638

3739
public:
@@ -43,13 +45,16 @@ class NvgWindow : public CameraViewWidget {
4345
void drawText(QPainter &p, int x, int y, const QString &text, int alpha = 255);
4446

4547
QPixmap engage_img;
48+
QPixmap dm_img;
4649
const int radius = 192;
4750
const int img_size = (radius / 2) * 1.5;
4851
QString speed;
4952
QString speedUnit;
5053
QString maxSpeed;
5154
bool is_cruise_set = false;
5255
bool engageable = false;
56+
bool dmActive = false;
57+
bool hideDM = false;
5358
int status = STATUS_DISENGAGED;
5459

5560
protected:

selfdrive/ui/ui.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ void UIState::updateStatus() {
231231
UIState::UIState(QObject *parent) : QObject(parent) {
232232
sm = std::make_unique<SubMaster, const std::initializer_list<const char *>>({
233233
"modelV2", "controlsState", "liveCalibration", "radarState", "deviceState", "roadCameraState",
234-
"pandaStates", "carParams", "sensorEvents", "carState", "liveLocationKalman",
234+
"pandaStates", "carParams", "driverMonitoringState", "sensorEvents", "carState", "liveLocationKalman",
235235
"wideRoadCameraState", "managerState", "navInstruction", "navRoute",
236236
});
237237

0 commit comments

Comments
 (0)