diff options
| author | Titus <154823939+tituscmd@users.noreply.github.com> | 2025-06-12 09:13:53 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-12 09:13:53 +0200 |
| commit | b2d0e04e42f8d321a87343f2759f8038b21bc214 (patch) | |
| tree | e4fc26fd3e2c33d9b69a523bbdb9baf85b21ff9d /src/displayapp/screens | |
| parent | 4f426f00a86ebb2e22e9868009948768b1bca07d (diff) | |
BatteryInfo App Redesign: Fixup (#2310)
* remove leading zeros from battery percentage
* add correct colors matching the battery icon color thresholds
Diffstat (limited to 'src/displayapp/screens')
| -rw-r--r-- | src/displayapp/screens/BatteryInfo.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/displayapp/screens/BatteryInfo.cpp b/src/displayapp/screens/BatteryInfo.cpp index 20401988..16845d53 100644 --- a/src/displayapp/screens/BatteryInfo.cpp +++ b/src/displayapp/screens/BatteryInfo.cpp @@ -30,7 +30,7 @@ BatteryInfo::BatteryInfo(const Pinetime::Controllers::Battery& batteryController percent = lv_label_create(lv_scr_act(), nullptr); lv_obj_set_style_local_text_font(percent, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42); - lv_label_set_text_fmt(percent, "%02i%%", batteryPercent); + lv_label_set_text_fmt(percent, "%i%%", batteryPercent); lv_label_set_align(percent, LV_LABEL_ALIGN_LEFT); lv_obj_align(percent, chargingArc, LV_ALIGN_CENTER, 0, 0); @@ -60,15 +60,18 @@ void BatteryInfo::Refresh() { } else if (batteryPercent == 100) { lv_obj_set_style_local_line_color(chargingArc, LV_ARC_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_BLUE); lv_label_set_text_static(status, "Fully charged"); - } else if (batteryPercent < 10) { - lv_obj_set_style_local_line_color(chargingArc, LV_ARC_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_RED); - lv_label_set_text_static(status, "Battery low"); - } else { + } else if (batteryPercent > 15) { lv_obj_set_style_local_line_color(chargingArc, LV_ARC_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_GREEN); lv_label_set_text_static(status, "Discharging"); + } else if (batteryPercent > 5) { + lv_obj_set_style_local_line_color(chargingArc, LV_ARC_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_ORANGE); + lv_label_set_text_static(status, "Battery low"); + } else { + lv_obj_set_style_local_line_color(chargingArc, LV_ARC_PART_INDIC, LV_STATE_DEFAULT, Colors::deepOrange); + lv_label_set_text_static(status, "Battery critical"); } - lv_label_set_text_fmt(percent, "%02i%%", batteryPercent); + lv_label_set_text_fmt(percent, "%i%%", batteryPercent); lv_obj_align(percent, chargingArc, LV_ALIGN_CENTER, 0, 0); lv_obj_align(status, voltage, LV_ALIGN_IN_BOTTOM_MID, 0, -27); |
