dashboard: add temperature high alerts
This commit is contained in:
@@ -19,8 +19,10 @@ static lv_obj_t *battery_charge_pulse_arc = nullptr;
|
||||
static lv_obj_t *battery_current_label = nullptr;
|
||||
static lv_obj_t *battery_estimate_label = nullptr;
|
||||
static lv_obj_t *battery_soc_label = nullptr;
|
||||
static lv_obj_t *temp_tile_objs[2] = {nullptr};
|
||||
static lv_obj_t *temp_tile_value_labels[2] = {nullptr};
|
||||
static lv_obj_t *temp_tile_name_labels[2] = {nullptr};
|
||||
static bool last_temp_tile_alert[2] = {false, false};
|
||||
static lv_obj_t *system_status_label = nullptr;
|
||||
static lv_obj_t *wifi_icon_label = nullptr;
|
||||
static lv_obj_t *wifi_bars_obj[4] = {nullptr};
|
||||
@@ -597,6 +599,34 @@ static void update_system_status_label()
|
||||
|
||||
|
||||
|
||||
|
||||
static void update_temp_tile_alert_style(int index, bool alert)
|
||||
{
|
||||
if (index < 0 || index >= 2 || temp_tile_objs[index] == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (last_temp_tile_alert[index] == alert) {
|
||||
return;
|
||||
}
|
||||
|
||||
last_temp_tile_alert[index] = alert;
|
||||
|
||||
lvgl_port_lock(-1);
|
||||
|
||||
if (alert) {
|
||||
lv_obj_set_style_bg_color(temp_tile_objs[index], lv_color_hex(0x7A271A), 0);
|
||||
lv_obj_set_style_border_color(temp_tile_objs[index], lv_color_hex(0xF97066), 0);
|
||||
lv_obj_set_style_border_width(temp_tile_objs[index], 3, 0);
|
||||
} else {
|
||||
lv_obj_set_style_bg_color(temp_tile_objs[index], lv_color_hex(0x17202A), 0);
|
||||
lv_obj_set_style_border_color(temp_tile_objs[index], lv_color_hex(0x2F3A46), 0);
|
||||
lv_obj_set_style_border_width(temp_tile_objs[index], 2, 0);
|
||||
}
|
||||
|
||||
lvgl_port_unlock();
|
||||
}
|
||||
|
||||
static void update_overview_widgets()
|
||||
{
|
||||
String current_text = "Idle";
|
||||
@@ -687,6 +717,7 @@ static void parse_status_json(const String &body)
|
||||
String group;
|
||||
int priority;
|
||||
int rounded_f;
|
||||
bool high_alert;
|
||||
};
|
||||
|
||||
TempDisplayItem items[4];
|
||||
@@ -702,6 +733,7 @@ static void parse_status_json(const String &body)
|
||||
}
|
||||
|
||||
float temp_f = (float)(temp["temperature_f"] | 0.0);
|
||||
bool high_alert = temp["high_alert"] | false;
|
||||
|
||||
if (weather) {
|
||||
outside_status = "OUT ";
|
||||
@@ -716,7 +748,6 @@ static void parse_status_json(const String &body)
|
||||
String name = raw_name && raw_name[0] ? String(raw_name) : String("cabin");
|
||||
String group = normalize_temp_group(String(raw_group), name, false);
|
||||
|
||||
// Outside/weather is shown in the status strip, not the main temp card.
|
||||
if (group == "outside") {
|
||||
outside_status = "OUT ";
|
||||
outside_status += String((int)round(temp_f));
|
||||
@@ -728,7 +759,8 @@ static void parse_status_json(const String &body)
|
||||
items[item_count] = {
|
||||
group,
|
||||
temp["priority"] | 99,
|
||||
(int)round(temp_f)
|
||||
(int)round(temp_f),
|
||||
high_alert
|
||||
};
|
||||
item_count++;
|
||||
}
|
||||
@@ -749,13 +781,15 @@ static void parse_status_json(const String &body)
|
||||
|
||||
String group_names[2] = {"--", "--"};
|
||||
String group_values[2] = {"--", "--"};
|
||||
bool group_alerts[2] = {false, false};
|
||||
int group_count = 0;
|
||||
|
||||
for (int i = 0; i < item_count; i++) {
|
||||
int slot = -1;
|
||||
String display_group = display_temp_group_name(items[i].group);
|
||||
|
||||
for (int g = 0; g < group_count; g++) {
|
||||
if (group_names[g] == display_temp_group_name(items[i].group)) {
|
||||
if (group_names[g] == display_group) {
|
||||
slot = g;
|
||||
break;
|
||||
}
|
||||
@@ -767,7 +801,7 @@ static void parse_status_json(const String &body)
|
||||
}
|
||||
|
||||
slot = group_count;
|
||||
group_names[slot] = display_temp_group_name(items[i].group);
|
||||
group_names[slot] = display_group;
|
||||
group_values[slot] = "";
|
||||
group_count++;
|
||||
}
|
||||
@@ -780,6 +814,10 @@ static void parse_status_json(const String &body)
|
||||
}
|
||||
|
||||
group_values[slot] += value;
|
||||
|
||||
if (items[i].high_alert) {
|
||||
group_alerts[slot] = true;
|
||||
}
|
||||
}
|
||||
|
||||
update_outside_status_temp(outside_status);
|
||||
@@ -787,6 +825,7 @@ static void parse_status_json(const String &body)
|
||||
for (int i = 0; i < 2; i++) {
|
||||
set_label_text_if_changed(temp_tile_value_labels[i], last_temp_tile_value_text[i], group_values[i]);
|
||||
set_label_text_if_changed(temp_tile_name_labels[i], last_temp_tile_name_text[i], group_names[i]);
|
||||
update_temp_tile_alert_style(i, group_alerts[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1016,6 +1055,7 @@ static void create_overland_overview_screen()
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
lv_obj_t *tile = lv_obj_create(temp_card);
|
||||
temp_tile_objs[i] = tile;
|
||||
lv_obj_set_size(tile, temp_tile_w, temp_tile_h);
|
||||
lv_obj_align(tile, LV_ALIGN_TOP_MID, 0, temp_tile_y[i]);
|
||||
lv_obj_set_style_radius(tile, 18, 0);
|
||||
|
||||
Reference in New Issue
Block a user