summaryrefslogtreecommitdiff
path: root/src/components
diff options
context:
space:
mode:
Diffstat (limited to 'src/components')
-rw-r--r--src/components/battery/BatteryController.cpp16
-rw-r--r--src/components/battery/BatteryController.h9
-rw-r--r--src/components/ble/NimbleController.cpp2
-rw-r--r--src/components/brightness/BrightnessController.cpp32
-rw-r--r--src/components/brightness/BrightnessController.h3
-rw-r--r--src/components/motor/MotorController.cpp11
-rw-r--r--src/components/motor/MotorController.h1
-rw-r--r--src/components/settings/Settings.h2
8 files changed, 38 insertions, 38 deletions
diff --git a/src/components/battery/BatteryController.cpp b/src/components/battery/BatteryController.cpp
index f8a64ecd..4ef20a24 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;
+}
diff --git a/src/components/battery/BatteryController.h b/src/components/battery/BatteryController.h
index 6f09b737..8af27ea8 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;
@@ -34,8 +33,6 @@ namespace Pinetime {
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;
uint16_t voltage = 0;
uint8_t percentRemaining = 0;
@@ -49,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/ble/NimbleController.cpp b/src/components/ble/NimbleController.cpp
index 5eb227bf..bde9b076 100644
--- a/src/components/ble/NimbleController.cpp
+++ b/src/components/ble/NimbleController.cpp
@@ -126,7 +126,7 @@ void NimbleController::StartAdvertising() {
// ASSERT(res == 0);// TODO I've disabled these ASSERT as they sometime asserts and reset the mcu.
// For now, the advertising is restarted as soon as it ends. There may be a race condition
// that prevent the advertising from restarting reliably.
- // I remove the assert to prevent this uncesseray crash, but in the long term, the management of
+ // I remove the assert to prevent this unnecessary crash, but in the long term, the management of
// the advertising should be improve (better error handling, and advertise for 3 minutes after
// the application has been woken up, for example.
}
diff --git a/src/components/brightness/BrightnessController.cpp b/src/components/brightness/BrightnessController.cpp
index 8ad987d1..6c524679 100644
--- a/src/components/brightness/BrightnessController.cpp
+++ b/src/components/brightness/BrightnessController.cpp
@@ -1,13 +1,13 @@
#include "BrightnessController.h"
#include <hal/nrf_gpio.h>
#include "displayapp/screens/Symbols.h"
-
+#include "drivers/PinMap.h"
using namespace Pinetime::Controllers;
void BrightnessController::Init() {
- nrf_gpio_cfg_output(pinLcdBacklight1);
- nrf_gpio_cfg_output(pinLcdBacklight2);
- nrf_gpio_cfg_output(pinLcdBacklight3);
+ nrf_gpio_cfg_output(PinMap::LcdBacklightLow);
+ nrf_gpio_cfg_output(PinMap::LcdBacklightMedium);
+ nrf_gpio_cfg_output(PinMap::LcdBacklightHigh);
Set(level);
}
@@ -16,24 +16,24 @@ void BrightnessController::Set(BrightnessController::Levels level) {
switch (level) {
default:
case Levels::High:
- nrf_gpio_pin_clear(pinLcdBacklight1);
- nrf_gpio_pin_clear(pinLcdBacklight2);
- nrf_gpio_pin_clear(pinLcdBacklight3);
+ nrf_gpio_pin_clear(PinMap::LcdBacklightLow);
+ nrf_gpio_pin_clear(PinMap::LcdBacklightMedium);
+ nrf_gpio_pin_clear(PinMap::LcdBacklightHigh);
break;
case Levels::Medium:
- nrf_gpio_pin_clear(pinLcdBacklight1);
- nrf_gpio_pin_clear(pinLcdBacklight2);
- nrf_gpio_pin_set(pinLcdBacklight3);
+ nrf_gpio_pin_clear(PinMap::LcdBacklightLow);
+ nrf_gpio_pin_clear(PinMap::LcdBacklightMedium);
+ nrf_gpio_pin_set(PinMap::LcdBacklightHigh);
break;
case Levels::Low:
- nrf_gpio_pin_clear(pinLcdBacklight1);
- nrf_gpio_pin_set(pinLcdBacklight2);
- nrf_gpio_pin_set(pinLcdBacklight3);
+ nrf_gpio_pin_clear(PinMap::LcdBacklightLow);
+ nrf_gpio_pin_set(PinMap::LcdBacklightMedium);
+ nrf_gpio_pin_set(PinMap::LcdBacklightHigh);
break;
case Levels::Off:
- nrf_gpio_pin_set(pinLcdBacklight1);
- nrf_gpio_pin_set(pinLcdBacklight2);
- nrf_gpio_pin_set(pinLcdBacklight3);
+ nrf_gpio_pin_set(PinMap::LcdBacklightLow);
+ nrf_gpio_pin_set(PinMap::LcdBacklightMedium);
+ nrf_gpio_pin_set(PinMap::LcdBacklightHigh);
break;
}
}
diff --git a/src/components/brightness/BrightnessController.h b/src/components/brightness/BrightnessController.h
index c47158a9..0d7ac2ff 100644
--- a/src/components/brightness/BrightnessController.h
+++ b/src/components/brightness/BrightnessController.h
@@ -22,9 +22,6 @@ namespace Pinetime {
const char* ToString();
private:
- static constexpr uint8_t pinLcdBacklight1 = 14;
- static constexpr uint8_t pinLcdBacklight2 = 22;
- static constexpr uint8_t pinLcdBacklight3 = 23;
Levels level = Levels::High;
Levels backupLevel = Levels::High;
};
diff --git a/src/components/motor/MotorController.cpp b/src/components/motor/MotorController.cpp
index c79ecdd2..f596c718 100644
--- a/src/components/motor/MotorController.cpp
+++ b/src/components/motor/MotorController.cpp
@@ -2,6 +2,7 @@
#include <hal/nrf_gpio.h>
#include "systemtask/SystemTask.h"
#include "app_timer.h"
+#include "drivers/PinMap.h"
APP_TIMER_DEF(shortVibTimer);
APP_TIMER_DEF(longVibTimer);
@@ -9,8 +10,8 @@ APP_TIMER_DEF(longVibTimer);
using namespace Pinetime::Controllers;
void MotorController::Init() {
- nrf_gpio_cfg_output(pinMotor);
- nrf_gpio_pin_set(pinMotor);
+ nrf_gpio_cfg_output(PinMap::Motor);
+ nrf_gpio_pin_set(PinMap::Motor);
app_timer_init();
app_timer_create(&shortVibTimer, APP_TIMER_MODE_SINGLE_SHOT, StopMotor);
@@ -23,7 +24,7 @@ void MotorController::Ring(void* p_context) {
}
void MotorController::RunForDuration(uint8_t motorDuration) {
- nrf_gpio_pin_clear(pinMotor);
+ nrf_gpio_pin_clear(PinMap::Motor);
app_timer_start(shortVibTimer, APP_TIMER_TICKS(motorDuration), nullptr);
}
@@ -34,9 +35,9 @@ void MotorController::StartRinging() {
void MotorController::StopRinging() {
app_timer_stop(longVibTimer);
- nrf_gpio_pin_set(pinMotor);
+ nrf_gpio_pin_set(PinMap::Motor);
}
void MotorController::StopMotor(void* p_context) {
- nrf_gpio_pin_set(pinMotor);
+ nrf_gpio_pin_set(PinMap::Motor);
}
diff --git a/src/components/motor/MotorController.h b/src/components/motor/MotorController.h
index 574b86c8..61014a1e 100644
--- a/src/components/motor/MotorController.h
+++ b/src/components/motor/MotorController.h
@@ -5,7 +5,6 @@
namespace Pinetime {
namespace Controllers {
- static constexpr uint8_t pinMotor = 16;
class MotorController {
public:
diff --git a/src/components/settings/Settings.h b/src/components/settings/Settings.h
index cb7555f3..871ff3b6 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);