Numerical temperature gauge

Added toggle 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 and a function to swap between it by simply taping on the "Temp" gauge itself.
This commit is contained in:
FrogAi
2024-02-27 16:34:47 -07:00
parent a8387af5f0
commit 232c2bd713
6 changed files with 30 additions and 3 deletions

View File

@@ -99,9 +99,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())) {
@@ -120,6 +122,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;
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();
@@ -173,6 +182,10 @@ 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";
QColor theme_color = currentColors[0];
// FrogPilot metrics
@@ -234,12 +247,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));

View File

@@ -311,6 +311,7 @@ void ui_update_frogpilot_params(UIState *s) {
scene.disable_smoothing_mtsc = params.getBool("DisableMTSCSmoothing");
scene.driver_camera = params.getBool("DriverCamera");
scene.experimental_mode_via_screen = params.getBool("ExperimentalModeViaScreen") && params.getBool("ExperimentalModeActivation");
scene.fahrenheit = params.getBool("Fahrenheit");
scene.model_ui = params.getBool("ModelUI");
scene.dynamic_path_width = scene.model_ui && params.getBool("DynamicPathWidth");
@@ -320,6 +321,8 @@ void ui_update_frogpilot_params(UIState *s) {
scene.road_edge_width = params.getInt("RoadEdgesWidth") * (scene.is_metric ? 1.0f : INCH_TO_CM) / 200.0f;
scene.unlimited_road_ui_length = scene.model_ui && params.getBool("UnlimitedLength");
scene.numerical_temp = params.getBool("NumericalTemp");
bool quality_of_life_controls = params.getBool("QOLControls");
scene.reverse_cruise = quality_of_life_controls && params.getBool("ReverseCruise");
scene.reverse_cruise_ui = scene.reverse_cruise && params.getBool("ReverseCruiseUI");

View File

@@ -184,6 +184,7 @@ typedef struct UIScene {
bool enabled;
bool experimental_mode;
bool experimental_mode_via_screen;
bool fahrenheit;
bool fps_counter;
bool full_map;
bool hide_speed;
@@ -192,6 +193,7 @@ typedef struct UIScene {
bool lead_info;
bool map_open;
bool model_ui;
bool numerical_temp;
bool reverse_cruise;
bool reverse_cruise_ui;
bool show_driver_camera;