ui: Handle frequency checks for live params and other elements (#278)

This commit is contained in:
Jason Wen
2023-09-15 22:55:59 -04:00
committed by GitHub
parent 22a5951aa7
commit acf280e15b
4 changed files with 12 additions and 10 deletions
+1 -3
View File
@@ -92,9 +92,7 @@ void Sidebar::updateState(const UIState &s) {
}
setProperty("connectStatus", QVariant::fromValue(connectStatus));
if (millis_since_boot() - last_temp_count > 1000 * 1) {
last_temp_count = millis_since_boot();
if (sm.frame % (UI_FREQ / 20) == 0) { // Update every 1 Hz
switch (s.scene.sidebar_temp_options) {
case 0:
sidebar_temp = QString::number((int)deviceState.getAmbientTempC());
-1
View File
@@ -61,7 +61,6 @@ protected:
private:
std::unique_ptr<PubMaster> pm;
uint64_t last_temp_count;
QString sidebar_temp = "0";
QString sidebar_temp_str = "0";
};
+11 -5
View File
@@ -231,15 +231,14 @@ 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");
@@ -253,7 +252,6 @@ 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) {
@@ -314,6 +312,15 @@ 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) {
@@ -366,8 +373,7 @@ void UIState::updateStatus() {
}
}
if (millis_since_boot() - last_update_params_sidebar > 1000 * 1) {
last_update_params_sidebar = millis_since_boot();
if (sm->frame % (UI_FREQ / 20) == 0) { // Update every 1 Hz
scene.sidebar_temp = params.getBool("SidebarTemperature");
scene.sidebar_temp_options = std::atoi(params.get("SidebarTemperatureOptions").c_str());
}
-1
View File
@@ -265,7 +265,6 @@ 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;