From eccea5ab9f43eea3c3ac6dbfb7e03dd81578191c Mon Sep 17 00:00:00 2001 From: Riku Isokoski Date: Sat, 25 Feb 2023 10:05:32 +0200 Subject: [PATCH] SystemTask: Move lcd to DisplayApp SystemTask should never write to the lcd --- src/displayapp/DisplayApp.cpp | 3 +++ src/main.cpp | 1 - src/systemtask/SystemTask.cpp | 5 ----- src/systemtask/SystemTask.h | 2 -- 4 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index d910875e..6698ea28 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -129,6 +129,7 @@ void DisplayApp::InitHw() { brightnessController.Init(); ApplyBrightness(); motorController.Init(); + lcd.Init(); } void DisplayApp::Refresh() { @@ -184,10 +185,12 @@ void DisplayApp::Refresh() { brightnessController.Lower(); vTaskDelay(100); } + lcd.Sleep(); PushMessageToSystemTask(Pinetime::System::Messages::OnDisplayTaskSleeping); state = States::Idle; break; case Messages::GoToRunning: + lcd.Wakeup(); ApplyBrightness(); state = States::Running; break; diff --git a/src/main.cpp b/src/main.cpp index 9611d26c..36fb49c4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -128,7 +128,6 @@ Pinetime::Applications::DisplayApp displayApp(lcd, fs); Pinetime::System::SystemTask systemTask(spi, - lcd, spiNorFlash, twiMaster, touchPanel, diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index d5bca239..3ceb63d4 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -49,7 +49,6 @@ void MeasureBatteryTimerCallback(TimerHandle_t xTimer) { } SystemTask::SystemTask(Drivers::SpiMaster& spi, - Drivers::St7789& lcd, Pinetime::Drivers::SpiNorFlash& spiNorFlash, Drivers::TwiMaster& twiMaster, Drivers::Cst816S& touchPanel, @@ -71,7 +70,6 @@ SystemTask::SystemTask(Drivers::SpiMaster& spi, Pinetime::Controllers::TouchHandler& touchHandler, Pinetime::Controllers::ButtonHandler& buttonHandler) : spi {spi}, - lcd {lcd}, spiNorFlash {spiNorFlash}, twiMaster {twiMaster}, touchPanel {touchPanel}, @@ -131,7 +129,6 @@ void SystemTask::Work() { fs.Init(); nimbleController.Init(); - lcd.Init(); twiMaster.Init(); /* @@ -232,7 +229,6 @@ void SystemTask::Work() { xTimerStart(dimTimer, 0); spiNorFlash.Wakeup(); - lcd.Wakeup(); displayApp.PushMessage(Pinetime::Applications::Display::Messages::GoToRunning); heartRateApp.PushMessage(Pinetime::Applications::HeartRateTask::Messages::WakeUp); @@ -362,7 +358,6 @@ void SystemTask::Work() { // if it's in sleep mode. Avoid bricked device by disabling sleep mode on these versions. spiNorFlash.Sleep(); } - lcd.Sleep(); spi.Sleep(); // Double Tap needs the touch screen to be in normal mode diff --git a/src/systemtask/SystemTask.h b/src/systemtask/SystemTask.h index e407f7ea..72e88875 100644 --- a/src/systemtask/SystemTask.h +++ b/src/systemtask/SystemTask.h @@ -55,7 +55,6 @@ namespace Pinetime { public: enum class SystemTaskState { Sleeping, Running, GoingToSleep, WakingUp }; SystemTask(Drivers::SpiMaster& spi, - Drivers::St7789& lcd, Pinetime::Drivers::SpiNorFlash& spiNorFlash, Drivers::TwiMaster& twiMaster, Drivers::Cst816S& touchPanel, @@ -97,7 +96,6 @@ namespace Pinetime { TaskHandle_t taskHandle; Pinetime::Drivers::SpiMaster& spi; - Pinetime::Drivers::St7789& lcd; Pinetime::Drivers::SpiNorFlash& spiNorFlash; Pinetime::Drivers::TwiMaster& twiMaster; Pinetime::Drivers::Cst816S& touchPanel;