Visuals - Developer UI - Numerical Temperature Gauge

Replace the 'GOOD', 'OK', and 'HIGH' temperature statuses with a numerical temperature gauge based on the highest temperature between the memory, CPU, and GPU.
This commit is contained in:
FrogAi 2024-05-11 14:26:47 -07:00
parent 72aa33447e
commit 43a884610a
4 changed files with 29 additions and 4 deletions

View File

@ -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));

View File

@ -64,6 +64,8 @@ private:
Params params;
UIScene &scene;
bool isNumericalTemp;
std::unordered_map<int, std::pair<QString, std::vector<QColor>>> themeConfiguration;
std::unordered_map<int, QPixmap> flag_imgs;
std::unordered_map<int, QPixmap> home_imgs;

View File

@ -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");

View File

@ -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;