Converted percent remaining calc to int.
This commit is contained in:
parent
11280d5f37
commit
e2d1f81915
|
@ -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);
|
||||
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user