summaryrefslogtreecommitdiff
path: root/src/components/battery
diff options
context:
space:
mode:
authorJF002 <JF002@users.noreply.github.com>2021-09-12 18:22:04 +0200
committerGitHub <noreply@github.com>2021-09-12 18:22:04 +0200
commitf0329298ac4171e1c117bbf4ae2394f2b9769348 (patch)
tree7807daa81cb5bafc1f90f86a62bfe4f4c5505fbe /src/components/battery
parent977321cf6457eefed7fe0cea0fb9b94c2fddf7fd (diff)
parent21d37d1e234b217b3e71dc65eb19db197ee21bad (diff)
Merge pull request #580 from Riksu9000/timer_battery_reading
Make battery reading periodic
Diffstat (limited to 'src/components/battery')
-rw-r--r--src/components/battery/BatteryController.cpp11
-rw-r--r--src/components/battery/BatteryController.h7
2 files changed, 11 insertions, 7 deletions
diff --git a/src/components/battery/BatteryController.cpp b/src/components/battery/BatteryController.cpp
index f8a64ecd..aa038c5d 100644
--- a/src/components/battery/BatteryController.cpp
+++ b/src/components/battery/BatteryController.cpp
@@ -9,10 +9,7 @@ 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(chargingPin, static_cast<nrf_gpio_pin_pull_t> GPIO_PIN_CNF_PULL_Disabled);
}
void Battery::Update() {
@@ -75,5 +72,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;
+}
diff --git a/src/components/battery/BatteryController.h b/src/components/battery/BatteryController.h
index 6f09b737..ad304eba 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,8 @@ namespace Pinetime {
public:
Battery();
- void Init();
void Update();
+ void Register(System::SystemTask* systemTask);
uint8_t PercentRemaining() const {
return percentRemaining;
@@ -49,6 +48,8 @@ namespace Pinetime {
static void AdcCallbackStatic(nrfx_saadc_evt_t const* event);
bool isReading = false;
+
+ Pinetime::System::SystemTask* systemTask = nullptr;
};
}
}