diff options
Diffstat (limited to 'src/components/battery/BatteryController.h')
-rw-r--r-- | src/components/battery/BatteryController.h | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/components/battery/BatteryController.h b/src/components/battery/BatteryController.h index 6f09b737..5a7394c4 100644 --- a/src/components/battery/BatteryController.h +++ b/src/components/battery/BatteryController.h @@ -1,8 +1,7 @@ #pragma once #include <cstdint> #include <drivers/include/nrfx_saadc.h> -#include <array> -#include <numeric> +#include <systemtask/SystemTask.h> namespace Pinetime { namespace Controllers { @@ -11,8 +10,9 @@ namespace Pinetime { public: Battery(); - void Init(); - void Update(); + void ReadPowerState(); + void MeasureVoltage(); + void Register(System::SystemTask* systemTask); uint8_t PercentRemaining() const { return percentRemaining; @@ -23,7 +23,9 @@ namespace Pinetime { } bool IsCharging() const { - return isCharging; + // isCharging will go up and down when fully charged + // isFull makes sure this returns false while fully charged. + return isCharging && !isFull; } bool IsPowerPresent() const { @@ -34,14 +36,14 @@ namespace Pinetime { static Battery* instance; nrf_saadc_value_t saadc_value; - static constexpr uint32_t chargingPin = 12; - static constexpr uint32_t powerPresentPin = 19; static constexpr nrf_saadc_input_t batteryVoltageAdcInput = NRF_SAADC_INPUT_AIN7; uint16_t voltage = 0; uint8_t percentRemaining = 0; + bool isFull = false; bool isCharging = false; bool isPowerPresent = false; + bool firstMeasurement = true; void SaadcInit(); @@ -49,6 +51,8 @@ namespace Pinetime { static void AdcCallbackStatic(nrfx_saadc_evt_t const* event); bool isReading = false; + + Pinetime::System::SystemTask* systemTask = nullptr; }; } } |