summaryrefslogtreecommitdiff
path: root/src/components
diff options
context:
space:
mode:
authorhubmartin <hub.martin@gmail.com>2021-09-13 08:19:07 (GMT)
committerhubmartin <hub.martin@gmail.com>2021-09-13 08:19:07 (GMT)
commit73d3e41ceadf576542508c114679e1d3e6039d4d (patch)
tree8fdbd15c5a0ac7fc209276ea6e60a9570a51b7ff /src/components
parent8390d0ef7243261675aab3a5c19862eb3fc53e68 (diff)
parentc9aeef94ea824ad7304ca3f0bd76a476f4744ff4 (diff)
Merge branch 'develop' into pinmap
Diffstat (limited to 'src/components')
-rw-r--r--src/components/battery/BatteryController.cpp11
-rw-r--r--src/components/battery/BatteryController.h7
-rw-r--r--src/components/settings/Settings.h2
3 files changed, 12 insertions, 8 deletions
diff --git a/src/components/battery/BatteryController.cpp b/src/components/battery/BatteryController.cpp
index cabf101..4ef20a2 100644
--- a/src/components/battery/BatteryController.cpp
+++ b/src/components/battery/BatteryController.cpp
@@ -10,10 +10,7 @@ Battery* Battery::instance = nullptr;
Battery::Battery() {
instance = this;
-}
-
-void Battery::Init() {
- nrf_gpio_cfg_input(PinMap::Charging, 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() {
@@ -76,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;
+}
diff --git a/src/components/battery/BatteryController.h b/src/components/battery/BatteryController.h
index f33b05e..8af27ea 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;
@@ -47,6 +46,8 @@ namespace Pinetime {
static void AdcCallbackStatic(nrfx_saadc_evt_t const* event);
bool isReading = false;
+
+ Pinetime::System::SystemTask* systemTask = nullptr;
};
}
}
diff --git a/src/components/settings/Settings.h b/src/components/settings/Settings.h
index a294ab7..a54ba97 100644
--- a/src/components/settings/Settings.h
+++ b/src/components/settings/Settings.h
@@ -114,7 +114,7 @@ namespace Pinetime {
};
void setWakeUpMode(WakeUpMode wakeUp, bool enabled) {
- if (!isWakeUpModeOn(wakeUp)) {
+ if (enabled != isWakeUpModeOn(wakeUp)) {
settingsChanged = true;
}
settings.wakeUpMode.set(static_cast<size_t>(wakeUp), enabled);