2022-02-26 20:32:31 +01:00
|
|
|
#pragma once
|
|
|
|
|
2022-09-27 18:06:15 +02:00
|
|
|
#include <lvgl/lvgl.h>
|
2022-02-26 20:32:31 +01:00
|
|
|
#include <chrono>
|
|
|
|
#include <cstdint>
|
|
|
|
#include <memory>
|
2023-12-10 18:35:19 +01:00
|
|
|
#include <displayapp/Controllers.h>
|
2022-02-26 20:32:31 +01:00
|
|
|
#include "displayapp/screens/Screen.h"
|
|
|
|
#include "components/datetime/DateTimeController.h"
|
2023-03-16 22:08:51 +01:00
|
|
|
#include "utility/DirtyValue.h"
|
2023-12-10 18:35:19 +01:00
|
|
|
#include "displayapp/Apps.h"
|
2022-02-26 20:32:31 +01:00
|
|
|
|
|
|
|
namespace Pinetime {
|
|
|
|
namespace Controllers {
|
|
|
|
class Settings;
|
2022-04-01 16:22:26 +02:00
|
|
|
class Battery;
|
2022-02-26 20:32:31 +01:00
|
|
|
class Ble;
|
|
|
|
class NotificationManager;
|
|
|
|
class MotionController;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace Applications {
|
|
|
|
namespace Screens {
|
|
|
|
|
|
|
|
class WatchFaceInfineat : public Screen {
|
|
|
|
public:
|
2023-01-26 11:50:45 +02:00
|
|
|
static constexpr int nLines = 9;
|
2023-02-22 22:36:38 +02:00
|
|
|
WatchFaceInfineat(Controllers::DateTime& dateTimeController,
|
2023-02-23 22:16:44 +02:00
|
|
|
const Controllers::Battery& batteryController,
|
2023-02-23 22:24:07 +02:00
|
|
|
const Controllers::Ble& bleController,
|
2022-02-26 20:32:31 +01:00
|
|
|
Controllers::NotificationManager& notificationManager,
|
|
|
|
Controllers::Settings& settingsController,
|
2022-09-11 16:22:28 +02:00
|
|
|
Controllers::MotionController& motionController,
|
|
|
|
Controllers::FS& fs);
|
2022-02-26 20:32:31 +01:00
|
|
|
|
|
|
|
~WatchFaceInfineat() override;
|
|
|
|
|
|
|
|
bool OnTouchEvent(TouchEvents event) override;
|
|
|
|
bool OnButtonPushed() override;
|
2022-09-11 20:18:01 +02:00
|
|
|
void UpdateSelected(lv_obj_t* object, lv_event_t event);
|
2022-02-26 20:32:31 +01:00
|
|
|
void CloseMenu();
|
|
|
|
|
|
|
|
void Refresh() override;
|
|
|
|
|
2022-10-11 21:36:31 +02:00
|
|
|
static bool IsAvailable(Pinetime::Controllers::FS& filesystem);
|
|
|
|
|
2022-02-26 20:32:31 +01:00
|
|
|
private:
|
|
|
|
uint32_t savedTick = 0;
|
2022-09-11 20:18:01 +02:00
|
|
|
uint8_t chargingBatteryPercent = 101; // not a mistake ;)
|
2022-02-26 20:32:31 +01:00
|
|
|
|
2023-03-16 22:08:51 +01:00
|
|
|
Utility::DirtyValue<uint8_t> batteryPercentRemaining {};
|
|
|
|
Utility::DirtyValue<bool> isCharging {};
|
|
|
|
Utility::DirtyValue<bool> bleState {};
|
|
|
|
Utility::DirtyValue<bool> bleRadioEnabled {};
|
2023-03-03 13:03:00 +02:00
|
|
|
Utility::DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::minutes>> currentDateTime {};
|
2023-03-16 22:08:51 +01:00
|
|
|
Utility::DirtyValue<uint32_t> stepCount {};
|
|
|
|
Utility::DirtyValue<bool> notificationState {};
|
2023-03-03 13:03:00 +02:00
|
|
|
using days = std::chrono::duration<int32_t, std::ratio<86400>>; // TODO: days is standard in c++20
|
|
|
|
Utility::DirtyValue<std::chrono::time_point<std::chrono::system_clock, days>> currentDate;
|
2022-02-26 20:32:31 +01:00
|
|
|
|
|
|
|
// Lines making up the side cover
|
2022-04-01 16:22:26 +02:00
|
|
|
lv_obj_t* lineBattery;
|
2022-02-26 20:32:31 +01:00
|
|
|
|
2022-04-01 16:22:26 +02:00
|
|
|
lv_point_t lineBatteryPoints[2];
|
2022-02-26 20:32:31 +01:00
|
|
|
|
|
|
|
lv_obj_t* logoPine;
|
|
|
|
|
2022-03-03 22:22:33 +01:00
|
|
|
lv_obj_t* timeContainer;
|
2022-02-26 20:32:31 +01:00
|
|
|
lv_obj_t* labelHour;
|
|
|
|
lv_obj_t* labelMinutes;
|
|
|
|
lv_obj_t* labelTimeAmPm;
|
2022-03-21 10:34:35 +01:00
|
|
|
lv_obj_t* dateContainer;
|
2022-09-11 16:22:28 +02:00
|
|
|
lv_obj_t* labelDate;
|
2022-02-26 20:32:31 +01:00
|
|
|
lv_obj_t* bleIcon;
|
|
|
|
lv_obj_t* stepIcon;
|
|
|
|
lv_obj_t* stepValue;
|
|
|
|
lv_obj_t* notificationIcon;
|
|
|
|
lv_obj_t* btnClose;
|
|
|
|
lv_obj_t* btnNextColor;
|
|
|
|
lv_obj_t* btnToggleCover;
|
|
|
|
lv_obj_t* btnPrevColor;
|
|
|
|
lv_obj_t* btnSettings;
|
|
|
|
lv_obj_t* labelBtnSettings;
|
2022-10-06 15:00:35 +02:00
|
|
|
lv_obj_t* lblToggle;
|
2022-02-26 20:32:31 +01:00
|
|
|
|
2023-01-21 12:31:39 +02:00
|
|
|
lv_obj_t* lines[nLines];
|
|
|
|
|
2022-02-26 20:32:31 +01:00
|
|
|
Controllers::DateTime& dateTimeController;
|
2023-02-23 22:16:44 +02:00
|
|
|
const Controllers::Battery& batteryController;
|
2023-02-23 22:24:07 +02:00
|
|
|
const Controllers::Ble& bleController;
|
2022-02-26 20:32:31 +01:00
|
|
|
Controllers::NotificationManager& notificationManager;
|
|
|
|
Controllers::Settings& settingsController;
|
|
|
|
Controllers::MotionController& motionController;
|
|
|
|
|
2022-04-01 16:22:26 +02:00
|
|
|
void SetBatteryLevel(uint8_t batteryPercent);
|
2022-05-21 14:04:49 +02:00
|
|
|
void ToggleBatteryIndicatorColor(bool showSideCover);
|
2022-04-01 16:22:26 +02:00
|
|
|
|
2022-02-26 20:32:31 +01:00
|
|
|
lv_task_t* taskRefresh;
|
2022-09-11 16:22:28 +02:00
|
|
|
lv_font_t* font_teko = nullptr;
|
|
|
|
lv_font_t* font_bebas = nullptr;
|
2022-02-26 20:32:31 +01:00
|
|
|
};
|
|
|
|
}
|
2023-12-10 18:35:19 +01:00
|
|
|
|
|
|
|
template <>
|
|
|
|
struct WatchFaceTraits<WatchFace::Infineat> {
|
|
|
|
static constexpr WatchFace watchFace = WatchFace::Infineat;
|
|
|
|
static constexpr const char* name = "Infineat face";
|
|
|
|
|
|
|
|
static Screens::Screen* Create(AppControllers& controllers) {
|
|
|
|
return new Screens::WatchFaceInfineat(controllers.dateTimeController,
|
|
|
|
controllers.batteryController,
|
|
|
|
controllers.bleController,
|
|
|
|
controllers.notificationManager,
|
|
|
|
controllers.settingsController,
|
|
|
|
controllers.motionController,
|
|
|
|
controllers.filesystem);
|
|
|
|
};
|
|
|
|
|
|
|
|
static bool IsAvailable(Pinetime::Controllers::FS& filesystem) {
|
|
|
|
return Screens::WatchFaceInfineat::IsAvailable(filesystem);
|
|
|
|
}
|
|
|
|
};
|
2022-02-26 20:32:31 +01:00
|
|
|
}
|
|
|
|
}
|