2019-12-05 15:19:47 -05:00
|
|
|
#pragma once
|
|
|
|
#include <FreeRTOS.h>
|
2020-11-15 10:49:36 -05:00
|
|
|
#include <date/date.h>
|
2019-12-26 12:33:40 -05:00
|
|
|
#include <queue.h>
|
2020-11-15 10:49:36 -05:00
|
|
|
#include <task.h>
|
|
|
|
#include <memory>
|
|
|
|
#include "Apps.h"
|
|
|
|
#include "LittleVgl.h"
|
|
|
|
#include "TouchEvents.h"
|
2020-10-02 15:16:48 -04:00
|
|
|
#include "components/brightness/BrightnessController.h"
|
|
|
|
#include "components/firmwarevalidator/FirmwareValidator.h"
|
2021-02-24 14:40:24 -05:00
|
|
|
#include "components/settings/Settings.h"
|
2021-02-01 07:14:49 -05:00
|
|
|
#include "displayapp/screens/Screen.h"
|
2019-12-05 15:19:47 -05:00
|
|
|
|
2021-02-24 14:40:24 -05:00
|
|
|
|
2019-12-05 15:19:47 -05:00
|
|
|
namespace Pinetime {
|
2020-11-15 10:49:36 -05:00
|
|
|
|
|
|
|
namespace Drivers {
|
|
|
|
class St7789;
|
|
|
|
class Cst816S;
|
|
|
|
class WatchdogView;
|
|
|
|
}
|
|
|
|
namespace Controllers {
|
2021-02-24 14:40:24 -05:00
|
|
|
class Settings;
|
2020-11-15 10:49:36 -05:00
|
|
|
class Battery;
|
|
|
|
class Ble;
|
|
|
|
class DateTime;
|
|
|
|
class NotificationManager;
|
2021-01-10 11:57:26 -05:00
|
|
|
class HeartRateController;
|
2020-11-15 10:49:36 -05:00
|
|
|
}
|
|
|
|
|
2020-02-23 07:44:39 -05:00
|
|
|
namespace System {
|
|
|
|
class SystemTask;
|
|
|
|
};
|
2019-12-05 15:19:47 -05:00
|
|
|
namespace Applications {
|
|
|
|
class DisplayApp {
|
|
|
|
public:
|
2019-12-26 12:33:40 -05:00
|
|
|
enum class States {Idle, Running};
|
2020-08-17 10:31:00 -04:00
|
|
|
enum class Messages : uint8_t {GoToSleep, GoToRunning, UpdateDateTime, UpdateBleConnection, UpdateBatteryLevel, TouchEvent, ButtonPushed,
|
|
|
|
NewNotification, BleFirmwareUpdateStarted };
|
2020-03-22 07:03:17 -04:00
|
|
|
|
2020-08-17 10:31:00 -04:00
|
|
|
enum class FullRefreshDirections { None, Up, Down };
|
2020-08-20 15:09:45 -04:00
|
|
|
enum class TouchModes { Gestures, Polling };
|
2020-03-15 16:01:24 -04:00
|
|
|
|
2020-03-28 14:05:28 -04: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,
|
2021-01-10 11:57:26 -05:00
|
|
|
Pinetime::Controllers::NotificationManager& notificationManager,
|
2021-02-24 14:40:24 -05:00
|
|
|
Pinetime::Controllers::HeartRateController& heartRateController,
|
|
|
|
Controllers::Settings &settingsController
|
|
|
|
);
|
2019-12-05 15:19:47 -05:00
|
|
|
void Start();
|
2019-12-26 12:33:40 -05:00
|
|
|
void PushMessage(Messages msg);
|
|
|
|
|
2020-02-23 07:44:39 -05:00
|
|
|
void StartApp(Apps app);
|
|
|
|
|
2020-03-22 07:03:17 -04:00
|
|
|
void SetFullRefresh(FullRefreshDirections direction);
|
2020-08-20 15:09:45 -04:00
|
|
|
void SetTouchMode(TouchModes mode);
|
|
|
|
|
2019-12-05 15:19:47 -05:00
|
|
|
private:
|
|
|
|
TaskHandle_t taskHandle;
|
|
|
|
static void Process(void* instance);
|
2019-12-07 11:11:50 -05:00
|
|
|
void InitHw();
|
2020-01-26 07:37:10 -05:00
|
|
|
Pinetime::Drivers::St7789& lcd;
|
2020-03-08 16:38:11 -04:00
|
|
|
Pinetime::Components::LittleVgl& lvgl;
|
2019-12-07 13:15:33 -05:00
|
|
|
void Refresh();
|
|
|
|
|
2019-12-26 12:33:40 -05: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 10:05:35 -05:00
|
|
|
Pinetime::Controllers::Battery &batteryController;
|
2019-12-27 11:05:49 -05:00
|
|
|
Pinetime::Controllers::Ble &bleController;
|
2019-12-28 08:34:50 -05:00
|
|
|
Pinetime::Controllers::DateTime& dateTimeController;
|
2020-03-22 07:03:17 -04:00
|
|
|
Pinetime::Drivers::WatchdogView& watchdog;
|
2019-12-27 10:05:35 -05:00
|
|
|
|
2020-01-26 07:37:10 -05:00
|
|
|
Pinetime::Drivers::Cst816S& touchPanel;
|
2020-03-09 16:29:12 -04:00
|
|
|
TouchEvents OnTouchEvent();
|
2020-01-18 12:17:52 -05:00
|
|
|
|
2020-02-16 12:32:36 -05:00
|
|
|
std::unique_ptr<Screens::Screen> currentScreen;
|
|
|
|
|
|
|
|
bool isClock = true;
|
2020-02-23 07:44:39 -05:00
|
|
|
|
|
|
|
Pinetime::System::SystemTask& systemTask;
|
|
|
|
Apps nextApp = Apps::None;
|
2020-03-09 16:29:12 -04: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 13:03:11 -04:00
|
|
|
Controllers::BrightnessController brightnessController;
|
2020-03-28 14:05:28 -04:00
|
|
|
Pinetime::Controllers::NotificationManager& notificationManager;
|
2020-08-11 11:50:00 -04:00
|
|
|
Pinetime::Controllers::FirmwareValidator validator;
|
2020-08-20 15:09:45 -04:00
|
|
|
TouchModes touchMode = TouchModes::Gestures;
|
2021-01-10 11:57:26 -05:00
|
|
|
Pinetime::Controllers::HeartRateController& heartRateController;
|
2021-02-24 14:40:24 -05:00
|
|
|
Pinetime::Controllers::Settings& settingsController;
|
2019-12-05 15:19:47 -05:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|