From 10c52601879d80da55f5479a75ffb7f942ad2b61 Mon Sep 17 00:00:00 2001 From: Samuel Archibald Date: Mon, 2 Nov 2020 21:14:28 -0500 Subject: [PATCH 1/5] Fixed displaying last displayed time for ~100ms on wake --- .gitignore | 1 + src/systemtask/SystemTask.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index e1d954b7..8d416f85 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ CMakeFiles/ **/CMakeCache.txt cmake_install.cmake Makefile +build/ # Resulting binary files *.a diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index dac4ce29..f82bfc6a 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -105,8 +105,12 @@ void SystemTask::Work() { #pragma clang diagnostic push #pragma ide diagnostic ignored "EndlessLoop" while(true) { + uint8_t msg; if (xQueueReceive(systemTasksMsgQueue, &msg, isSleeping ? 2500 : 1000)) { + uint32_t systick_counter = nrf_rtc_counter_get(portNRF_RTC_REG); + dateTimeController.UpdateTime(systick_counter); + batteryController.Update(); Messages message = static_cast(msg); switch(message) { case Messages::GoToRunning: @@ -190,10 +194,6 @@ void SystemTask::Work() { } } - uint32_t systick_counter = nrf_rtc_counter_get(portNRF_RTC_REG); - dateTimeController.UpdateTime(systick_counter); - batteryController.Update(); - monitor.Process(); if(!nrf_gpio_pin_read(pinButton)) From 37c27687874bcafe2fcc8ac6fdba0b6d549d6434 Mon Sep 17 00:00:00 2001 From: Samuel Archibald Date: Mon, 2 Nov 2020 23:13:31 -0500 Subject: [PATCH 2/5] This is the actual fix, reducing the time between LCD is turned back on and the next task which will display the time is started. --- src/systemtask/SystemTask.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index f82bfc6a..3271edcf 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -105,11 +105,8 @@ void SystemTask::Work() { #pragma clang diagnostic push #pragma ide diagnostic ignored "EndlessLoop" while(true) { - uint8_t msg; if (xQueueReceive(systemTasksMsgQueue, &msg, isSleeping ? 2500 : 1000)) { - uint32_t systick_counter = nrf_rtc_counter_get(portNRF_RTC_REG); - dateTimeController.UpdateTime(systick_counter); batteryController.Update(); Messages message = static_cast(msg); switch(message) { @@ -117,15 +114,15 @@ void SystemTask::Work() { spi.Wakeup(); twiMaster.Wakeup(); + nimbleController.StartAdvertising(); + xTimerStart(idleTimer, 0); spiNorFlash.Wakeup(); - lcd.Wakeup(); touchPanel.Wakeup(); + lcd.Wakeup(); displayApp->PushMessage(Applications::DisplayApp::Messages::GoToRunning); displayApp->PushMessage(Applications::DisplayApp::Messages::UpdateBatteryLevel); - xTimerStart(idleTimer, 0); - nimbleController.StartAdvertising(); isSleeping = false; isWakingUp = false; break; @@ -195,7 +192,7 @@ void SystemTask::Work() { } monitor.Process(); - + dateTimeController.UpdateTime(nrf_rtc_counter_get(portNRF_RTC_REG);); if(!nrf_gpio_pin_read(pinButton)) watchdog.Kick(); } From 681182d16ab502d103e277d817a05f750dc59e66 Mon Sep 17 00:00:00 2001 From: Samuel Archibald Date: Thu, 19 Nov 2020 15:44:57 -0500 Subject: [PATCH 3/5] Readability and fix --- src/systemtask/SystemTask.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index 3271edcf..51b84912 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -192,7 +192,8 @@ void SystemTask::Work() { } monitor.Process(); - dateTimeController.UpdateTime(nrf_rtc_counter_get(portNRF_RTC_REG);); + uint32_t systick_counter = nrf_rtc_counter_get(portNRF_RTC_REG); + dateTimeController.UpdateTime(nrf_rtc_counter_get(systick_counter); if(!nrf_gpio_pin_read(pinButton)) watchdog.Kick(); } From e18485c92bc4941eff38d61de52077c8d2aebeeb Mon Sep 17 00:00:00 2001 From: Samuel Archibald Date: Thu, 19 Nov 2020 15:47:27 -0500 Subject: [PATCH 4/5] Whoops! Don't look at this XD --- src/systemtask/SystemTask.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index 51b84912..96ab7b73 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -193,7 +193,7 @@ void SystemTask::Work() { monitor.Process(); uint32_t systick_counter = nrf_rtc_counter_get(portNRF_RTC_REG); - dateTimeController.UpdateTime(nrf_rtc_counter_get(systick_counter); + dateTimeController.UpdateTime(nrf_rtc_counter_get(systick_counter)); if(!nrf_gpio_pin_read(pinButton)) watchdog.Kick(); } From e180ec5f3a45e5ad4774ca915c84dff481692206 Mon Sep 17 00:00:00 2001 From: Samuel Archibald Date: Thu, 19 Nov 2020 15:50:39 -0500 Subject: [PATCH 5/5] =?UTF-8?q?Jeez=20this=20is=20what=20I=20get=20for=20r?= =?UTF-8?q?ushing=20=F0=9F=98=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/systemtask/SystemTask.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index 96ab7b73..3177bce5 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -193,7 +193,7 @@ void SystemTask::Work() { monitor.Process(); uint32_t systick_counter = nrf_rtc_counter_get(portNRF_RTC_REG); - dateTimeController.UpdateTime(nrf_rtc_counter_get(systick_counter)); + dateTimeController.UpdateTime(systick_counter); if(!nrf_gpio_pin_read(pinButton)) watchdog.Kick(); }