Skip to content

Commit b2d0e04

Browse files
authored
BatteryInfo App Redesign: Fixup (#2310)
* remove leading zeros from battery percentage * add correct colors matching the battery icon color thresholds
1 parent 4f426f0 commit b2d0e04

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

src/displayapp/screens/BatteryInfo.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ BatteryInfo::BatteryInfo(const Pinetime::Controllers::Battery& batteryController
3030

3131
percent = lv_label_create(lv_scr_act(), nullptr);
3232
lv_obj_set_style_local_text_font(percent, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42);
33-
lv_label_set_text_fmt(percent, "%02i%%", batteryPercent);
33+
lv_label_set_text_fmt(percent, "%i%%", batteryPercent);
3434
lv_label_set_align(percent, LV_LABEL_ALIGN_LEFT);
3535
lv_obj_align(percent, chargingArc, LV_ALIGN_CENTER, 0, 0);
3636

@@ -60,15 +60,18 @@ void BatteryInfo::Refresh() {
6060
} else if (batteryPercent == 100) {
6161
lv_obj_set_style_local_line_color(chargingArc, LV_ARC_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_BLUE);
6262
lv_label_set_text_static(status, "Fully charged");
63-
} else if (batteryPercent < 10) {
64-
lv_obj_set_style_local_line_color(chargingArc, LV_ARC_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_RED);
65-
lv_label_set_text_static(status, "Battery low");
66-
} else {
63+
} else if (batteryPercent > 15) {
6764
lv_obj_set_style_local_line_color(chargingArc, LV_ARC_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_GREEN);
6865
lv_label_set_text_static(status, "Discharging");
66+
} else if (batteryPercent > 5) {
67+
lv_obj_set_style_local_line_color(chargingArc, LV_ARC_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_ORANGE);
68+
lv_label_set_text_static(status, "Battery low");
69+
} else {
70+
lv_obj_set_style_local_line_color(chargingArc, LV_ARC_PART_INDIC, LV_STATE_DEFAULT, Colors::deepOrange);
71+
lv_label_set_text_static(status, "Battery critical");
6972
}
7073

71-
lv_label_set_text_fmt(percent, "%02i%%", batteryPercent);
74+
lv_label_set_text_fmt(percent, "%i%%", batteryPercent);
7275
lv_obj_align(percent, chargingArc, LV_ALIGN_CENTER, 0, 0);
7376

7477
lv_obj_align(status, voltage, LV_ALIGN_IN_BOTTOM_MID, 0, -27);

0 commit comments

Comments
 (0)