summaryrefslogtreecommitdiff
path: root/src/components/battery/BatteryController.cpp
diff options
context:
space:
mode:
authorJF <jf@codingfield.com>2021-09-26 09:16:55 (GMT)
committerGitea <gitea@fake.local>2021-09-26 09:16:55 (GMT)
commit6652ec6f71967f4a8eea1f159aa500a1a21a5902 (patch)
treecdbbf9afede8ea74258867ba41905a3fe0d784f4 /src/components/battery/BatteryController.cpp
parent6c3d6fb2575888e582e7ef3004a0bc3bf6c588b6 (diff)
parentd03db14129b4f8cc2e691dd6f9e8d8d1ed52b7a1 (diff)
Merge branch 'develop' of JF/PineTime into master
Diffstat (limited to 'src/components/battery/BatteryController.cpp')
-rw-r--r--src/components/battery/BatteryController.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/components/battery/BatteryController.cpp b/src/components/battery/BatteryController.cpp
index f8a64ec..4ef20a2 100644
--- a/src/components/battery/BatteryController.cpp
+++ b/src/components/battery/BatteryController.cpp
@@ -1,4 +1,5 @@
#include "BatteryController.h"
+#include "drivers/PinMap.h"
#include <hal/nrf_gpio.h>
#include <nrfx_saadc.h>
#include <algorithm>
@@ -9,15 +10,12 @@ Battery* Battery::instance = nullptr;
Battery::Battery() {
instance = this;
-}
-
-void Battery::Init() {
- nrf_gpio_cfg_input(chargingPin, static_cast<nrf_gpio_pin_pull_t> GPIO_PIN_CNF_PULL_Pullup);
+ nrf_gpio_cfg_input(PinMap::Charging, static_cast<nrf_gpio_pin_pull_t> GPIO_PIN_CNF_PULL_Disabled);
}
void Battery::Update() {
- isCharging = !nrf_gpio_pin_read(chargingPin);
- isPowerPresent = !nrf_gpio_pin_read(powerPresentPin);
+ isCharging = !nrf_gpio_pin_read(PinMap::Charging);
+ isPowerPresent = !nrf_gpio_pin_read(PinMap::PowerPresent);
if (isReading) {
return;
@@ -75,5 +73,11 @@ void Battery::SaadcEventHandler(nrfx_saadc_evt_t const* p_event) {
nrfx_saadc_uninit();
isReading = false;
+
+ systemTask->PushMessage(System::Messages::BatteryMeasurementDone);
}
}
+
+void Battery::Register(Pinetime::System::SystemTask* systemTask) {
+ this->systemTask = systemTask;
+}