diff --git a/selfdrive/ui/qt/sidebar.cc b/selfdrive/ui/qt/sidebar.cc index 2dcf975..48b9849 100644 --- a/selfdrive/ui/qt/sidebar.cc +++ b/selfdrive/ui/qt/sidebar.cc @@ -89,7 +89,21 @@ Sidebar::Sidebar(QWidget *parent) : QFrame(parent), onroad(false), flag_pressed( } void Sidebar::mousePressEvent(QMouseEvent *event) { - if (onroad && home_btn.contains(event->pos())) { + QRect tempRect = {30, 338, 240, 126}; + + static int showTemp = 0; + + if (tempRect.contains(event->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(); + } else if (onroad && home_btn.contains(event->pos())) { flag_pressed = true; update(); } else if (settings_btn.contains(event->pos())) { @@ -142,6 +156,11 @@ void Sidebar::updateState(const UIState &s) { auto frogpilotDeviceState = sm["frogpilotDeviceState"].getFrogpilotDeviceState(); + bool 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) { @@ -153,12 +172,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 6d65c63..202ddfd 100644 --- a/selfdrive/ui/qt/sidebar.h +++ b/selfdrive/ui/qt/sidebar.h @@ -64,6 +64,8 @@ private: Params params; UIScene &scene; + 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 c274f8d..2c1ae4a 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -343,6 +343,8 @@ void ui_update_frogpilot_params(UIState *s) { scene.show_steering = border_metrics && params.getBool("ShowSteering"); scene.fps_counter = developer_ui && params.getBool("FPSCounter"); scene.lead_info = scene.longitudinal_control && developer_ui && params.getBool("LongitudinalMetrics"); + scene.numerical_temp = developer_ui && params.getBool("NumericalTemp"); + scene.fahrenheit = scene.numerical_temp && params.getBool("Fahrenheit"); scene.show_jerk = scene.longitudinal_control && developer_ui && params.getBool("LongitudinalMetrics"); scene.show_tuning = developer_ui && scene.has_auto_tune && params.getBool("LateralMetrics"); diff --git a/selfdrive/ui/ui.h b/selfdrive/ui/ui.h index 0ee12c6..ebb2771 100644 --- a/selfdrive/ui/ui.h +++ b/selfdrive/ui/ui.h @@ -202,12 +202,14 @@ typedef struct UIScene { bool enabled; bool experimental_mode; bool experimental_mode_via_screen; + bool fahrenheit; bool fps_counter; bool has_auto_tune; bool holiday_themes; bool lead_info; bool live_valid; bool map_open; + bool numerical_temp; bool online; bool onroad_distance_button; bool parked;