diff --git a/src/components/battery/BatteryController.cpp b/src/components/battery/BatteryController.cpp index e0042f5c..aaa245e4 100644 --- a/src/components/battery/BatteryController.cpp +++ b/src/components/battery/BatteryController.cpp @@ -34,9 +34,9 @@ void Battery::Update() { // see https://forum.pine64.org/showthread.php?tid=8147 voltage = (value * 2.0f) / (1024/3.0f); - float percentRemaining = ((voltage - 3.55f)*100.0f)*3.9f; - percentRemaining = std::max(percentRemaining, 0.0f); - percentRemaining = std::min(percentRemaining, 100.0f); + int percentRemaining = ((voltage - 3.55f)*100.0f)*3.9f; + percentRemaining = std::max(percentRemaining, 0); + percentRemaining = std::min(percentRemaining, 100); percentRemainingBuffer.insert(percentRemaining); diff --git a/src/components/battery/BatteryController.h b/src/components/battery/BatteryController.h index 21caffec..0f2c2a42 100644 --- a/src/components/battery/BatteryController.h +++ b/src/components/battery/BatteryController.h @@ -20,8 +20,8 @@ namespace Pinetime { } } - float GetAverage() const { - float sum = std::accumulate(arr.begin(), arr.end(), 0.0f); + int GetAverage() const { + int sum = std::accumulate(arr.begin(), arr.end(), 0.0f); return (sum / sz); } @@ -36,7 +36,7 @@ namespace Pinetime { public: void Init(); void Update(); - float PercentRemaining() const { return percentRemainingBuffer.GetAverage(); } + int PercentRemaining() const { return percentRemainingBuffer.GetAverage(); } float Voltage() const { return voltage; } bool IsCharging() const { return isCharging; } bool IsPowerPresent() const { return isPowerPresent; } diff --git a/src/displayapp/screens/Clock.cpp b/src/displayapp/screens/Clock.cpp index 5849f4cc..57659141 100644 --- a/src/displayapp/screens/Clock.cpp +++ b/src/displayapp/screens/Clock.cpp @@ -98,8 +98,7 @@ bool Clock::Refresh() { batteryPercentRemaining = batteryController.PercentRemaining(); if (batteryPercentRemaining.IsUpdated()) { auto batteryPercent = batteryPercentRemaining.Get(); - // lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryPercent)); - lv_label_set_text(batteryIcon, std::to_string(batteryPercent).c_str()); + lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryPercent)); auto isCharging = batteryController.IsCharging() || batteryController.IsPowerPresent(); lv_label_set_text(batteryPlug, BatteryIcon::GetPlugIcon(isCharging)); }