summaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 04cef6b..61194b9 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -101,11 +101,13 @@ Pinetime::Drivers::Bma421 motionSensor {twiMaster, motionSensorTwiAddress};
Pinetime::Drivers::Hrs3300 heartRateSensor {twiMaster, heartRateSensorTwiAddress};
TimerHandle_t debounceTimer;
+TimerHandle_t debounceChargeTimer;
Pinetime::Controllers::Battery batteryController;
Pinetime::Controllers::Ble bleController;
void ble_manager_set_ble_connection_callback(void (*connection)());
void ble_manager_set_ble_disconnection_callback(void (*disconnection)());
static constexpr uint8_t pinTouchIrq = 28;
+static constexpr uint8_t pinPowerPresentIrq = 19;
std::unique_ptr<Pinetime::System::SystemTask> systemTask;
Pinetime::Controllers::Settings settingsController {spiNorFlash};
@@ -119,6 +121,13 @@ void nrfx_gpiote_evt_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action
}
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
+
+ if (pin == pinPowerPresentIrq and action == NRF_GPIOTE_POLARITY_TOGGLE) {
+ xTimerStartFromISR(debounceChargeTimer, &xHigherPriorityTaskWoken);
+ portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
+ return;
+ }
+
xTimerStartFromISR(debounceTimer, &xHigherPriorityTaskWoken);
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
}
@@ -130,6 +139,11 @@ void vApplicationIdleHook(void) {
}
}
+void DebounceTimerChargeCallback(TimerHandle_t xTimer) {
+ xTimerStop(xTimer, 0);
+ systemTask->PushMessage(Pinetime::System::SystemTask::Messages::OnChargingEvent);
+}
+
void DebounceTimerCallback(TimerHandle_t xTimer) {
xTimerStop(xTimer, 0);
systemTask->OnButtonPushed();
@@ -248,6 +262,7 @@ int main(void) {
nrf_drv_clock_init();
debounceTimer = xTimerCreate("debounceTimer", 200, pdFALSE, (void*) 0, DebounceTimerCallback);
+ debounceChargeTimer = xTimerCreate("debounceTimerCharge", 200, pdFALSE, (void*) 0, DebounceTimerChargeCallback);
systemTask = std::make_unique<Pinetime::System::SystemTask>(spi,
lcd,