2019-12-05 20:19:47 +00:00
|
|
|
#pragma once
|
|
|
|
#include <FreeRTOS.h>
|
|
|
|
#include <task.h>
|
2019-12-07 16:11:50 +00:00
|
|
|
#include <drivers/St7789.h>
|
|
|
|
#include <drivers/SpiMaster.h>
|
|
|
|
#include <Components/Gfx/Gfx.h>
|
|
|
|
#include <bits/unique_ptr.h>
|
2019-12-26 17:33:40 +00:00
|
|
|
#include <queue.h>
|
2019-12-27 15:05:35 +00:00
|
|
|
#include <Components/Battery/BatteryController.h>
|
2019-12-27 16:05:49 +00:00
|
|
|
#include <Components/Ble/BleController.h>
|
2019-12-28 13:34:50 +00:00
|
|
|
#include <Components/DateTime/DateTimeController.h>
|
2020-01-18 17:17:52 +00:00
|
|
|
#include "Fonts/lcdfont14.h"
|
2020-01-03 15:32:31 +00:00
|
|
|
#include "../drivers/Cst816s.h"
|
2020-02-10 20:05:33 +00:00
|
|
|
#include "LittleVgl.h"
|
2020-01-11 16:14:12 +00:00
|
|
|
#include <date/date.h>
|
2020-01-18 17:17:52 +00:00
|
|
|
#include <DisplayApp/Screens/Clock.h>
|
2019-12-07 16:11:50 +00:00
|
|
|
|
2019-12-05 20:19:47 +00:00
|
|
|
|
|
|
|
namespace Pinetime {
|
2020-02-23 12:44:39 +00:00
|
|
|
namespace System {
|
|
|
|
class SystemTask;
|
|
|
|
};
|
2019-12-05 20:19:47 +00:00
|
|
|
namespace Applications {
|
|
|
|
class DisplayApp {
|
|
|
|
public:
|
2019-12-26 17:33:40 +00:00
|
|
|
enum class States {Idle, Running};
|
2020-02-16 17:32:36 +00:00
|
|
|
enum class Messages : uint8_t {GoToSleep, GoToRunning, UpdateDateTime, UpdateBleConnection, UpdateBatteryLevel, TouchEvent, SwitchScreen,ButtonPushed} ;
|
2020-03-09 20:29:12 +00:00
|
|
|
enum class TouchEvents { None, Tap, SwipeLeft, SwipeRight, SwipeUp, SwipeDown, LongTap, DoubleTap
|
|
|
|
};
|
2020-01-26 12:37:10 +00:00
|
|
|
DisplayApp(Pinetime::Drivers::St7789& lcd,
|
2020-02-10 20:05:33 +00:00
|
|
|
Pinetime::Components::LittleVgl& lvgl,
|
2020-01-26 12:37:10 +00:00
|
|
|
Pinetime::Drivers::Cst816S&,
|
|
|
|
Controllers::Battery &batteryController,
|
2019-12-28 13:34:50 +00:00
|
|
|
Controllers::Ble &bleController,
|
2020-02-23 12:44:39 +00:00
|
|
|
Controllers::DateTime& dateTimeController,
|
|
|
|
Pinetime::System::SystemTask& systemTask);
|
2019-12-05 20:19:47 +00:00
|
|
|
void Start();
|
2019-12-26 17:33:40 +00:00
|
|
|
void PushMessage(Messages msg);
|
|
|
|
|
2020-02-26 19:49:26 +00:00
|
|
|
enum class Apps {None, Launcher, Clock, Test, Meter, Gauge};
|
2020-02-23 12:44:39 +00:00
|
|
|
void StartApp(Apps app);
|
|
|
|
|
2019-12-05 20:19:47 +00:00
|
|
|
private:
|
|
|
|
TaskHandle_t taskHandle;
|
|
|
|
static void Process(void* instance);
|
2019-12-07 16:11:50 +00:00
|
|
|
void InitHw();
|
2020-01-26 12:37:10 +00:00
|
|
|
Pinetime::Drivers::St7789& lcd;
|
2020-03-08 20:38:11 +00:00
|
|
|
Pinetime::Components::LittleVgl& lvgl;
|
2019-12-07 18:15:33 +00:00
|
|
|
void Refresh();
|
|
|
|
|
2019-12-26 17:33:40 +00: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 15:05:35 +00:00
|
|
|
Pinetime::Controllers::Battery &batteryController;
|
2019-12-27 16:05:49 +00:00
|
|
|
Pinetime::Controllers::Ble &bleController;
|
2019-12-28 13:34:50 +00:00
|
|
|
Pinetime::Controllers::DateTime& dateTimeController;
|
2019-12-27 15:05:35 +00:00
|
|
|
|
2020-01-26 12:37:10 +00:00
|
|
|
Pinetime::Drivers::Cst816S& touchPanel;
|
2020-03-09 20:29:12 +00:00
|
|
|
TouchEvents OnTouchEvent();
|
2020-01-18 17:17:52 +00:00
|
|
|
|
2020-02-16 17:32:36 +00:00
|
|
|
std::unique_ptr<Screens::Screen> currentScreen;
|
2020-01-18 19:53:32 +00:00
|
|
|
static constexpr uint8_t pinLcdBacklight1 = 14;
|
|
|
|
static constexpr uint8_t pinLcdBacklight2 = 22;
|
|
|
|
static constexpr uint8_t pinLcdBacklight3 = 23;
|
2020-02-16 17:32:36 +00:00
|
|
|
|
|
|
|
bool isClock = true;
|
2020-02-23 12:44:39 +00:00
|
|
|
|
|
|
|
Pinetime::System::SystemTask& systemTask;
|
|
|
|
Apps nextApp = Apps::None;
|
2020-03-09 20:29:12 +00:00
|
|
|
bool onClockApp = false; // TODO find a better way to know that we should handle gestures and button differently for the Clock app.
|
2019-12-05 20:19:47 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|