Automatically switch the display on when receiving a notification

This commit is contained in:
JF 2020-07-04 18:10:30 +02:00
parent 4abbd7d0cf
commit 62de76ba99
2 changed files with 11 additions and 5 deletions

View File

@ -120,15 +120,15 @@ void SystemTask::Work() {
isSleeping = true; isSleeping = true;
break; break;
case Messages::OnNewTime: case Messages::OnNewTime:
xTimerReset(idleTimer, 0); ReloadIdleTimer();
displayApp->PushMessage(Pinetime::Applications::DisplayApp::Messages::UpdateDateTime); displayApp->PushMessage(Pinetime::Applications::DisplayApp::Messages::UpdateDateTime);
break; break;
case Messages::OnNewNotification: case Messages::OnNewNotification:
xTimerReset(idleTimer, 0); if(isSleeping) GoToRunning();
displayApp->PushMessage(Pinetime::Applications::DisplayApp::Messages::NewNotification); displayApp->PushMessage(Pinetime::Applications::DisplayApp::Messages::NewNotification);
break; break;
case Messages::BleConnected: case Messages::BleConnected:
xTimerReset(idleTimer, 0); ReloadIdleTimer();
isBleDiscoveryTimerRunning = true; isBleDiscoveryTimerRunning = true;
bleDiscoveryTimer = 5; bleDiscoveryTimer = 5;
break; break;
@ -145,10 +145,10 @@ void SystemTask::Work() {
NVIC_SystemReset(); NVIC_SystemReset();
break; break;
case Messages::OnTouchEvent: case Messages::OnTouchEvent:
xTimerReset(idleTimer, 0); ReloadIdleTimer();
break; break;
case Messages::OnButtonEvent: case Messages::OnButtonEvent:
xTimerReset(idleTimer, 0); ReloadIdleTimer();
break; break;
default: break; default: break;
} }
@ -217,3 +217,8 @@ void SystemTask::OnIdle() {
NRF_LOG_INFO("Idle timeout -> Going to sleep") NRF_LOG_INFO("Idle timeout -> Going to sleep")
PushMessage(Messages::GoToSleep); PushMessage(Messages::GoToSleep);
} }
void SystemTask::ReloadIdleTimer() const {
if(isSleeping) return;
xTimerReset(idleTimer, 0);
}

View File

@ -66,6 +66,7 @@ namespace Pinetime {
static void Process(void* instance); static void Process(void* instance);
void Work(); void Work();
void ReloadIdleTimer() const;
bool isBleDiscoveryTimerRunning = false; bool isBleDiscoveryTimerRunning = false;
uint8_t bleDiscoveryTimer = 0; uint8_t bleDiscoveryTimer = 0;
static constexpr uint32_t idleTime = 15000; static constexpr uint32_t idleTime = 15000;