InfiniTime/src/displayapp/DisplayApp.h

136 lines
4.8 KiB
C
Raw Normal View History

#pragma once
#include <FreeRTOS.h>
2020-11-15 15:49:36 +00:00
#include <date/date.h>
#include <queue.h>
2020-11-15 15:49:36 +00:00
#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"
2021-04-20 11:31:40 +00:00
#include "components/motor/MotorController.h"
#include "components/firmwarevalidator/FirmwareValidator.h"
#include "components/settings/Settings.h"
2021-02-01 12:14:49 +00:00
#include "displayapp/screens/Screen.h"
#include "components/timer/TimerController.h"
2021-09-10 22:40:13 +00:00
#include "components/alarm/AlarmController.h"
2021-07-15 11:11:27 +00:00
#include "touchhandler/TouchHandler.h"
2021-09-10 22:40:13 +00:00
#include "displayapp/Messages.h"
2021-08-18 12:23:30 +00:00
#include "BootErrors.h"
#include "StaticStack.h"
namespace Pinetime {
2020-11-15 15:49:36 +00:00
namespace Drivers {
class St7789;
class Cst816S;
class WatchdogView;
}
2020-11-15 15:49:36 +00:00
namespace Controllers {
class Settings;
2020-11-15 15:49:36 +00:00
class Battery;
class Ble;
class DateTime;
class NotificationManager;
class HeartRateController;
class MotionController;
2021-07-15 11:11:27 +00:00
class TouchHandler;
2020-11-15 15:49:36 +00:00
}
namespace System {
class SystemTask;
};
namespace Applications {
class DisplayApp {
2021-04-24 09:00:45 +00:00
public:
enum class States { Idle, Running };
enum class FullRefreshDirections { None, Up, Down, Left, Right, LeftAnim, RightAnim };
DisplayApp(Drivers::St7789& lcd,
Components::LittleVgl& lvgl,
Drivers::Cst816S&,
Controllers::Battery& batteryController,
Controllers::Ble& bleController,
Controllers::DateTime& dateTimeController,
Drivers::WatchdogView& watchdog,
Pinetime::Controllers::NotificationManager& notificationManager,
Pinetime::Controllers::HeartRateController& heartRateController,
Controllers::Settings& settingsController,
2021-04-20 11:31:40 +00:00
Pinetime::Controllers::MotorController& motorController,
Pinetime::Controllers::MotionController& motionController,
2021-07-15 11:11:27 +00:00
Pinetime::Controllers::TimerController& timerController,
2021-09-10 22:40:13 +00:00
Pinetime::Controllers::AlarmController& alarmController,
Pinetime::Controllers::BrightnessController& brightnessController,
Pinetime::Controllers::TouchHandler& touchHandler,
Pinetime::Controllers::FS& filesystem);
2021-08-18 12:23:30 +00:00
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);
2021-04-24 09:00:45 +00:00
private:
Pinetime::Drivers::St7789& lcd;
Pinetime::Components::LittleVgl& lvgl;
Pinetime::Drivers::Cst816S& touchPanel;
Pinetime::Controllers::Battery& batteryController;
Pinetime::Controllers::Ble& bleController;
Pinetime::Controllers::DateTime& dateTimeController;
Pinetime::Drivers::WatchdogView& watchdog;
Pinetime::System::SystemTask* systemTask = nullptr;
Pinetime::Controllers::NotificationManager& notificationManager;
Pinetime::Controllers::HeartRateController& heartRateController;
Pinetime::Controllers::Settings& settingsController;
2021-04-20 11:31:40 +00:00
Pinetime::Controllers::MotorController& motorController;
Pinetime::Controllers::MotionController& motionController;
Pinetime::Controllers::TimerController& timerController;
2021-09-10 22:40:13 +00:00
Pinetime::Controllers::AlarmController& alarmController;
2022-05-09 15:16:08 +00:00
Pinetime::Controllers::BrightnessController& brightnessController;
2021-07-15 11:11:27 +00:00
Pinetime::Controllers::TouchHandler& touchHandler;
Pinetime::Controllers::FS& filesystem;
Pinetime::Controllers::FirmwareValidator validator;
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;
2021-07-15 11:11:27 +00:00
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;
2021-08-18 12:23:30 +00:00
System::BootErrors bootError;
void ApplyBrightness();
static constexpr size_t returnAppStackSize = 10;
StaticStack<Apps, returnAppStackSize> returnAppStack;
StaticStack<FullRefreshDirections, returnAppStackSize> appStackDirections;
};
}
}