diff options
author | Finlay Davidson <finlay.davidson@coderclass.nl> | 2022-12-12 00:44:39 +0100 |
---|---|---|
committer | JF <JF002@users.noreply.github.com> | 2023-01-23 21:48:29 +0100 |
commit | 8b0d888952bb3cfbf587ab20d5096f2e578a6107 (patch) | |
tree | 92ee70cdc6f13a4a2f19921725659ac4f6390de9 | |
parent | 762d52e114e02ef490e7b30a28f99d8b6b880404 (diff) |
batt: Improve discharge curve values
Values calculated using multiple tests on 3 PineTimes
-rw-r--r-- | src/components/battery/BatteryController.cpp | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/src/components/battery/BatteryController.cpp b/src/components/battery/BatteryController.cpp index ead3e43b..4d860490 100644 --- a/src/components/battery/BatteryController.cpp +++ b/src/components/battery/BatteryController.cpp @@ -61,14 +61,8 @@ void Battery::SaadcInit() { } void Battery::SaadcEventHandler(nrfx_saadc_evt_t const* p_event) { - static const Utility::LinearApproximation<uint16_t, uint8_t, 6> aprox {{{ - {3500, 0}, // Minimum voltage before shutdown (depends on the battery) - {3600, 10}, // Keen point that corresponds to 10% - {3700, 25}, - {3750, 50}, - {3900, 75}, - {4180, 100} // Maximum voltage during charging is 4.21V - }}}; + static const Utility::LinearApproximation<uint16_t, uint8_t, 6> approx { + {{{3500, 0}, {3616, 3}, {3723, 22}, {3776, 48}, {3979, 79}, {4180, 100}}}}; if (p_event->type == NRFX_SAADC_EVT_DONE) { @@ -83,7 +77,8 @@ void Battery::SaadcEventHandler(nrfx_saadc_evt_t const* p_event) { uint8_t newPercent = 100; if (!isFull) { - newPercent = std::min(aprox.GetValue(voltage), isCharging ? uint8_t {99} : uint8_t {100}); + // max. voltage while charging is higher than when discharging + newPercent = std::min(approx.GetValue(voltage), isCharging ? uint8_t {99} : uint8_t {100}); } if (isPowerPresent) { |