From 7546fe114a51dc107f663e2e80b4f9004fc44536 Mon Sep 17 00:00:00 2001 From: FrogAi <91348155+FrogAi@users.noreply.github.com> Date: Fri, 12 Jan 2024 22:39:30 -0700 Subject: [PATCH] Numerical temperature gauge Added function to replace the "GOOD", "OK", and "HIGH" temperature statuses with a numerical temperature gauge based on the highest temperature between the memory, CPU, and GPU by simply taping on the "Temp" gauge itself. --- common/params.cc | 2 ++ selfdrive/ui/qt/sidebar.cc | 20 +++++++++++++++++--- selfdrive/ui/qt/sidebar.h | 2 ++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/common/params.cc b/common/params.cc index 157ffda..7c12037 100644 --- a/common/params.cc +++ b/common/params.cc @@ -251,6 +251,7 @@ std::unordered_map keys = { {"DisableOnroadUploads", PERSISTENT}, {"DriverCamera", PERSISTENT}, {"ExperimentalModeViaPress", PERSISTENT}, + {"Fahrenheit", PERSISTENT}, {"FireTheBabysitter", PERSISTENT}, {"FrogPilotTogglesUpdated", PERSISTENT}, {"GasRegenCmd", PERSISTENT}, @@ -285,6 +286,7 @@ std::unordered_map keys = { {"NNFFModelName", PERSISTENT}, {"NoLogging", PERSISTENT}, {"NudgelessLaneChange", PERSISTENT}, + {"NumericalTemp", PERSISTENT}, {"OfflineMode", PERSISTENT}, {"OneLaneChange", PERSISTENT}, {"PathEdgeWidth", PERSISTENT}, diff --git a/selfdrive/ui/qt/sidebar.cc b/selfdrive/ui/qt/sidebar.cc index 81d8944..f76af4b 100644 --- a/selfdrive/ui/qt/sidebar.cc +++ b/selfdrive/ui/qt/sidebar.cc @@ -48,6 +48,9 @@ Sidebar::Sidebar(QWidget *parent) : QFrame(parent), onroad(false), flag_pressed( isStorageLeft = params.getBool("ShowStorageLeft"); isStorageUsed = params.getBool("ShowStorageUsed"); + isNumericalTemp = params.getBool("NumericalTemp"); + isFahrenheit = params.getBool("Fahrenheit"); + themeConfiguration = { {0, {"stock", {QColor(255, 255, 255)}}}, {1, {"frog_theme", {QColor(23, 134, 68)}}}, @@ -72,9 +75,11 @@ void Sidebar::mousePressEvent(QMouseEvent *event) { // Declare the click boxes QRect cpuRect = {30, 496, 240, 126}; QRect memoryRect = {30, 654, 240, 126}; + QRect tempRect = {30, 338, 240, 126}; static int showChip = 0; static int showMemory = 0; + static int showTemp = 0; // Swap between the respective metrics upon tap if (cpuRect.contains(event->pos())) { @@ -93,6 +98,13 @@ void Sidebar::mousePressEvent(QMouseEvent *event) { params.putBoolNonBlocking("ShowStorageLeft", isStorageLeft); params.putBoolNonBlocking("ShowStorageUsed", isStorageUsed); update(); + } else if (tempRect.contains(event->pos())) { + showTemp = (showTemp + 1) % 3; + isNumericalTemp = (showTemp != 0); + isFahrenheit = (showTemp == 2); + params.putBoolNonBlocking("Fahrenheit", isFahrenheit); + params.putBoolNonBlocking("NumericalTemp", isNumericalTemp); + update(); } else if (onroad && home_btn.contains(event->pos())) { flag_pressed = true; update(); @@ -134,6 +146,8 @@ void Sidebar::updateState(const UIState &s) { // FrogPilot properties auto frogpilotDeviceState = sm["frogpilotDeviceState"].getFrogpilotDeviceState(); + int maxTempC = deviceState.getMaxTempC(); + QString max_temp = isFahrenheit ? QString::number(maxTempC * 9 / 5 + 32) + "°F" : QString::number(maxTempC) + "°C"; QColor theme_color = currentColors[0]; // FrogPilot metrics @@ -195,12 +209,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")}, theme_color}; + tempStatus = {{tr("TEMP"), isNumericalTemp ? max_temp : tr("GOOD")}, theme_color}; } 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 63f2312..c807b0f 100644 --- a/selfdrive/ui/qt/sidebar.h +++ b/selfdrive/ui/qt/sidebar.h @@ -81,8 +81,10 @@ private: bool isCPU; bool isCustomTheme; + bool isFahrenheit; bool isGPU; bool isMemoryUsage; + bool isNumericalTemp; bool isStorageLeft; bool isStorageUsed; int customColors;