Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ui: update params on the show event #22927

Merged
merged 4 commits into from
Nov 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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