ref: 9196c18d376d4f18c686bcfec8550f9c8659d5ea
src/displayapp/DisplayApp.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
#pragma once #include <FreeRTOS.h> #include <queue.h> #include <task.h> #include <memory> #include <systemtask/Messages.h> #include "displayapp/Apps.h" #include "displayapp/LittleVgl.h" #include "displayapp/TouchEvents.h" #include "components/brightness/BrightnessController.h" #include "components/motor/MotorController.h" #include "components/firmwarevalidator/FirmwareValidator.h" #include "components/settings/Settings.h" #include "displayapp/screens/Screen.h" #include "components/timer/Timer.h" #include "components/alarm/AlarmController.h" #include "touchhandler/TouchHandler.h" #include "displayapp/Messages.h" #include "BootErrors.h" #include "utility/StaticStack.h" namespace Pinetime { namespace Drivers { class St7789; class Cst816S; class Watchdog; } namespace Controllers { class Settings; class Battery; class Ble; class DateTime; class NotificationManager; class HeartRateController; class MotionController; class TouchHandler; } namespace System { class SystemTask; }; namespace Applications { class DisplayApp { public: enum class States { Idle, Running }; enum class FullRefreshDirections { None, Up, Down, Left, Right, LeftAnim, RightAnim }; DisplayApp(Drivers::St7789& lcd, const Drivers::Cst816S&, const Controllers::Battery& batteryController, const Controllers::Ble& bleController, Controllers::DateTime& dateTimeController, const Drivers::Watchdog& watchdog, Pinetime::Controllers::NotificationManager& notificationManager, Pinetime::Controllers::HeartRateController& heartRateController, Controllers::Settings& settingsController, Pinetime::Controllers::MotorController& motorController, Pinetime::Controllers::MotionController& motionController, Pinetime::Controllers::AlarmController& alarmController, Pinetime::Controllers::BrightnessController& brightnessController, Pinetime::Controllers::TouchHandler& touchHandler, Pinetime::Controllers::FS& filesystem); void Start(System::BootErrors error); void PushMessage(Display::Messages msg); void StartApp(Apps app, DisplayApp::FullRefreshDirections direction); void SetFullRefresh(FullRefreshDirections direction); void Register(Pinetime::System::SystemTask* systemTask); private: Pinetime::Drivers::St7789& lcd; const Pinetime::Drivers::Cst816S& touchPanel; const Pinetime::Controllers::Battery& batteryController; const Pinetime::Controllers::Ble& bleController; Pinetime::Controllers::DateTime& dateTimeController; const Pinetime::Drivers::Watchdog& watchdog; Pinetime::System::SystemTask* systemTask = nullptr; Pinetime::Controllers::NotificationManager& notificationManager; Pinetime::Controllers::HeartRateController& heartRateController; Pinetime::Controllers::Settings& settingsController; Pinetime::Controllers::MotorController& motorController; Pinetime::Controllers::MotionController& motionController; Pinetime::Controllers::AlarmController& alarmController; Pinetime::Controllers::BrightnessController& brightnessController; Pinetime::Controllers::TouchHandler& touchHandler; Pinetime::Controllers::FS& filesystem; Pinetime::Controllers::FirmwareValidator validator; Pinetime::Components::LittleVgl lvgl; Pinetime::Controllers::Timer timer; TaskHandle_t taskHandle; States state = States::Running; QueueHandle_t msgQueue; static constexpr uint8_t queueSize = 10; static constexpr uint8_t itemSize = 1; std::unique_ptr<Screens::Screen> currentScreen; Apps currentApp = Apps::None; Apps returnToApp = Apps::None; FullRefreshDirections returnDirection = FullRefreshDirections::None; TouchEvents returnTouchEvent = TouchEvents::None; TouchEvents GetGesture(); static void Process(void* instance); void InitHw(); void Refresh(); void LoadNewScreen(Apps app, DisplayApp::FullRefreshDirections direction); void LoadScreen(Apps app, DisplayApp::FullRefreshDirections direction); void PushMessageToSystemTask(Pinetime::System::Messages message); Apps nextApp = Apps::None; DisplayApp::FullRefreshDirections nextDirection; System::BootErrors bootError; void ApplyBrightness(); static constexpr size_t returnAppStackSize = 10; Utility::StaticStack<Apps, returnAppStackSize> returnAppStack; Utility::StaticStack<FullRefreshDirections, returnAppStackSize> appStackDirections; bool isDimmed = false; }; } } |