summaryrefslogtreecommitdiff
path: root/src/Components/Battery/BatteryController.h
diff options
context:
space:
mode:
authorJF <jf@codingfield.com>2019-12-27 15:05:35 (GMT)
committerJF <jf@codingfield.com>2019-12-27 15:05:35 (GMT)
commitfcbd341c1cf0084d50e7d32337013095d45091b9 (patch)
treeb1894c3e5168f88142dbf76b3a813535464811c8 /src/Components/Battery/BatteryController.h
parent11d5403558d09eecd2c1fbf824ac925fe3f75d21 (diff)
Implement battery measurement in BatteryController.
Update battery info on wake up (with button)
Diffstat (limited to 'src/Components/Battery/BatteryController.h')
-rw-r--r--src/Components/Battery/BatteryController.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/Components/Battery/BatteryController.h b/src/Components/Battery/BatteryController.h
new file mode 100644
index 0000000..5c631dc
--- /dev/null
+++ b/src/Components/Battery/BatteryController.h
@@ -0,0 +1,24 @@
+#pragma once
+#include <drivers/include/nrfx_saadc.h>
+
+
+namespace Pinetime {
+ namespace Controllers {
+ class Battery {
+ public:
+ void Init();
+ void Update();
+ float PercentRemaining() const { return percentRemaining; }
+ float Voltage() const { return voltage; }
+ bool IsCharging() const { return isCharging; }
+ bool IsPowerPresent() const { return isPowerPresent; }
+
+ private:
+ static void SaadcEventHandler(nrfx_saadc_evt_t const * p_event);
+ float percentRemaining = 0.0f;
+ float voltage = 0.0f;
+ bool isCharging = false;
+ bool isPowerPresent = false;
+ };
+ }
+} \ No newline at end of file