aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/battery/BatteryController.h
diff options
context:
space:
mode:
authorJoaquim <joaquim.org@gmail.com>2021-04-05 15:22:10 +0100
committerJoaquim <joaquim.org@gmail.com>2021-04-05 15:22:10 +0100
commit365e68e6cc3c9f893e7582d26a1805d6d51ef294 (patch)
tree9eff0e7f277419d4b551413be2d498602fcbcbe2 /src/components/battery/BatteryController.h
parent96961709f3a659fd89ccbb8a13813ed9f3c586eb (diff)
Fix wake up lock in twi
optimize battery code
Diffstat (limited to 'src/components/battery/BatteryController.h')
-rw-r--r--src/components/battery/BatteryController.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/components/battery/BatteryController.h b/src/components/battery/BatteryController.h
index 9bc942c9..6a0c7dff 100644
--- a/src/components/battery/BatteryController.h
+++ b/src/components/battery/BatteryController.h
@@ -10,6 +10,8 @@ namespace Pinetime {
class Battery {
public:
+ Battery();
+
void Init();
void Update();
@@ -20,16 +22,22 @@ namespace Pinetime {
bool IsPowerPresent() const { return isPowerPresent; }
private:
+ 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;
+ float voltage = 0.0f;
+ int percentRemaining = -1;
bool isCharging = false;
bool isPowerPresent = false;
-
- static void SaadcEventHandler(nrfx_saadc_evt_t const * p_event);
+
void SaadcInit();
+ void SaadcEventHandler(nrfx_saadc_evt_t const * p_event);
+ static void adcCallbackStatic(nrfx_saadc_evt_t const *event);
};
}
} \ No newline at end of file