From 6c008e96518487c49fb36fa4e3cc012bc5698853 Mon Sep 17 00:00:00 2001 From: mark9064 <30447455+mark9064@users.noreply.github.com> Date: Sun, 26 Jan 2025 19:23:14 +0000 Subject: [PATCH] Initialise DisplayApp components in DisplayApp context --- src/displayapp/DisplayApp.cpp | 23 +++++++++++------------ src/displayapp/DisplayApp.h | 2 +- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index f5b2efde9a..9d9a0a772e 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -129,15 +129,6 @@ void DisplayApp::Start(System::BootErrors error) { bootError = error; - lvgl.Init(); - motorController.Init(); - - if (error == System::BootErrors::TouchController) { - LoadNewScreen(Apps::Error, DisplayApp::FullRefreshDirections::None); - } else { - LoadNewScreen(Apps::Clock, DisplayApp::FullRefreshDirections::None); - } - if (pdPASS != xTaskCreate(DisplayApp::Process, "displayapp", 800, this, 0, &taskHandle)) { APP_ERROR_HANDLER(NRF_ERROR_NO_MEM); } @@ -146,17 +137,25 @@ void DisplayApp::Start(System::BootErrors error) { void DisplayApp::Process(void* instance) { auto* app = static_cast(instance); NRF_LOG_INFO("displayapp task started!"); - app->InitHw(); + app->Init(); + + if (app->bootError == System::BootErrors::TouchController) { + app->LoadNewScreen(Apps::Error, DisplayApp::FullRefreshDirections::None); + } else { + app->LoadNewScreen(Apps::Clock, DisplayApp::FullRefreshDirections::None); + } while (true) { app->Refresh(); } } -void DisplayApp::InitHw() { +void DisplayApp::Init() { + lcd.Init(); + motorController.Init(); brightnessController.Init(); ApplyBrightness(); - lcd.Init(); + lvgl.Init(); } TickType_t DisplayApp::CalculateSleepTime() { diff --git a/src/displayapp/DisplayApp.h b/src/displayapp/DisplayApp.h index 2f276eaf9e..dabed99ea7 100644 --- a/src/displayapp/DisplayApp.h +++ b/src/displayapp/DisplayApp.h @@ -121,7 +121,7 @@ namespace Pinetime { TouchEvents GetGesture(); static void Process(void* instance); - void InitHw(); + void Init(); void Refresh(); void LoadNewScreen(Apps app, DisplayApp::FullRefreshDirections direction); void LoadScreen(Apps app, DisplayApp::FullRefreshDirections direction);