summaryrefslogtreecommitdiff
path: root/src/components/battery/BatteryController.cpp
diff options
context:
space:
mode:
authorJF <jf@codingfield.com>2021-01-23 16:41:29 (GMT)
committerGitea <gitea@fake.local>2021-01-23 16:41:29 (GMT)
commit76ab14fa5f7979dd764b449396dc5835a286ec6d (patch)
tree846b39f9c412854c57fd15cc37e920b7affa28c5 /src/components/battery/BatteryController.cpp
parent1d940af924bac5728a4d494f780e298e5b67b707 (diff)
parent84b509ed9536e081f370d2fd7c519c9ed6acfea4 (diff)
Merge branch 'develop' of JF/PineTime into master
Diffstat (limited to 'src/components/battery/BatteryController.cpp')
-rw-r--r--src/components/battery/BatteryController.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/components/battery/BatteryController.cpp b/src/components/battery/BatteryController.cpp
index 3e3d65b..aaa245e 100644
--- a/src/components/battery/BatteryController.cpp
+++ b/src/components/battery/BatteryController.cpp
@@ -34,9 +34,11 @@ void Battery::Update() {
// see https://forum.pine64.org/showthread.php?tid=8147
voltage = (value * 2.0f) / (1024/3.0f);
- 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);
// NRF_LOG_INFO("BATTERY " NRF_LOG_FLOAT_MARKER " %% - " NRF_LOG_FLOAT_MARKER " v", NRF_LOG_FLOAT(percentRemaining), NRF_LOG_FLOAT(voltage));
// NRF_LOG_INFO("POWER Charging : %d - Power : %d", isCharging, isPowerPresent);