From 7f9cc51b050e1034b573e37484f7afe29c370d81 Mon Sep 17 00:00:00 2001 From: Jean-François Milants Date: Sun, 6 Jun 2021 15:56:03 +0200 Subject: Initialize SystemTask, DisplayApp and HeartRateTask as global static variable instead of variables on the heap. We don't need them on the heap as we know their size at build time, it'll reduce memory fragmentation and it'll make memory analysis easier. --- src/displayapp/DisplayApp.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/displayapp/DisplayApp.h') diff --git a/src/displayapp/DisplayApp.h b/src/displayapp/DisplayApp.h index 0c7bd216..65abd41a 100644 --- a/src/displayapp/DisplayApp.h +++ b/src/displayapp/DisplayApp.h @@ -4,6 +4,7 @@ #include #include #include +#include #include "Apps.h" #include "LittleVgl.h" #include "TouchEvents.h" @@ -49,7 +50,6 @@ namespace Pinetime { Controllers::Ble& bleController, Controllers::DateTime& dateTimeController, Drivers::WatchdogView& watchdog, - System::SystemTask& systemTask, Pinetime::Controllers::NotificationManager& notificationManager, Pinetime::Controllers::HeartRateController& heartRateController, Controllers::Settings& settingsController, @@ -64,6 +64,8 @@ namespace Pinetime { void SetFullRefresh(FullRefreshDirections direction); void SetTouchMode(TouchModes mode); + void Register(Pinetime::System::SystemTask* systemTask); + private: Pinetime::Drivers::St7789& lcd; Pinetime::Components::LittleVgl& lvgl; @@ -72,7 +74,7 @@ namespace Pinetime { Pinetime::Controllers::Ble& bleController; Pinetime::Controllers::DateTime& dateTimeController; Pinetime::Drivers::WatchdogView& watchdog; - Pinetime::System::SystemTask& systemTask; + Pinetime::System::SystemTask* systemTask = nullptr; Pinetime::Controllers::NotificationManager& notificationManager; Pinetime::Controllers::HeartRateController& heartRateController; Pinetime::Controllers::Settings& settingsController; @@ -108,6 +110,7 @@ namespace Pinetime { void Refresh(); void ReturnApp(Apps app, DisplayApp::FullRefreshDirections direction, TouchEvents touchEvent); void LoadApp(Apps app, DisplayApp::FullRefreshDirections direction); + void PushMessageToSystemTask(Pinetime::System::Messages message); }; } } -- cgit v1.2.3 From caca6a5cff0025df80241a09baab28e49720ddf8 Mon Sep 17 00:00:00 2001 From: Jean-François Milants Date: Thu, 10 Jun 2021 21:19:11 +0200 Subject: Fix stack corruption when exiting an app (the app was destroyed while it was executing the button handler). --- src/displayapp/DisplayApp.cpp | 8 +++++++- src/displayapp/DisplayApp.h | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'src/displayapp/DisplayApp.h') diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index ba6dfbd2..99758c92 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -205,6 +205,11 @@ void DisplayApp::Refresh() { } } + if(nextApp != Apps::None) { + LoadApp(nextApp, nextDirection); + nextApp = Apps::None; + } + if (state != States::Idle && touchMode == TouchModes::Polling) { auto info = touchPanel.GetTouchInfo(); if (info.action == 2) { // 2 = contact @@ -223,7 +228,8 @@ void DisplayApp::RunningState() { } void DisplayApp::StartApp(Apps app, DisplayApp::FullRefreshDirections direction) { - LoadApp(app, direction); + nextApp = app; + nextDirection = direction; } void DisplayApp::ReturnApp(Apps app, DisplayApp::FullRefreshDirections direction, TouchEvents touchEvent) { diff --git a/src/displayapp/DisplayApp.h b/src/displayapp/DisplayApp.h index 65abd41a..73a7cc36 100644 --- a/src/displayapp/DisplayApp.h +++ b/src/displayapp/DisplayApp.h @@ -111,6 +111,9 @@ namespace Pinetime { void ReturnApp(Apps app, DisplayApp::FullRefreshDirections direction, TouchEvents touchEvent); void LoadApp(Apps app, DisplayApp::FullRefreshDirections direction); void PushMessageToSystemTask(Pinetime::System::Messages message); + + Apps nextApp = Apps::None; + DisplayApp::FullRefreshDirections nextDirection; }; } } -- cgit v1.2.3