diff --git a/selfdrive/ui/paint.h b/selfdrive/ui/paint.h index 55fe9c1d0835f1..4ce7cbd133e156 100644 --- a/selfdrive/ui/paint.h +++ b/selfdrive/ui/paint.h @@ -9,3 +9,4 @@ void ui_fill_rect(NVGcontext *vg, const Rect &r, const NVGpaint &paint, float ra void ui_fill_rect(NVGcontext *vg, const Rect &r, const NVGcolor &color, float radius = 0); void ui_nvg_init(UIState *s); void ui_resize(UIState *s, int width, int height); +void ui_update_params(UIState *s); diff --git a/selfdrive/ui/qt/onroad.cc b/selfdrive/ui/qt/onroad.cc index c3fbdcb6e64112..1eef3122e08629 100644 --- a/selfdrive/ui/qt/onroad.cc +++ b/selfdrive/ui/qt/onroad.cc @@ -186,3 +186,9 @@ void NvgWindow::paintGL() { } prev_draw_t = cur_draw_t; } + +void NvgWindow::showEvent(QShowEvent *event) { + CameraViewWidget::showEvent(event); + ui_update_params(&QUIState::ui_state); + prev_draw_t = millis_since_boot(); +} diff --git a/selfdrive/ui/qt/onroad.h b/selfdrive/ui/qt/onroad.h index 9be04e04ae473f..ee44973cf24c19 100644 --- a/selfdrive/ui/qt/onroad.h +++ b/selfdrive/ui/qt/onroad.h @@ -34,6 +34,7 @@ class NvgWindow : public CameraViewWidget { protected: void paintGL() override; void initializeGL() override; + void showEvent(QShowEvent *event) override; double prev_draw_t = 0; }; diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index 054e90e1768a82..016bf72d1d00c5 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -186,12 +186,8 @@ static void update_state(UIState *s) { scene.started = sm["deviceState"].getDeviceState().getStarted() && scene.ignition; } -static void update_params(UIState *s) { - const uint64_t frame = s->sm->frame; - UIScene &scene = s->scene; - if (frame % (5*UI_FREQ) == 0) { - scene.is_metric = Params().getBool("IsMetric"); - } +void ui_update_params(UIState *s) { + s->scene.is_metric = Params().getBool("IsMetric"); } static void update_status(UIState *s) { @@ -240,7 +236,6 @@ QUIState::QUIState(QObject *parent) : QObject(parent) { } void QUIState::update() { - update_params(&ui_state); update_sockets(&ui_state); update_state(&ui_state); update_status(&ui_state);