Skip to content

Commit

Permalink
ui: update params on the show event (#22927)
Browse files Browse the repository at this point in the history
  • Loading branch information
deanlee authored Nov 16, 2021
1 parent 9f423a9 commit 9062085
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions selfdrive/ui/paint.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
6 changes: 6 additions & 0 deletions selfdrive/ui/qt/onroad.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
1 change: 1 addition & 0 deletions selfdrive/ui/qt/onroad.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down
9 changes: 2 additions & 7 deletions selfdrive/ui/ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 9062085

Please sign in to comment.