diff options
Diffstat (limited to 'src/systemtask')
| -rw-r--r-- | src/systemtask/SystemTask.cpp | 22 | ||||
| -rw-r--r-- | src/systemtask/SystemTask.h | 4 |
2 files changed, 20 insertions, 6 deletions
diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index 6d695e2..5966062 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -149,6 +149,16 @@ void SystemTask::Work() { nrfx_gpiote_in_init(pinTouchIrq, &pinConfig, nrfx_gpiote_evt_handler); + nrf_gpio_cfg_sense_input(pinPowerPresentIrq, (nrf_gpio_pin_pull_t) NRF_GPIO_PIN_NOPULL, (nrf_gpio_pin_sense_t) GPIO_PIN_CNF_SENSE_Low); + + pinConfig.sense = NRF_GPIOTE_POLARITY_TOGGLE; + pinConfig.pull = NRF_GPIO_PIN_NOPULL; + pinConfig.is_watcher = false; + pinConfig.hi_accuracy = false; + pinConfig.skip_gpio_setup = true; + + nrfx_gpiote_in_init(pinPowerPresentIrq, &pinConfig, nrfx_gpiote_evt_handler); + idleTimer = xTimerCreate("idleTimer", pdMS_TO_TICKS(settingsController.GetScreenTimeOut()), pdFALSE, this, IdleTimerCallback); xTimerStart(idleTimer, 0); @@ -161,12 +171,9 @@ void SystemTask::Work() { uint8_t msg; if (xQueueReceive(systemTasksMsgQueue, &msg, 100)) { - // call the battery controller or use the MSG in DisplayApp to get the battery status ??? - // it is necessary to validate which is the most efficient batteryController.Update(); - // displayApp->PushMessage(Pinetime::Applications::Display::Messages::UpdateBatteryLevel); - // analyze a more efficient way to do this refreshment - // this and the UpdateMotion(); can be called on a timer to be independent of the main process ??? + // the battery does not emit events when changing charge levels, so we piggyback + // on any system event to read and update the current values Messages message = static_cast<Messages>(msg); switch (message) { @@ -274,6 +281,11 @@ void SystemTask::Work() { // Remember we'll have to reset the counter next time we're awake stepCounterMustBeReset = true; break; + case Messages::OnChargingEvent: + motorController.SetDuration(15); + // Battery level is updated on every message - there's no need to do anything + break; + default: break; } diff --git a/src/systemtask/SystemTask.h b/src/systemtask/SystemTask.h index e65fbea..52e71b1 100644 --- a/src/systemtask/SystemTask.h +++ b/src/systemtask/SystemTask.h @@ -55,7 +55,8 @@ namespace Pinetime { OnDisplayTaskSleeping, EnableSleeping, DisableSleeping, - OnNewDay + OnNewDay, + OnChargingEvent }; SystemTask(Drivers::SpiMaster& spi, @@ -121,6 +122,7 @@ namespace Pinetime { static constexpr uint8_t pinLcdDataCommand = 18; static constexpr uint8_t pinButton = 13; static constexpr uint8_t pinTouchIrq = 28; + static constexpr uint8_t pinPowerPresentIrq = 19; static void Process(void* instance); void Work(); |
