From f48fb8a368718bc9d2e2b434bda5da9877629b30 Mon Sep 17 00:00:00 2001 From: Titus Kendzorra Date: Wed, 11 Jun 2025 01:14:40 +0200 Subject: [PATCH 1/3] remove leading zeros from battery percentage --- src/displayapp/screens/BatteryInfo.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/displayapp/screens/BatteryInfo.cpp b/src/displayapp/screens/BatteryInfo.cpp index 2040198805..f9aaec8a69 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); @@ -68,7 +68,7 @@ void BatteryInfo::Refresh() { lv_label_set_text_static(status, "Discharging"); } - 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); From e1c45d5b75348a629f538bad2a4f437ba9c4172a Mon Sep 17 00:00:00 2001 From: Titus Kendzorra Date: Wed, 11 Jun 2025 01:17:21 +0200 Subject: [PATCH 2/3] add correct colors matching the battery icon color thresholds --- src/displayapp/screens/BatteryInfo.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/displayapp/screens/BatteryInfo.cpp b/src/displayapp/screens/BatteryInfo.cpp index f9aaec8a69..14ea9c75d3 100644 --- a/src/displayapp/screens/BatteryInfo.cpp +++ b/src/displayapp/screens/BatteryInfo.cpp @@ -60,12 +60,15 @@ 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, "%i%%", batteryPercent); From d270ceb33ae631951d45d78de3f3a102a01744af Mon Sep 17 00:00:00 2001 From: Titus Kendzorra Date: Wed, 11 Jun 2025 01:38:59 +0200 Subject: [PATCH 3/3] formatting --- src/displayapp/screens/BatteryInfo.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/displayapp/screens/BatteryInfo.cpp b/src/displayapp/screens/BatteryInfo.cpp index 14ea9c75d3..16845d53e7 100644 --- a/src/displayapp/screens/BatteryInfo.cpp +++ b/src/displayapp/screens/BatteryInfo.cpp @@ -67,8 +67,8 @@ void BatteryInfo::Refresh() { 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_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, "%i%%", batteryPercent);