Skip to content

Commit 19df9c5

Browse files
committed
Simplify temp background opacity handling in LVGL UI
Set temp background objects to fully opaque by default in lvgl_main_screen.cpp, and remove redundant opacity changes in lvgl_updates.cpp. Visibility is now controlled solely by the HIDDEN flag, streamlining the logic for showing and hiding temperature backgrounds.
1 parent 7c907e2 commit 19df9c5

File tree

2 files changed

+2
-10
lines changed

2 files changed

+2
-10
lines changed

src/sp140/lvgl/lvgl_main_screen.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ lv_obj_t* createTempBackground(lv_obj_t* parent, int x, int y, int width, int he
7373
lv_obj_set_pos(bg, x, y);
7474
lv_obj_set_style_border_width(bg, 0, LV_PART_MAIN);
7575
lv_obj_set_style_radius(bg, 0, LV_PART_MAIN);
76-
lv_obj_set_style_bg_opa(bg, LV_OPA_0, LV_PART_MAIN);
76+
// Default to opaque background; visibility controlled by HIDDEN flag in updates
77+
lv_obj_set_style_bg_opa(bg, LV_OPA_100, LV_PART_MAIN);
7778
lv_obj_set_style_shadow_width(bg, 0, LV_PART_MAIN);
7879
lv_obj_set_style_outline_width(bg, 0, LV_PART_MAIN);
7980
lv_obj_set_style_pad_all(bg, 0, LV_PART_MAIN);

src/sp140/lvgl/lvgl_updates.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -656,14 +656,11 @@ void updateLvglMainScreen(
656656
if (batteryTemp >= bmsTempThresholds.critHigh) {
657657
lv_obj_add_style(batt_temp_bg, &style_critical, 0);
658658
lv_obj_clear_flag(batt_temp_bg, LV_OBJ_FLAG_HIDDEN);
659-
lv_obj_set_style_bg_opa(batt_temp_bg, LV_OPA_100, LV_PART_MAIN);
660659
} else if (batteryTemp >= bmsTempThresholds.warnHigh) {
661660
lv_obj_add_style(batt_temp_bg, &style_warning, 0);
662661
lv_obj_clear_flag(batt_temp_bg, LV_OBJ_FLAG_HIDDEN);
663-
lv_obj_set_style_bg_opa(batt_temp_bg, LV_OPA_100, LV_PART_MAIN);
664662
} else {
665663
lv_obj_add_flag(batt_temp_bg, LV_OBJ_FLAG_HIDDEN);
666-
lv_obj_set_style_bg_opa(batt_temp_bg, LV_OPA_0, LV_PART_MAIN);
667664
}
668665
} else {
669666
lv_label_set_text(batt_temp_label, "-");
@@ -682,14 +679,11 @@ void updateLvglMainScreen(
682679
if (escTemp >= escMosTempThresholds.critHigh) {
683680
lv_obj_add_style(esc_temp_bg, &style_critical, 0);
684681
lv_obj_clear_flag(esc_temp_bg, LV_OBJ_FLAG_HIDDEN);
685-
lv_obj_set_style_bg_opa(esc_temp_bg, LV_OPA_100, LV_PART_MAIN);
686682
} else if (escTemp >= escMosTempThresholds.warnHigh) {
687683
lv_obj_add_style(esc_temp_bg, &style_warning, 0);
688684
lv_obj_clear_flag(esc_temp_bg, LV_OBJ_FLAG_HIDDEN);
689-
lv_obj_set_style_bg_opa(esc_temp_bg, LV_OPA_100, LV_PART_MAIN);
690685
} else {
691686
lv_obj_add_flag(esc_temp_bg, LV_OBJ_FLAG_HIDDEN);
692-
lv_obj_set_style_bg_opa(esc_temp_bg, LV_OPA_0, LV_PART_MAIN);
693687
}
694688
} else {
695689
lv_label_set_text(esc_temp_label, "-");
@@ -708,14 +702,11 @@ void updateLvglMainScreen(
708702
if (motorTemp >= motorTempThresholds.critHigh) {
709703
lv_obj_add_style(motor_temp_bg, &style_critical, 0);
710704
lv_obj_clear_flag(motor_temp_bg, LV_OBJ_FLAG_HIDDEN);
711-
lv_obj_set_style_bg_opa(motor_temp_bg, LV_OPA_100, LV_PART_MAIN);
712705
} else if (motorTemp >= motorTempThresholds.warnHigh) {
713706
lv_obj_add_style(motor_temp_bg, &style_warning, 0);
714707
lv_obj_clear_flag(motor_temp_bg, LV_OBJ_FLAG_HIDDEN);
715-
lv_obj_set_style_bg_opa(motor_temp_bg, LV_OPA_100, LV_PART_MAIN);
716708
} else {
717709
lv_obj_add_flag(motor_temp_bg, LV_OBJ_FLAG_HIDDEN);
718-
lv_obj_set_style_bg_opa(motor_temp_bg, LV_OPA_0, LV_PART_MAIN);
719710
}
720711
} else {
721712
lv_label_set_text(motor_temp_label, "-");

0 commit comments

Comments
 (0)