InfiniTime.git

commit cad58f190f18bc4717d7c1b78e8a5497d5220d9e

Author: minacode <minamoto9@web.de>

added message, changed UI

 src/components/battery/BatteryController.cpp | 9 ++++-----
 src/components/battery/BatteryController.h | 5 +++++
 src/displayapp/screens/BatteryInfo.cpp | 2 +-
 src/systemtask/SystemTask.cpp | 4 ++--


diff --git a/src/components/battery/BatteryController.cpp b/src/components/battery/BatteryController.cpp
index ca0db79f675d72db93350ee42640470dde506afc..49a17da1147c9c4945b5750f6ab24edacc768b4b 100644
--- a/src/components/battery/BatteryController.cpp
+++ b/src/components/battery/BatteryController.cpp
@@ -96,12 +96,11 @@       firstMeasurement = false;
       lastPercentRemaining = percentRemaining;
       percentRemaining = newPercent;
       systemTask->PushMessage(System::Messages::BatteryPercentageUpdated);
-    }
 
-    // warn at 20% battery (wrt. rescaling above)
-    constexpr uint8_t lowBatteryThreshold {20};
-    if (!isPowerPresent && lastPercentRemaining >= lowBatteryThreshold && percentRemaining < lowBatteryThreshold) {
-      systemTask->PushMessage(System::Messages::LowBattery);
+      // warn at 20% battery (wrt. rescaling above)
+      if (!isPowerPresent && BatteryIsLow() && lastPercentRemaining > lowBatteryThreshold) {
+          systemTask->PushMessage(System::Messages::LowBattery);
+      }
     }
 
     nrfx_saadc_uninit();




diff --git a/src/components/battery/BatteryController.h b/src/components/battery/BatteryController.h
index 53eb7d19fabc7716efd0304d6104cf865660db13..df592232e9a21557a4b8db91ee5dd0538aed6985 100644
--- a/src/components/battery/BatteryController.h
+++ b/src/components/battery/BatteryController.h
@@ -17,6 +17,9 @@
       uint8_t PercentRemaining() const {
         return percentRemaining;
       }
+      bool BatteryIsLow() const {
+        return percentRemaining <= lowBatteryThreshold;
+      }
 
       uint16_t Voltage() const {
         return voltage;
@@ -50,6 +53,8 @@       void SaadcInit();
 
       void SaadcEventHandler(nrfx_saadc_evt_t const* p_event);
       static void AdcCallbackStatic(nrfx_saadc_evt_t const* event);
+
+      static constexpr uint8_t lowBatteryThreshold {20};
 
       bool isReading = false;
 




diff --git a/src/displayapp/screens/BatteryInfo.cpp b/src/displayapp/screens/BatteryInfo.cpp
index 9febda61a9454922f9fe32360480b1648f8559d0..87d1f2e181b8bcf0a7c3943b4360064be610cdd7 100644
--- a/src/displayapp/screens/BatteryInfo.cpp
+++ b/src/displayapp/screens/BatteryInfo.cpp
@@ -59,7 +59,7 @@     lv_label_set_text_static(status, "Charging");
   } else if (batteryPercent == 100) {
     lv_obj_set_style_local_bg_color(charging_bar, LV_BAR_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_BLUE);
     lv_label_set_text_static(status, "Fully charged");
-  } else if (batteryPercent < 10) {
+  } else if (batteryController.BatteryIsLow()) {
     lv_obj_set_style_local_bg_color(charging_bar, LV_BAR_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_YELLOW);
     lv_label_set_text_static(status, "Battery low");
   } else {




diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp
index e45ffe8bd42fa4bf7ccf056f5c48f5e3e43ef6aa..2232f56b563e39edc475fb32fc9dce78b5eb0971 100644
--- a/src/systemtask/SystemTask.cpp
+++ b/src/systemtask/SystemTask.cpp
@@ -426,9 +426,9 @@           nimbleController.NotifyBatteryLevel(batteryController.PercentRemaining());
           break;
         case Messages::LowBattery: {
           Pinetime::Controllers::NotificationManager::Notification notif;
-          std::array<char, 101> message {"Low Battery\0Low Battery\0"};
+          std::array<char, 101> message {"Low Battery\0Charge your watch to prevent data loss\0"};
           notif.message = message;
-          notif.size = 25;
+          notif.size = 52;
           notif.category = Pinetime::Controllers::NotificationManager::Categories::SimpleAlert;
           notificationManager.Push(std::move(notif));
           PushMessage(Messages::OnNewNotification);