Skip to content

Commit

Permalink
Visuals - Developer UI - Numerical Temperature Gauge
Browse files Browse the repository at this point in the history
Replace the 'GOOD', 'OK', and 'HIGH' temperature statuses with a numerical temperature gauge based on the highest temperature between the memory, CPU, and GPU.
  • Loading branch information
FrogAi committed Aug 6, 2024
1 parent 21a6bb6 commit b47cab1
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 5 deletions.
37 changes: 32 additions & 5 deletions selfdrive/ui/qt/sidebar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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) {
Expand All @@ -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));

Expand Down
2 changes: 2 additions & 0 deletions selfdrive/ui/qt/sidebar.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ public slots:
// FrogPilot variables
Params params;

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;
Expand Down
2 changes: 2 additions & 0 deletions selfdrive/ui/ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,8 @@ void ui_update_frogpilot_params(UIState *s, Params &params) {
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");
Expand Down
2 changes: 2 additions & 0 deletions selfdrive/ui/ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,15 @@ 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;
bool lead_info;
bool live_valid;
bool map_open;
bool model_randomizer;
bool numerical_temp;
bool online;
bool onroad_distance_button;
bool parked;
Expand Down

0 comments on commit b47cab1

Please sign in to comment.