2019-12-05 21:19:47 +01:00
|
|
|
#pragma once
|
|
|
|
#include <FreeRTOS.h>
|
|
|
|
#include <task.h>
|
2019-12-07 17:11:50 +01:00
|
|
|
#include <drivers/St7789.h>
|
|
|
|
#include <drivers/SpiMaster.h>
|
|
|
|
#include <bits/unique_ptr.h>
|
2019-12-26 18:33:40 +01:00
|
|
|
#include <queue.h>
|
2020-10-02 21:16:48 +02:00
|
|
|
#include "components/gfx/Gfx.h"
|
|
|
|
#include "components/battery/BatteryController.h"
|
|
|
|
#include "components/brightness/BrightnessController.h"
|
|
|
|
#include "components/ble/BleController.h"
|
|
|
|
#include "components/datetime/DateTimeController.h"
|
|
|
|
#include "components/ble/NotificationManager.h"
|
|
|
|
#include "components/firmwarevalidator/FirmwareValidator.h"
|
|
|
|
#include "drivers/Cst816s.h"
|
2020-02-10 21:05:33 +01:00
|
|
|
#include "LittleVgl.h"
|
2020-01-11 17:14:12 +01:00
|
|
|
#include <date/date.h>
|
2020-10-02 21:16:48 +02:00
|
|
|
#include "displayapp/screens/Clock.h"
|
|
|
|
#include "displayapp/screens/Modal.h"
|
2020-03-22 12:03:17 +01:00
|
|
|
#include <drivers/Watchdog.h>
|
2020-03-15 21:01:24 +01:00
|
|
|
#include "TouchEvents.h"
|
2020-08-14 09:46:37 +02:00
|
|
|
#include "Apps.h"
|
2019-12-07 17:11:50 +01:00
|
|
|
|
2019-12-05 21:19:47 +01:00
|
|
|
|
|
|
|
namespace Pinetime {
|
2020-02-23 13:44:39 +01:00
|
|
|
namespace System {
|
|
|
|
class SystemTask;
|
|
|
|
};
|
2019-12-05 21:19:47 +01:00
|
|
|
namespace Applications {
|
|
|
|
class DisplayApp {
|
|
|
|
public:
|
2019-12-26 18:33:40 +01:00
|
|
|
enum class States {Idle, Running};
|
2020-08-17 16:31:00 +02:00
|
|
|
enum class Messages : uint8_t {GoToSleep, GoToRunning, UpdateDateTime, UpdateBleConnection, UpdateBatteryLevel, TouchEvent, ButtonPushed,
|
|
|
|
NewNotification, BleFirmwareUpdateStarted };
|
2020-03-22 12:03:17 +01:00
|
|
|
|
2020-08-17 16:31:00 +02:00
|
|
|
enum class FullRefreshDirections { None, Up, Down };
|
2020-08-20 21:09:45 +02:00
|
|
|
enum class TouchModes { Gestures, Polling };
|
2020-03-15 21:01:24 +01:00
|
|
|
|
2020-03-28 19:05:28 +01:00
|
|
|
DisplayApp(Drivers::St7789 &lcd, Components::LittleVgl &lvgl, Drivers::Cst816S &,
|
|
|
|
Controllers::Battery &batteryController, Controllers::Ble &bleController,
|
|
|
|
Controllers::DateTime &dateTimeController, Drivers::WatchdogView &watchdog,
|
|
|
|
System::SystemTask &systemTask,
|
|
|
|
Pinetime::Controllers::NotificationManager& notificationManager);
|
2019-12-05 21:19:47 +01:00
|
|
|
void Start();
|
2019-12-26 18:33:40 +01:00
|
|
|
void PushMessage(Messages msg);
|
|
|
|
|
2020-02-23 13:44:39 +01:00
|
|
|
void StartApp(Apps app);
|
|
|
|
|
2020-03-22 12:03:17 +01:00
|
|
|
void SetFullRefresh(FullRefreshDirections direction);
|
2020-08-20 21:09:45 +02:00
|
|
|
void SetTouchMode(TouchModes mode);
|
|
|
|
|
2019-12-05 21:19:47 +01:00
|
|
|
private:
|
|
|
|
TaskHandle_t taskHandle;
|
|
|
|
static void Process(void* instance);
|
2019-12-07 17:11:50 +01:00
|
|
|
void InitHw();
|
2020-01-26 13:37:10 +01:00
|
|
|
Pinetime::Drivers::St7789& lcd;
|
2020-03-08 21:38:11 +01:00
|
|
|
Pinetime::Components::LittleVgl& lvgl;
|
2019-12-07 19:15:33 +01:00
|
|
|
void Refresh();
|
|
|
|
|
2019-12-26 18:33:40 +01:00
|
|
|
States state = States::Running;
|
|
|
|
void RunningState();
|
|
|
|
void IdleState();
|
|
|
|
QueueHandle_t msgQueue;
|
|
|
|
|
|
|
|
static constexpr uint8_t queueSize = 10;
|
|
|
|
static constexpr uint8_t itemSize = 1;
|
|
|
|
|
2019-12-27 16:05:35 +01:00
|
|
|
Pinetime::Controllers::Battery &batteryController;
|
2019-12-27 17:05:49 +01:00
|
|
|
Pinetime::Controllers::Ble &bleController;
|
2019-12-28 14:34:50 +01:00
|
|
|
Pinetime::Controllers::DateTime& dateTimeController;
|
2020-03-22 12:03:17 +01:00
|
|
|
Pinetime::Drivers::WatchdogView& watchdog;
|
2019-12-27 16:05:35 +01:00
|
|
|
|
2020-01-26 13:37:10 +01:00
|
|
|
Pinetime::Drivers::Cst816S& touchPanel;
|
2020-03-09 21:29:12 +01:00
|
|
|
TouchEvents OnTouchEvent();
|
2020-01-18 18:17:52 +01:00
|
|
|
|
2020-02-16 18:32:36 +01:00
|
|
|
std::unique_ptr<Screens::Screen> currentScreen;
|
|
|
|
|
|
|
|
bool isClock = true;
|
2020-02-23 13:44:39 +01:00
|
|
|
|
|
|
|
Pinetime::System::SystemTask& systemTask;
|
|
|
|
Apps nextApp = Apps::None;
|
2020-03-09 21:29:12 +01:00
|
|
|
bool onClockApp = false; // TODO find a better way to know that we should handle gestures and button differently for the Clock app.
|
2020-03-15 18:03:11 +01:00
|
|
|
Controllers::BrightnessController brightnessController;
|
2020-03-25 21:23:40 +01:00
|
|
|
std::unique_ptr<Screens::Modal> modal;
|
2020-03-28 19:05:28 +01:00
|
|
|
Pinetime::Controllers::NotificationManager& notificationManager;
|
2020-08-11 17:50:00 +02:00
|
|
|
Pinetime::Controllers::FirmwareValidator validator;
|
2020-08-20 21:09:45 +02:00
|
|
|
TouchModes touchMode = TouchModes::Gestures;
|
2019-12-05 21:19:47 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|