From 1a0da520fc90868bca3f8fca07437bfc4869be67 Mon Sep 17 00:00:00 2001 From: Jason Wen Date: Fri, 15 Sep 2023 23:15:17 -0400 Subject: [PATCH] Revert "ui: Handle frequency checks for live params and other elements (#278)" (#279) This reverts commit acf280e15babfc5654b0cfc093b7050dbd9205e5. --- selfdrive/ui/qt/sidebar.cc | 4 +++- selfdrive/ui/qt/sidebar.h | 1 + selfdrive/ui/ui.cc | 16 +++++----------- selfdrive/ui/ui.h | 1 + 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/selfdrive/ui/qt/sidebar.cc b/selfdrive/ui/qt/sidebar.cc index eca5247b0f..f17822c5c4 100644 --- a/selfdrive/ui/qt/sidebar.cc +++ b/selfdrive/ui/qt/sidebar.cc @@ -92,7 +92,9 @@ void Sidebar::updateState(const UIState &s) { } setProperty("connectStatus", QVariant::fromValue(connectStatus)); - if (sm.frame % (UI_FREQ / 20) == 0) { // Update every 1 Hz + if (millis_since_boot() - last_temp_count > 1000 * 1) { + last_temp_count = millis_since_boot(); + switch (s.scene.sidebar_temp_options) { case 0: sidebar_temp = QString::number((int)deviceState.getAmbientTempC()); diff --git a/selfdrive/ui/qt/sidebar.h b/selfdrive/ui/qt/sidebar.h index 4297602908..01ad00915c 100644 --- a/selfdrive/ui/qt/sidebar.h +++ b/selfdrive/ui/qt/sidebar.h @@ -61,6 +61,7 @@ protected: private: std::unique_ptr pm; + uint64_t last_temp_count; QString sidebar_temp = "0"; QString sidebar_temp_str = "0"; }; diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index 5884660b37..8d39e35db4 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -231,14 +231,15 @@ void ui_update_params(UIState *s) { auto params = Params(); s->scene.is_metric = params.getBool("IsMetric"); s->scene.map_on_left = params.getBool("NavSettingLeftSide"); - s->scene.dynamic_lane_profile_toggle = params.getBool("DynamicLaneProfileToggle"); + s->scene.dynamic_lane_profile = std::atoi(params.get("DynamicLaneProfile").c_str()); s->scene.visual_brake_lights = params.getBool("BrakeLights"); s->scene.onroadScreenOff = std::atoi(params.get("OnroadScreenOff").c_str()); s->scene.onroadScreenOffBrightness = std::atoi(params.get("OnroadScreenOffBrightness").c_str()); s->scene.onroadScreenOffEvent = params.getBool("OnroadScreenOffEvent"); s->scene.brightness = std::atoi(params.get("BrightnessControl").c_str()); s->scene.stand_still_timer = params.getBool("StandStillTimer"); + s->scene.speed_limit_control_enabled = params.getBool("SpeedLimitControl"); s->scene.speed_limit_perc_offset = params.getBool("SpeedLimitPercOffset"); s->scene.show_debug_ui = params.getBool("ShowDebugUI"); s->scene.debug_snapshot_enabled = params.getBool("EnableDebugSnapshot"); @@ -252,6 +253,7 @@ void ui_update_params(UIState *s) { s->scene.e2e_long_alert_light = params.getBool("EndToEndLongAlertLight"); s->scene.e2e_long_alert_lead = params.getBool("EndToEndLongAlertLead"); s->scene.e2e_long_alert_ui = params.getBool("EndToEndLongAlertUI"); + s->scene.longitudinal_personality = std::atoi(params.get("LongitudinalPersonality").c_str()); // Handle Onroad Screen Off params if (s->scene.onroadScreenOff > 0) { @@ -312,15 +314,6 @@ void UIState::updateStatus() { } if (scene.started) { - // Update live params when the camera view is on - { - if (sm->frame % (UI_FREQ / 10) == 0) { // Update every 2 Hz - scene.dynamic_lane_profile = std::atoi(params.get("DynamicLaneProfile").c_str()); - scene.longitudinal_personality = std::atoi(params.get("LongitudinalPersonality").c_str()); - scene.speed_limit_control_enabled = params.getBool("SpeedLimitControl"); - } - } - // Auto hide UI button state machine { if (scene.button_auto_hide) { @@ -373,7 +366,8 @@ void UIState::updateStatus() { } } - if (sm->frame % (UI_FREQ / 20) == 0) { // Update every 1 Hz + if (millis_since_boot() - last_update_params_sidebar > 1000 * 1) { + last_update_params_sidebar = millis_since_boot(); scene.sidebar_temp = params.getBool("SidebarTemperature"); scene.sidebar_temp_options = std::atoi(params.get("SidebarTemperatureOptions").c_str()); } diff --git a/selfdrive/ui/ui.h b/selfdrive/ui/ui.h index 086acdeb89..23ccc48b84 100644 --- a/selfdrive/ui/ui.h +++ b/selfdrive/ui/ui.h @@ -265,6 +265,7 @@ private: QTimer *timer; bool started_prev = false; PrimeType prime_type = PrimeType::UNKNOWN; + uint64_t last_update_params_sidebar; bool last_mads_enabled = false; bool mads_path_state = false;