File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -34,9 +34,9 @@ void Battery::Update() {
3434
3535 // see https://forum.pine64.org/showthread.php?tid=8147
3636 voltage = (value * 2 .0f ) / (1024 /3 .0f );
37- float percentRemaining = ((voltage - 3 .55f )*100 .0f )*3 .9f ;
38- percentRemaining = std::max (percentRemaining, 0 . 0f );
39- percentRemaining = std::min (percentRemaining, 100 . 0f );
37+ int percentRemaining = ((voltage - 3 .55f )*100 .0f )*3 .9f ;
38+ percentRemaining = std::max (percentRemaining, 0 );
39+ percentRemaining = std::min (percentRemaining, 100 );
4040
4141 percentRemainingBuffer.insert (percentRemaining);
4242
Original file line number Diff line number Diff line change @@ -20,8 +20,8 @@ namespace Pinetime {
2020 }
2121 }
2222
23- float GetAverage () const {
24- float sum = std::accumulate (arr.begin (), arr.end (), 0 .0f );
23+ int GetAverage () const {
24+ int sum = std::accumulate (arr.begin (), arr.end (), 0 .0f );
2525 return (sum / sz);
2626 }
2727
@@ -36,7 +36,7 @@ namespace Pinetime {
3636 public:
3737 void Init ();
3838 void Update ();
39- float PercentRemaining () const { return percentRemainingBuffer.GetAverage (); }
39+ int PercentRemaining () const { return percentRemainingBuffer.GetAverage (); }
4040 float Voltage () const { return voltage; }
4141 bool IsCharging () const { return isCharging; }
4242 bool IsPowerPresent () const { return isPowerPresent; }
Original file line number Diff line number Diff line change @@ -98,8 +98,7 @@ bool Clock::Refresh() {
9898 batteryPercentRemaining = batteryController.PercentRemaining ();
9999 if (batteryPercentRemaining.IsUpdated ()) {
100100 auto batteryPercent = batteryPercentRemaining.Get ();
101- // lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryPercent));
102- lv_label_set_text (batteryIcon, std::to_string (batteryPercent).c_str ());
101+ lv_label_set_text (batteryIcon, BatteryIcon::GetBatteryIcon (batteryPercent));
103102 auto isCharging = batteryController.IsCharging () || batteryController.IsPowerPresent ();
104103 lv_label_set_text (batteryPlug, BatteryIcon::GetPlugIcon (isCharging));
105104 }
You can’t perform that action at this time.
0 commit comments