From 53c76849563fcd2f11baee8a86fb982a024bdeea Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Mon, 6 Dec 2021 04:54:35 +0800 Subject: [PATCH] OnroadHud: update engageability and DM icons at 2Hz (#23134) old-commit-hash: 5ab6bff67016585edbbec134123c54db2e471599 --- selfdrive/ui/qt/onroad.cc | 8 ++++++-- selfdrive/ui/ui.cc | 6 ------ selfdrive/ui/ui.h | 2 -- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/selfdrive/ui/qt/onroad.cc b/selfdrive/ui/qt/onroad.cc index c5704007a0..41c0012a11 100644 --- a/selfdrive/ui/qt/onroad.cc +++ b/selfdrive/ui/qt/onroad.cc @@ -184,10 +184,14 @@ void OnroadHud::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("dmActive", sm["driverMonitoringState"].getDriverMonitoringState().getIsActiveMode()); setProperty("hideDM", cs.getAlertSize() != cereal::ControlsState::AlertSize::NONE); - setProperty("engageable", cs.getEngageable()); setProperty("status", s.status); + + // 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()); + } } void OnroadHud::paintEvent(QPaintEvent *event) { diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index 7a4de06586..f9a473bc83 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -110,12 +110,6 @@ static void update_state(UIState *s) { UIScene &scene = s->scene; s->running_time = 1e-9 * (nanos_since_boot() - sm["deviceState"].getDeviceState().getStartedMonoTime()); - // update engageability and DM icons at 2Hz - if (sm.frame % (UI_FREQ / 2) == 0) { - auto cs = sm["controlsState"].getControlsState(); - scene.engageable = cs.getEngageable() || cs.getEnabled(); - scene.dm_active = sm["driverMonitoringState"].getDriverMonitoringState().getIsActiveMode(); - } if (sm.updated("modelV2") && s->vg) { update_model(s, sm["modelV2"].getModelV2()); } diff --git a/selfdrive/ui/ui.h b/selfdrive/ui/ui.h index ef02a30f26..52ba882c2b 100644 --- a/selfdrive/ui/ui.h +++ b/selfdrive/ui/ui.h @@ -109,8 +109,6 @@ typedef struct UIScene { line_vertices_data lane_line_vertices[4]; line_vertices_data road_edge_vertices[2]; - bool dm_active, engageable; - // lead vertex_data lead_vertices[2];