2019-12-05 21:19:47 +01:00
|
|
|
#pragma once
|
|
|
|
#include <FreeRTOS.h>
|
2020-11-15 16:49:36 +01:00
|
|
|
#include <date/date.h>
|
2019-12-26 18:33:40 +01:00
|
|
|
#include <queue.h>
|
2020-11-15 16:49:36 +01:00
|
|
|
#include <task.h>
|
|
|
|
#include <memory>
|
2021-06-06 15:56:03 +02:00
|
|
|
#include <systemtask/Messages.h>
|
2020-11-15 16:49:36 +01:00
|
|
|
#include "Apps.h"
|
|
|
|
#include "LittleVgl.h"
|
|
|
|
#include "TouchEvents.h"
|
2020-10-02 21:16:48 +02:00
|
|
|
#include "components/brightness/BrightnessController.h"
|
2021-04-20 13:31:40 +02:00
|
|
|
#include "components/motor/MotorController.h"
|
2020-10-02 21:16:48 +02:00
|
|
|
#include "components/firmwarevalidator/FirmwareValidator.h"
|
2021-02-24 20:40:24 +01:00
|
|
|
#include "components/settings/Settings.h"
|
2021-02-01 13:14:49 +01:00
|
|
|
#include "displayapp/screens/Screen.h"
|
2021-05-20 20:43:54 +02:00
|
|
|
#include "components/timer/TimerController.h"
|
2021-01-26 20:31:45 +01:00
|
|
|
#include "Messages.h"
|
2019-12-05 21:19:47 +01:00
|
|
|
|
|
|
|
namespace Pinetime {
|
2020-11-15 16:49:36 +01:00
|
|
|
|
|
|
|
namespace Drivers {
|
|
|
|
class St7789;
|
|
|
|
class Cst816S;
|
|
|
|
class WatchdogView;
|
|
|
|
}
|
|
|
|
namespace Controllers {
|
2021-02-24 20:40:24 +01:00
|
|
|
class Settings;
|
2020-11-15 16:49:36 +01:00
|
|
|
class Battery;
|
|
|
|
class Ble;
|
|
|
|
class DateTime;
|
|
|
|
class NotificationManager;
|
2021-01-10 17:57:26 +01:00
|
|
|
class HeartRateController;
|
2021-03-31 19:47:27 +02:00
|
|
|
class MotionController;
|
2020-11-15 16:49:36 +01:00
|
|
|
}
|
|
|
|
|
2020-02-23 13:44:39 +01:00
|
|
|
namespace System {
|
|
|
|
class SystemTask;
|
|
|
|
};
|
2019-12-05 21:19:47 +01:00
|
|
|
namespace Applications {
|
|
|
|
class DisplayApp {
|
2021-04-24 11:00:45 +02:00
|
|
|
public:
|
2021-04-18 19:28:14 +02:00
|
|
|
enum class States { Idle, Running };
|
|
|
|
enum class FullRefreshDirections { None, Up, Down, Left, Right, LeftAnim, RightAnim };
|
|
|
|
enum class TouchModes { Gestures, Polling };
|
|
|
|
|
|
|
|
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 13:31:40 +02:00
|
|
|
Pinetime::Controllers::MotorController& motorController,
|
2021-05-20 20:43:54 +02:00
|
|
|
Pinetime::Controllers::MotionController& motionController,
|
|
|
|
Pinetime::Controllers::TimerController& timerController);
|
2021-04-18 19:28:14 +02:00
|
|
|
void Start();
|
|
|
|
void PushMessage(Display::Messages msg);
|
|
|
|
|
|
|
|
void StartApp(Apps app, DisplayApp::FullRefreshDirections direction);
|
|
|
|
|
|
|
|
void SetFullRefresh(FullRefreshDirections direction);
|
|
|
|
void SetTouchMode(TouchModes mode);
|
|
|
|
|
2021-06-06 15:56:03 +02:00
|
|
|
void Register(Pinetime::System::SystemTask* systemTask);
|
|
|
|
|
2021-04-24 11:00:45 +02:00
|
|
|
private:
|
2021-04-18 19:28:14 +02:00
|
|
|
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;
|
2021-06-06 15:56:03 +02:00
|
|
|
Pinetime::System::SystemTask* systemTask = nullptr;
|
2021-04-18 19:28:14 +02:00
|
|
|
Pinetime::Controllers::NotificationManager& notificationManager;
|
|
|
|
Pinetime::Controllers::HeartRateController& heartRateController;
|
|
|
|
Pinetime::Controllers::Settings& settingsController;
|
2021-04-20 13:31:40 +02:00
|
|
|
Pinetime::Controllers::MotorController& motorController;
|
2021-04-18 19:28:14 +02:00
|
|
|
Pinetime::Controllers::MotionController& motionController;
|
2021-05-20 20:43:54 +02:00
|
|
|
Pinetime::Controllers::TimerController& timerController;
|
2021-04-18 19:28:14 +02:00
|
|
|
|
|
|
|
Pinetime::Controllers::FirmwareValidator validator;
|
|
|
|
Controllers::BrightnessController brightnessController;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
TouchModes touchMode = TouchModes::Gestures;
|
|
|
|
|
|
|
|
TouchEvents OnTouchEvent();
|
|
|
|
void RunningState();
|
|
|
|
void IdleState();
|
|
|
|
static void Process(void* instance);
|
|
|
|
void InitHw();
|
|
|
|
void Refresh();
|
2021-05-14 11:46:51 +02:00
|
|
|
void ReturnApp(Apps app, DisplayApp::FullRefreshDirections direction, TouchEvents touchEvent);
|
2021-04-18 19:28:14 +02:00
|
|
|
void LoadApp(Apps app, DisplayApp::FullRefreshDirections direction);
|
2021-06-06 15:56:03 +02:00
|
|
|
void PushMessageToSystemTask(Pinetime::System::Messages message);
|
2021-06-10 21:19:11 +02:00
|
|
|
|
|
|
|
Apps nextApp = Apps::None;
|
|
|
|
DisplayApp::FullRefreshDirections nextDirection;
|
2021-07-13 20:42:59 +02:00
|
|
|
TickType_t lastWakeTime;
|
2019-12-05 21:19:47 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|