diff --git a/selfdrive/ui/qt/sidebar.cc b/selfdrive/ui/qt/sidebar.cc index 4a631534..dcea9617 100644 --- a/selfdrive/ui/qt/sidebar.cc +++ b/selfdrive/ui/qt/sidebar.cc @@ -92,12 +92,34 @@ Sidebar::Sidebar(QWidget *parent) : QFrame(parent), onroad(false), flag_pressed( } void Sidebar::mousePressEvent(QMouseEvent *event) { - if (onroad && home_btn.contains(event->pos())) { + UIState *s = uiState(); + UIScene &scene = s->scene; + + QPoint pos = event->pos(); + + QRect tempRect = {30, 338, 240, 126}; + + static int showTemp = 0; + + if (tempRect.contains(pos)) { + showTemp = (showTemp + 1) % 3; + + scene.fahrenheit = showTemp == 2; + scene.numerical_temp = showTemp != 0; + + params.putBoolNonBlocking("Fahrenheit", showTemp == 2); + params.putBoolNonBlocking("NumericalTemp", showTemp != 0); + + update(); + return; + } else if (onroad && home_btn.contains(pos)) { flag_pressed = true; update(); - } else if (settings_btn.contains(event->pos())) { + return; + } else if (settings_btn.contains(pos)) { settings_pressed = true; update(); + return; } } @@ -147,6 +169,11 @@ void Sidebar::updateState(const UIState &s) { auto frogpilotDeviceState = sm["frogpilotDeviceState"].getFrogpilotDeviceState(); + isNumericalTemp = scene.numerical_temp; + + int maxTempC = deviceState.getMaxTempC(); + QString max_temp = scene.fahrenheit ? QString::number(maxTempC * 9 / 5 + 32) + "°F" : QString::number(maxTempC) + "°C"; + ItemStatus connectStatus; auto last_ping = deviceState.getLastAthenaPingTime(); if (last_ping == 0) { @@ -158,12 +185,12 @@ void Sidebar::updateState(const UIState &s) { } setProperty("connectStatus", QVariant::fromValue(connectStatus)); - ItemStatus tempStatus = {{tr("TEMP"), tr("HIGH")}, danger_color}; + ItemStatus tempStatus = {{tr("TEMP"), isNumericalTemp ? max_temp : tr("HIGH")}, danger_color}; auto ts = deviceState.getThermalStatus(); if (ts == cereal::DeviceState::ThermalStatus::GREEN) { - tempStatus = {{tr("TEMP"), tr("GOOD")}, currentColors[0]}; + tempStatus = {{tr("TEMP"), isNumericalTemp ? max_temp : tr("GOOD")}, currentColors[0]}; } else if (ts == cereal::DeviceState::ThermalStatus::YELLOW) { - tempStatus = {{tr("TEMP"), tr("OK")}, warning_color}; + tempStatus = {{tr("TEMP"), isNumericalTemp ? max_temp : tr("OK")}, warning_color}; } setProperty("tempStatus", QVariant::fromValue(tempStatus)); diff --git a/selfdrive/ui/qt/sidebar.h b/selfdrive/ui/qt/sidebar.h index 73d7c71d..a63c3ac8 100644 --- a/selfdrive/ui/qt/sidebar.h +++ b/selfdrive/ui/qt/sidebar.h @@ -63,6 +63,8 @@ private: // FrogPilot variables Params params; + bool isNumericalTemp; + std::unordered_map>> themeConfiguration; std::unordered_map flag_imgs; std::unordered_map home_imgs; diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index 9a95be28..6235c808 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -362,6 +362,8 @@ void ui_update_frogpilot_params(UIState *s, Params ¶ms) { bool show_longitudinal = scene.longitudinal_control && developer_ui && params.getBool("LongitudinalMetrics"); scene.lead_info = show_longitudinal && params.getBool("LeadInfo"); scene.show_jerk = show_longitudinal && params.getBool("JerkInfo"); + scene.numerical_temp = developer_ui && params.getBool("NumericalTemp"); + scene.fahrenheit = scene.numerical_temp && params.getBool("Fahrenheit"); scene.disable_smoothing_mtsc = params.getBool("MTSCEnabled") && params.getBool("DisableMTSCSmoothing"); scene.disable_smoothing_vtsc = params.getBool("VisionTurnControl") && params.getBool("DisableVTSCSmoothing"); diff --git a/selfdrive/ui/ui.h b/selfdrive/ui/ui.h index f5fc3d59..9c4983e5 100644 --- a/selfdrive/ui/ui.h +++ b/selfdrive/ui/ui.h @@ -138,6 +138,7 @@ typedef struct UIScene { bool enabled; bool experimental_mode; bool experimental_mode_via_screen; + bool fahrenheit; bool has_auto_tune; bool has_lead; bool holiday_themes; @@ -145,6 +146,7 @@ typedef struct UIScene { bool live_valid; bool map_open; bool model_randomizer; + bool numerical_temp; bool online; bool onroad_distance_button; bool parked;