From 62de76ba99f28eccbe72bbf132ae64cd05eaf6b6 Mon Sep 17 00:00:00 2001 From: JF Date: Sat, 4 Jul 2020 18:10:30 +0200 Subject: [PATCH] Automatically switch the display on when receiving a notification --- src/SystemTask/SystemTask.cpp | 15 ++++++++++----- src/SystemTask/SystemTask.h | 1 + 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/SystemTask/SystemTask.cpp b/src/SystemTask/SystemTask.cpp index 1f01b1b5..39e9751b 100644 --- a/src/SystemTask/SystemTask.cpp +++ b/src/SystemTask/SystemTask.cpp @@ -120,15 +120,15 @@ void SystemTask::Work() { isSleeping = true; break; case Messages::OnNewTime: - xTimerReset(idleTimer, 0); + ReloadIdleTimer(); displayApp->PushMessage(Pinetime::Applications::DisplayApp::Messages::UpdateDateTime); break; case Messages::OnNewNotification: - xTimerReset(idleTimer, 0); + if(isSleeping) GoToRunning(); displayApp->PushMessage(Pinetime::Applications::DisplayApp::Messages::NewNotification); break; case Messages::BleConnected: - xTimerReset(idleTimer, 0); + ReloadIdleTimer(); isBleDiscoveryTimerRunning = true; bleDiscoveryTimer = 5; break; @@ -145,10 +145,10 @@ void SystemTask::Work() { NVIC_SystemReset(); break; case Messages::OnTouchEvent: - xTimerReset(idleTimer, 0); + ReloadIdleTimer(); break; case Messages::OnButtonEvent: - xTimerReset(idleTimer, 0); + ReloadIdleTimer(); break; default: break; } @@ -217,3 +217,8 @@ void SystemTask::OnIdle() { NRF_LOG_INFO("Idle timeout -> Going to sleep") PushMessage(Messages::GoToSleep); } + +void SystemTask::ReloadIdleTimer() const { + if(isSleeping) return; + xTimerReset(idleTimer, 0); +} diff --git a/src/SystemTask/SystemTask.h b/src/SystemTask/SystemTask.h index e006058f..860647a1 100644 --- a/src/SystemTask/SystemTask.h +++ b/src/SystemTask/SystemTask.h @@ -66,6 +66,7 @@ namespace Pinetime { static void Process(void* instance); void Work(); + void ReloadIdleTimer() const; bool isBleDiscoveryTimerRunning = false; uint8_t bleDiscoveryTimer = 0; static constexpr uint32_t idleTime = 15000;