mirror of
https://github.com/InfiniTimeOrg/InfiniTime.git
synced 2024-10-22 23:21:53 +02:00
Compare commits
10 commits
11db2f53c6
...
6287d61ac8
Author | SHA1 | Date | |
---|---|---|---|
6287d61ac8 | |||
a2356f2f4a | |||
3db4e012ce | |||
a0cd439efc | |||
241e4ef63c | |||
7c4fc1069b | |||
49b00d219f | |||
814449405f | |||
ffda367917 | |||
f5963a8db8 |
|
@ -19,11 +19,13 @@
|
||||||
#include "systemtask/SystemTask.h"
|
#include "systemtask/SystemTask.h"
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include <libraries/log/nrf_log.h>
|
||||||
|
|
||||||
using namespace Pinetime::Controllers;
|
using namespace Pinetime::Controllers;
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
AlarmController::AlarmController(Controllers::DateTime& dateTimeController) : dateTimeController {dateTimeController} {
|
AlarmController::AlarmController(Controllers::DateTime& dateTimeController, Controllers::FS& fs)
|
||||||
|
: dateTimeController {dateTimeController}, fs {fs} {
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -36,11 +38,28 @@ namespace {
|
||||||
void AlarmController::Init(System::SystemTask* systemTask) {
|
void AlarmController::Init(System::SystemTask* systemTask) {
|
||||||
this->systemTask = systemTask;
|
this->systemTask = systemTask;
|
||||||
alarmTimer = xTimerCreate("Alarm", 1, pdFALSE, this, SetOffAlarm);
|
alarmTimer = xTimerCreate("Alarm", 1, pdFALSE, this, SetOffAlarm);
|
||||||
|
LoadSettingsFromFile();
|
||||||
|
if (alarm.isEnabled) {
|
||||||
|
NRF_LOG_INFO("[AlarmController] Loaded alarm was enabled, scheduling");
|
||||||
|
ScheduleAlarm();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AlarmController::SaveAlarm() {
|
||||||
|
// verify if it is necessary to save
|
||||||
|
if (alarmChanged) {
|
||||||
|
SaveSettingsToFile();
|
||||||
|
}
|
||||||
|
alarmChanged = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AlarmController::SetAlarmTime(uint8_t alarmHr, uint8_t alarmMin) {
|
void AlarmController::SetAlarmTime(uint8_t alarmHr, uint8_t alarmMin) {
|
||||||
hours = alarmHr;
|
if (alarm.hours == alarmHr && alarm.minutes == alarmMin) {
|
||||||
minutes = alarmMin;
|
return;
|
||||||
|
}
|
||||||
|
alarm.hours = alarmHr;
|
||||||
|
alarm.minutes = alarmMin;
|
||||||
|
alarmChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AlarmController::ScheduleAlarm() {
|
void AlarmController::ScheduleAlarm() {
|
||||||
|
@ -53,18 +72,19 @@ void AlarmController::ScheduleAlarm() {
|
||||||
tm* tmAlarmTime = std::localtime(&ttAlarmTime);
|
tm* tmAlarmTime = std::localtime(&ttAlarmTime);
|
||||||
|
|
||||||
// If the time being set has already passed today,the alarm should be set for tomorrow
|
// If the time being set has already passed today,the alarm should be set for tomorrow
|
||||||
if (hours < dateTimeController.Hours() || (hours == dateTimeController.Hours() && minutes <= dateTimeController.Minutes())) {
|
if (alarm.hours < dateTimeController.Hours() ||
|
||||||
|
(alarm.hours == dateTimeController.Hours() && alarm.minutes <= dateTimeController.Minutes())) {
|
||||||
tmAlarmTime->tm_mday += 1;
|
tmAlarmTime->tm_mday += 1;
|
||||||
// tm_wday doesn't update automatically
|
// tm_wday doesn't update automatically
|
||||||
tmAlarmTime->tm_wday = (tmAlarmTime->tm_wday + 1) % 7;
|
tmAlarmTime->tm_wday = (tmAlarmTime->tm_wday + 1) % 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmAlarmTime->tm_hour = hours;
|
tmAlarmTime->tm_hour = alarm.hours;
|
||||||
tmAlarmTime->tm_min = minutes;
|
tmAlarmTime->tm_min = alarm.minutes;
|
||||||
tmAlarmTime->tm_sec = 0;
|
tmAlarmTime->tm_sec = 0;
|
||||||
|
|
||||||
// if alarm is in weekday-only mode, make sure it shifts to the next weekday
|
// if alarm is in weekday-only mode, make sure it shifts to the next weekday
|
||||||
if (recurrence == RecurType::Weekdays) {
|
if (alarm.recurrence == RecurType::Weekdays) {
|
||||||
if (tmAlarmTime->tm_wday == 0) { // Sunday, shift 1 day
|
if (tmAlarmTime->tm_wday == 0) { // Sunday, shift 1 day
|
||||||
tmAlarmTime->tm_mday += 1;
|
tmAlarmTime->tm_mday += 1;
|
||||||
} else if (tmAlarmTime->tm_wday == 6) { // Saturday, shift 2 days
|
} else if (tmAlarmTime->tm_wday == 6) { // Saturday, shift 2 days
|
||||||
|
@ -79,7 +99,10 @@ void AlarmController::ScheduleAlarm() {
|
||||||
xTimerChangePeriod(alarmTimer, secondsToAlarm * configTICK_RATE_HZ, 0);
|
xTimerChangePeriod(alarmTimer, secondsToAlarm * configTICK_RATE_HZ, 0);
|
||||||
xTimerStart(alarmTimer, 0);
|
xTimerStart(alarmTimer, 0);
|
||||||
|
|
||||||
state = AlarmState::Set;
|
if (!alarm.isEnabled) {
|
||||||
|
alarm.isEnabled = true;
|
||||||
|
alarmChanged = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t AlarmController::SecondsToAlarm() const {
|
uint32_t AlarmController::SecondsToAlarm() const {
|
||||||
|
@ -88,20 +111,72 @@ uint32_t AlarmController::SecondsToAlarm() const {
|
||||||
|
|
||||||
void AlarmController::DisableAlarm() {
|
void AlarmController::DisableAlarm() {
|
||||||
xTimerStop(alarmTimer, 0);
|
xTimerStop(alarmTimer, 0);
|
||||||
state = AlarmState::Not_Set;
|
isAlerting = false;
|
||||||
|
if (alarm.isEnabled) {
|
||||||
|
alarm.isEnabled = false;
|
||||||
|
alarmChanged = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AlarmController::SetOffAlarmNow() {
|
void AlarmController::SetOffAlarmNow() {
|
||||||
state = AlarmState::Alerting;
|
isAlerting = true;
|
||||||
systemTask->PushMessage(System::Messages::SetOffAlarm);
|
systemTask->PushMessage(System::Messages::SetOffAlarm);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AlarmController::StopAlerting() {
|
void AlarmController::StopAlerting() {
|
||||||
// Alarm state is off unless this is a recurring alarm
|
isAlerting = false;
|
||||||
if (recurrence == RecurType::None) {
|
// Disable alarm unless it is recurring
|
||||||
state = AlarmState::Not_Set;
|
if (alarm.recurrence == RecurType::None) {
|
||||||
|
alarm.isEnabled = false;
|
||||||
|
alarmChanged = true;
|
||||||
} else {
|
} else {
|
||||||
// set next instance
|
// set next instance
|
||||||
ScheduleAlarm();
|
ScheduleAlarm();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AlarmController::SetRecurrence(RecurType recurrence) {
|
||||||
|
if (alarm.recurrence != recurrence) {
|
||||||
|
alarm.recurrence = recurrence;
|
||||||
|
alarmChanged = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AlarmController::LoadSettingsFromFile() {
|
||||||
|
lfs_file_t alarmFile;
|
||||||
|
AlarmSettings alarmBuffer;
|
||||||
|
|
||||||
|
if (fs.FileOpen(&alarmFile, "/.system/alarm.dat", LFS_O_RDONLY) != LFS_ERR_OK) {
|
||||||
|
NRF_LOG_WARNING("[AlarmController] Failed to open alarm data file");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
fs.FileRead(&alarmFile, reinterpret_cast<uint8_t*>(&alarmBuffer), sizeof(alarmBuffer));
|
||||||
|
fs.FileClose(&alarmFile);
|
||||||
|
if (alarmBuffer.version != alarmFormatVersion) {
|
||||||
|
NRF_LOG_WARNING("[AlarmController] Loaded alarm settings has version %u instead of %u, discarding",
|
||||||
|
alarmBuffer.version,
|
||||||
|
alarmFormatVersion);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
alarm = alarmBuffer;
|
||||||
|
NRF_LOG_INFO("[AlarmController] Loaded alarm settings from file");
|
||||||
|
}
|
||||||
|
|
||||||
|
void AlarmController::SaveSettingsToFile() const {
|
||||||
|
lfs_dir systemDir;
|
||||||
|
if (fs.DirOpen("/.system", &systemDir) != LFS_ERR_OK) {
|
||||||
|
fs.DirCreate("/.system");
|
||||||
|
}
|
||||||
|
fs.DirClose(&systemDir);
|
||||||
|
lfs_file_t alarmFile;
|
||||||
|
if (fs.FileOpen(&alarmFile, "/.system/alarm.dat", LFS_O_WRONLY | LFS_O_CREAT) != LFS_ERR_OK) {
|
||||||
|
NRF_LOG_WARNING("[AlarmController] Failed to open alarm data file for saving");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
fs.FileWrite(&alarmFile, reinterpret_cast<const uint8_t*>(&alarm), sizeof(alarm));
|
||||||
|
fs.FileClose(&alarmFile);
|
||||||
|
NRF_LOG_INFO("[AlarmController] Saved alarm settings with format version %u to file", alarm.version);
|
||||||
|
}
|
||||||
|
|
|
@ -30,47 +30,65 @@ namespace Pinetime {
|
||||||
namespace Controllers {
|
namespace Controllers {
|
||||||
class AlarmController {
|
class AlarmController {
|
||||||
public:
|
public:
|
||||||
AlarmController(Controllers::DateTime& dateTimeController);
|
AlarmController(Controllers::DateTime& dateTimeController, Controllers::FS& fs);
|
||||||
|
|
||||||
void Init(System::SystemTask* systemTask);
|
void Init(System::SystemTask* systemTask);
|
||||||
|
void SaveAlarm();
|
||||||
void SetAlarmTime(uint8_t alarmHr, uint8_t alarmMin);
|
void SetAlarmTime(uint8_t alarmHr, uint8_t alarmMin);
|
||||||
void ScheduleAlarm();
|
void ScheduleAlarm();
|
||||||
void DisableAlarm();
|
void DisableAlarm();
|
||||||
void SetOffAlarmNow();
|
void SetOffAlarmNow();
|
||||||
uint32_t SecondsToAlarm() const;
|
uint32_t SecondsToAlarm() const;
|
||||||
void StopAlerting();
|
void StopAlerting();
|
||||||
enum class AlarmState { Not_Set, Set, Alerting };
|
|
||||||
enum class RecurType { None, Daily, Weekdays };
|
enum class RecurType { None, Daily, Weekdays };
|
||||||
|
|
||||||
uint8_t Hours() const {
|
uint8_t Hours() const {
|
||||||
return hours;
|
return alarm.hours;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t Minutes() const {
|
uint8_t Minutes() const {
|
||||||
return minutes;
|
return alarm.minutes;
|
||||||
}
|
}
|
||||||
|
|
||||||
AlarmState State() const {
|
bool IsAlerting() const {
|
||||||
return state;
|
return isAlerting;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsEnabled() const {
|
||||||
|
return alarm.isEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
RecurType Recurrence() const {
|
RecurType Recurrence() const {
|
||||||
return recurrence;
|
return alarm.recurrence;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetRecurrence(RecurType recurType) {
|
void SetRecurrence(RecurType recurrence);
|
||||||
recurrence = recurType;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Controllers::DateTime& dateTimeController;
|
// Versions 255 is reserved for now, so the version field can be made
|
||||||
System::SystemTask* systemTask = nullptr;
|
// bigger, should it ever be needed.
|
||||||
TimerHandle_t alarmTimer;
|
static constexpr uint8_t alarmFormatVersion = 1;
|
||||||
|
|
||||||
|
struct AlarmSettings {
|
||||||
|
uint8_t version = alarmFormatVersion;
|
||||||
uint8_t hours = 7;
|
uint8_t hours = 7;
|
||||||
uint8_t minutes = 0;
|
uint8_t minutes = 0;
|
||||||
std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> alarmTime;
|
|
||||||
AlarmState state = AlarmState::Not_Set;
|
|
||||||
RecurType recurrence = RecurType::None;
|
RecurType recurrence = RecurType::None;
|
||||||
|
bool isEnabled = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
bool isAlerting = false;
|
||||||
|
bool alarmChanged = false;
|
||||||
|
|
||||||
|
Controllers::DateTime& dateTimeController;
|
||||||
|
Controllers::FS& fs;
|
||||||
|
System::SystemTask* systemTask = nullptr;
|
||||||
|
TimerHandle_t alarmTimer;
|
||||||
|
AlarmSettings alarm;
|
||||||
|
std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> alarmTime;
|
||||||
|
|
||||||
|
void LoadSettingsFromFile();
|
||||||
|
void SaveSettingsToFile() const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
#include "components/ble/MusicService.h"
|
#include "components/ble/MusicService.h"
|
||||||
#include "components/ble/NimbleController.h"
|
#include "components/ble/NimbleController.h"
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <FreeRTOS.h>
|
||||||
|
#include <task.h>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
// 0000yyxx-78fc-48fe-8e23-433b3a1942d0
|
// 0000yyxx-78fc-48fe-8e23-433b3a1942d0
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include <host/ble_uuid.h>
|
#include <host/ble_uuid.h>
|
||||||
#undef max
|
#undef max
|
||||||
#undef min
|
#undef min
|
||||||
|
#include <FreeRTOS.h>
|
||||||
|
|
||||||
namespace Pinetime {
|
namespace Pinetime {
|
||||||
namespace Controllers {
|
namespace Controllers {
|
||||||
|
|
|
@ -582,7 +582,7 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio
|
||||||
currentScreen = std::make_unique<Screens::SettingWakeUp>(settingsController);
|
currentScreen = std::make_unique<Screens::SettingWakeUp>(settingsController);
|
||||||
break;
|
break;
|
||||||
case Apps::SettingDisplay:
|
case Apps::SettingDisplay:
|
||||||
currentScreen = std::make_unique<Screens::SettingDisplay>(this, settingsController);
|
currentScreen = std::make_unique<Screens::SettingDisplay>(settingsController);
|
||||||
break;
|
break;
|
||||||
case Apps::SettingSteps:
|
case Apps::SettingSteps:
|
||||||
currentScreen = std::make_unique<Screens::SettingSteps>(settingsController);
|
currentScreen = std::make_unique<Screens::SettingSteps>(settingsController);
|
||||||
|
|
|
@ -8,6 +8,7 @@ namespace Colors {
|
||||||
static constexpr lv_color_t green = LV_COLOR_MAKE(0x0, 0xb0, 0x0);
|
static constexpr lv_color_t green = LV_COLOR_MAKE(0x0, 0xb0, 0x0);
|
||||||
static constexpr lv_color_t blue = LV_COLOR_MAKE(0x0, 0x50, 0xff);
|
static constexpr lv_color_t blue = LV_COLOR_MAKE(0x0, 0x50, 0xff);
|
||||||
static constexpr lv_color_t lightGray = LV_COLOR_MAKE(0xb0, 0xb0, 0xb0);
|
static constexpr lv_color_t lightGray = LV_COLOR_MAKE(0xb0, 0xb0, 0xb0);
|
||||||
|
static constexpr lv_color_t gray = LV_COLOR_MAKE(0x50, 0x50, 0x50);
|
||||||
|
|
||||||
static constexpr lv_color_t bg = LV_COLOR_MAKE(0x5d, 0x69, 0x7e);
|
static constexpr lv_color_t bg = LV_COLOR_MAKE(0x5d, 0x69, 0x7e);
|
||||||
static constexpr lv_color_t bgAlt = LV_COLOR_MAKE(0x38, 0x38, 0x38);
|
static constexpr lv_color_t bgAlt = LV_COLOR_MAKE(0x38, 0x38, 0x38);
|
||||||
|
|
|
@ -117,7 +117,7 @@ Alarm::Alarm(Controllers::AlarmController& alarmController,
|
||||||
|
|
||||||
UpdateAlarmTime();
|
UpdateAlarmTime();
|
||||||
|
|
||||||
if (alarmController.State() == Controllers::AlarmController::AlarmState::Alerting) {
|
if (alarmController.IsAlerting()) {
|
||||||
SetAlerting();
|
SetAlerting();
|
||||||
} else {
|
} else {
|
||||||
SetSwitchState(LV_ANIM_OFF);
|
SetSwitchState(LV_ANIM_OFF);
|
||||||
|
@ -125,14 +125,15 @@ Alarm::Alarm(Controllers::AlarmController& alarmController,
|
||||||
}
|
}
|
||||||
|
|
||||||
Alarm::~Alarm() {
|
Alarm::~Alarm() {
|
||||||
if (alarmController.State() == AlarmController::AlarmState::Alerting) {
|
if (alarmController.IsAlerting()) {
|
||||||
StopAlerting();
|
StopAlerting();
|
||||||
}
|
}
|
||||||
lv_obj_clean(lv_scr_act());
|
lv_obj_clean(lv_scr_act());
|
||||||
|
alarmController.SaveAlarm();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Alarm::DisableAlarm() {
|
void Alarm::DisableAlarm() {
|
||||||
if (alarmController.State() == AlarmController::AlarmState::Set) {
|
if (alarmController.IsEnabled()) {
|
||||||
alarmController.DisableAlarm();
|
alarmController.DisableAlarm();
|
||||||
lv_switch_off(enableSwitch, LV_ANIM_ON);
|
lv_switch_off(enableSwitch, LV_ANIM_ON);
|
||||||
}
|
}
|
||||||
|
@ -172,7 +173,7 @@ bool Alarm::OnButtonPushed() {
|
||||||
HideInfo();
|
HideInfo();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (alarmController.State() == AlarmController::AlarmState::Alerting) {
|
if (alarmController.IsAlerting()) {
|
||||||
StopAlerting();
|
StopAlerting();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -181,7 +182,7 @@ bool Alarm::OnButtonPushed() {
|
||||||
|
|
||||||
bool Alarm::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
bool Alarm::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
||||||
// Don't allow closing the screen by swiping while the alarm is alerting
|
// Don't allow closing the screen by swiping while the alarm is alerting
|
||||||
return alarmController.State() == AlarmController::AlarmState::Alerting && event == TouchEvents::SwipeDown;
|
return alarmController.IsAlerting() && event == TouchEvents::SwipeDown;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Alarm::OnValueChanged() {
|
void Alarm::OnValueChanged() {
|
||||||
|
@ -222,15 +223,10 @@ void Alarm::StopAlerting() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Alarm::SetSwitchState(lv_anim_enable_t anim) {
|
void Alarm::SetSwitchState(lv_anim_enable_t anim) {
|
||||||
switch (alarmController.State()) {
|
if (alarmController.IsEnabled()) {
|
||||||
case AlarmController::AlarmState::Set:
|
|
||||||
lv_switch_on(enableSwitch, anim);
|
lv_switch_on(enableSwitch, anim);
|
||||||
break;
|
} else {
|
||||||
case AlarmController::AlarmState::Not_Set:
|
|
||||||
lv_switch_off(enableSwitch, anim);
|
lv_switch_off(enableSwitch, anim);
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,7 +243,7 @@ void Alarm::ShowInfo() {
|
||||||
txtMessage = lv_label_create(btnMessage, nullptr);
|
txtMessage = lv_label_create(btnMessage, nullptr);
|
||||||
lv_obj_set_style_local_bg_color(btnMessage, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_NAVY);
|
lv_obj_set_style_local_bg_color(btnMessage, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_NAVY);
|
||||||
|
|
||||||
if (alarmController.State() == AlarmController::AlarmState::Set) {
|
if (alarmController.IsEnabled()) {
|
||||||
auto timeToAlarm = alarmController.SecondsToAlarm();
|
auto timeToAlarm = alarmController.SecondsToAlarm();
|
||||||
|
|
||||||
auto daysToAlarm = timeToAlarm / 86400;
|
auto daysToAlarm = timeToAlarm / 86400;
|
||||||
|
|
|
@ -40,8 +40,7 @@ SystemInfo::SystemInfo(Pinetime::Applications::DisplayApp* app,
|
||||||
Pinetime::Controllers::MotionController& motionController,
|
Pinetime::Controllers::MotionController& motionController,
|
||||||
const Pinetime::Drivers::Cst816S& touchPanel,
|
const Pinetime::Drivers::Cst816S& touchPanel,
|
||||||
const Pinetime::Drivers::SpiNorFlash& spiNorFlash)
|
const Pinetime::Drivers::SpiNorFlash& spiNorFlash)
|
||||||
: app {app},
|
: dateTimeController {dateTimeController},
|
||||||
dateTimeController {dateTimeController},
|
|
||||||
batteryController {batteryController},
|
batteryController {batteryController},
|
||||||
brightnessController {brightnessController},
|
brightnessController {brightnessController},
|
||||||
bleController {bleController},
|
bleController {bleController},
|
||||||
|
|
|
@ -35,7 +35,6 @@ namespace Pinetime {
|
||||||
bool OnTouchEvent(TouchEvents event) override;
|
bool OnTouchEvent(TouchEvents event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DisplayApp* app;
|
|
||||||
Pinetime::Controllers::DateTime& dateTimeController;
|
Pinetime::Controllers::DateTime& dateTimeController;
|
||||||
const Pinetime::Controllers::Battery& batteryController;
|
const Pinetime::Controllers::Battery& batteryController;
|
||||||
Pinetime::Controllers::BrightnessController& brightnessController;
|
Pinetime::Controllers::BrightnessController& brightnessController;
|
||||||
|
|
|
@ -2,23 +2,39 @@
|
||||||
#include "displayapp/screens/WatchFaceTerminal.h"
|
#include "displayapp/screens/WatchFaceTerminal.h"
|
||||||
#include "displayapp/screens/BatteryIcon.h"
|
#include "displayapp/screens/BatteryIcon.h"
|
||||||
#include "displayapp/screens/NotificationIcon.h"
|
#include "displayapp/screens/NotificationIcon.h"
|
||||||
#include "displayapp/screens/Symbols.h"
|
|
||||||
#include "components/battery/BatteryController.h"
|
#include "components/battery/BatteryController.h"
|
||||||
#include "components/ble/BleController.h"
|
#include "components/ble/BleController.h"
|
||||||
#include "components/ble/NotificationManager.h"
|
#include "components/ble/NotificationManager.h"
|
||||||
|
#include "components/ble/SimpleWeatherService.h"
|
||||||
#include "components/heartrate/HeartRateController.h"
|
#include "components/heartrate/HeartRateController.h"
|
||||||
#include "components/motion/MotionController.h"
|
#include "components/motion/MotionController.h"
|
||||||
#include "components/settings/Settings.h"
|
#include "components/settings/Settings.h"
|
||||||
|
#include "displayapp/screens/WeatherSymbols.h"
|
||||||
|
#include "displayapp/InfiniTimeTheme.h"
|
||||||
|
|
||||||
using namespace Pinetime::Applications::Screens;
|
using namespace Pinetime::Applications::Screens;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
lv_color_t temperatureColor(int16_t temperature) {
|
||||||
|
if (temperature <= 0) { // freezing
|
||||||
|
return Colors::blue;
|
||||||
|
} else if (temperature <= 400) { // ice
|
||||||
|
return LV_COLOR_CYAN;
|
||||||
|
} else if (temperature >= 2700) { // hot
|
||||||
|
return Colors::deepOrange;
|
||||||
|
}
|
||||||
|
return Colors::orange; // normal
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
WatchFaceTerminal::WatchFaceTerminal(Controllers::DateTime& dateTimeController,
|
WatchFaceTerminal::WatchFaceTerminal(Controllers::DateTime& dateTimeController,
|
||||||
const Controllers::Battery& batteryController,
|
const Controllers::Battery& batteryController,
|
||||||
const Controllers::Ble& bleController,
|
const Controllers::Ble& bleController,
|
||||||
Controllers::NotificationManager& notificationManager,
|
Controllers::NotificationManager& notificationManager,
|
||||||
Controllers::Settings& settingsController,
|
Controllers::Settings& settingsController,
|
||||||
Controllers::HeartRateController& heartRateController,
|
Controllers::HeartRateController& heartRateController,
|
||||||
Controllers::MotionController& motionController)
|
Controllers::MotionController& motionController,
|
||||||
|
Controllers::SimpleWeatherService& weatherService)
|
||||||
: currentDateTime {{}},
|
: currentDateTime {{}},
|
||||||
dateTimeController {dateTimeController},
|
dateTimeController {dateTimeController},
|
||||||
batteryController {batteryController},
|
batteryController {batteryController},
|
||||||
|
@ -26,41 +42,50 @@ WatchFaceTerminal::WatchFaceTerminal(Controllers::DateTime& dateTimeController,
|
||||||
notificationManager {notificationManager},
|
notificationManager {notificationManager},
|
||||||
settingsController {settingsController},
|
settingsController {settingsController},
|
||||||
heartRateController {heartRateController},
|
heartRateController {heartRateController},
|
||||||
motionController {motionController} {
|
motionController {motionController},
|
||||||
batteryValue = lv_label_create(lv_scr_act(), nullptr);
|
weatherService {weatherService} {
|
||||||
lv_label_set_recolor(batteryValue, true);
|
|
||||||
lv_obj_align(batteryValue, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -20);
|
|
||||||
|
|
||||||
connectState = lv_label_create(lv_scr_act(), nullptr);
|
|
||||||
lv_label_set_recolor(connectState, true);
|
|
||||||
lv_obj_align(connectState, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 40);
|
|
||||||
|
|
||||||
notificationIcon = lv_label_create(lv_scr_act(), nullptr);
|
notificationIcon = lv_label_create(lv_scr_act(), nullptr);
|
||||||
lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_LEFT_MID, 0, -100);
|
lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_LEFT_MID, 0, -100);
|
||||||
|
|
||||||
label_date = lv_label_create(lv_scr_act(), nullptr);
|
|
||||||
lv_label_set_recolor(label_date, true);
|
|
||||||
lv_obj_align(label_date, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -40);
|
|
||||||
|
|
||||||
label_prompt_1 = lv_label_create(lv_scr_act(), nullptr);
|
label_prompt_1 = lv_label_create(lv_scr_act(), nullptr);
|
||||||
|
lv_obj_set_style_local_text_color(label_prompt_1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::lightGray);
|
||||||
lv_obj_align(label_prompt_1, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -80);
|
lv_obj_align(label_prompt_1, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -80);
|
||||||
lv_label_set_text_static(label_prompt_1, "user@watch:~ $ now");
|
lv_label_set_text_static(label_prompt_1, "user@watch:~ $ now");
|
||||||
|
|
||||||
label_prompt_2 = lv_label_create(lv_scr_act(), nullptr);
|
|
||||||
lv_obj_align(label_prompt_2, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 60);
|
|
||||||
lv_label_set_text_static(label_prompt_2, "user@watch:~ $");
|
|
||||||
|
|
||||||
label_time = lv_label_create(lv_scr_act(), nullptr);
|
label_time = lv_label_create(lv_scr_act(), nullptr);
|
||||||
lv_label_set_recolor(label_time, true);
|
lv_label_set_recolor(label_time, true);
|
||||||
lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -60);
|
lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -60);
|
||||||
|
|
||||||
heartbeatValue = lv_label_create(lv_scr_act(), nullptr);
|
label_date = lv_label_create(lv_scr_act(), nullptr);
|
||||||
lv_label_set_recolor(heartbeatValue, true);
|
lv_label_set_recolor(label_date, true);
|
||||||
lv_obj_align(heartbeatValue, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 20);
|
lv_obj_align(label_date, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -40);
|
||||||
|
|
||||||
|
weather = lv_label_create(lv_scr_act(), nullptr);
|
||||||
|
lv_label_set_recolor(weather, true);
|
||||||
|
lv_obj_align(weather, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -20);
|
||||||
|
|
||||||
|
batteryValue = lv_label_create(lv_scr_act(), nullptr);
|
||||||
|
lv_label_set_recolor(batteryValue, true);
|
||||||
|
lv_obj_align(batteryValue, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 0);
|
||||||
|
|
||||||
stepValue = lv_label_create(lv_scr_act(), nullptr);
|
stepValue = lv_label_create(lv_scr_act(), nullptr);
|
||||||
lv_label_set_recolor(stepValue, true);
|
lv_label_set_recolor(stepValue, true);
|
||||||
lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 0);
|
lv_obj_set_style_local_text_color(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::orange);
|
||||||
|
lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 20);
|
||||||
|
|
||||||
|
heartbeatValue = lv_label_create(lv_scr_act(), nullptr);
|
||||||
|
lv_label_set_recolor(heartbeatValue, true);
|
||||||
|
lv_obj_align(heartbeatValue, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 40);
|
||||||
|
|
||||||
|
connectState = lv_label_create(lv_scr_act(), nullptr);
|
||||||
|
lv_label_set_recolor(connectState, true);
|
||||||
|
lv_obj_align(connectState, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 60);
|
||||||
|
|
||||||
|
label_prompt_2 = lv_label_create(lv_scr_act(), nullptr);
|
||||||
|
lv_obj_set_style_local_text_color(label_prompt_2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::lightGray);
|
||||||
|
lv_obj_align(label_prompt_2, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 80);
|
||||||
|
lv_label_set_text_static(label_prompt_2, "user@watch:~ $");
|
||||||
|
|
||||||
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
|
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
|
||||||
Refresh();
|
Refresh();
|
||||||
|
@ -72,33 +97,10 @@ WatchFaceTerminal::~WatchFaceTerminal() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void WatchFaceTerminal::Refresh() {
|
void WatchFaceTerminal::Refresh() {
|
||||||
powerPresent = batteryController.IsPowerPresent();
|
|
||||||
batteryPercentRemaining = batteryController.PercentRemaining();
|
|
||||||
if (batteryPercentRemaining.IsUpdated() || powerPresent.IsUpdated()) {
|
|
||||||
lv_label_set_text_fmt(batteryValue, "[BATT]#387b54 %d%%", batteryPercentRemaining.Get());
|
|
||||||
if (batteryController.IsPowerPresent()) {
|
|
||||||
lv_label_ins_text(batteryValue, LV_LABEL_POS_LAST, " Charging");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bleState = bleController.IsConnected();
|
|
||||||
bleRadioEnabled = bleController.IsRadioEnabled();
|
|
||||||
if (bleState.IsUpdated() || bleRadioEnabled.IsUpdated()) {
|
|
||||||
if (!bleRadioEnabled.Get()) {
|
|
||||||
lv_label_set_text_static(connectState, "[STAT]#0082fc Disabled#");
|
|
||||||
} else {
|
|
||||||
if (bleState.Get()) {
|
|
||||||
lv_label_set_text_static(connectState, "[STAT]#0082fc Connected#");
|
|
||||||
} else {
|
|
||||||
lv_label_set_text_static(connectState, "[STAT]#0082fc Disconnected#");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
notificationState = notificationManager.AreNewNotificationsAvailable();
|
notificationState = notificationManager.AreNewNotificationsAvailable();
|
||||||
if (notificationState.IsUpdated()) {
|
if (notificationState.IsUpdated()) {
|
||||||
if (notificationState.Get()) {
|
if (notificationState.Get()) {
|
||||||
lv_label_set_text_static(notificationIcon, "You have mail.");
|
lv_label_set_text_static(notificationIcon, "[1]+ Notify");
|
||||||
} else {
|
} else {
|
||||||
lv_label_set_text_static(notificationIcon, "");
|
lv_label_set_text_static(notificationIcon, "");
|
||||||
}
|
}
|
||||||
|
@ -120,9 +122,9 @@ void WatchFaceTerminal::Refresh() {
|
||||||
hour = hour - 12;
|
hour = hour - 12;
|
||||||
ampmChar[0] = 'P';
|
ampmChar[0] = 'P';
|
||||||
}
|
}
|
||||||
lv_label_set_text_fmt(label_time, "[TIME]#11cc55 %02d:%02d:%02d %s#", hour, minute, second, ampmChar);
|
lv_label_set_text_fmt(label_time, "#fffff [TIME]# #11cc55 %02d:%02d:%02d %s#", hour, minute, second, ampmChar);
|
||||||
} else {
|
} else {
|
||||||
lv_label_set_text_fmt(label_time, "[TIME]#11cc55 %02d:%02d:%02d", hour, minute, second);
|
lv_label_set_text_fmt(label_time, "#ffffff [TIME]# #11cc55 %02d:%02d:%02d#", hour, minute, second);
|
||||||
}
|
}
|
||||||
|
|
||||||
currentDate = std::chrono::time_point_cast<std::chrono::days>(currentDateTime.Get());
|
currentDate = std::chrono::time_point_cast<std::chrono::days>(currentDateTime.Get());
|
||||||
|
@ -130,22 +132,75 @@ void WatchFaceTerminal::Refresh() {
|
||||||
uint16_t year = dateTimeController.Year();
|
uint16_t year = dateTimeController.Year();
|
||||||
Controllers::DateTime::Months month = dateTimeController.Month();
|
Controllers::DateTime::Months month = dateTimeController.Month();
|
||||||
uint8_t day = dateTimeController.Day();
|
uint8_t day = dateTimeController.Day();
|
||||||
lv_label_set_text_fmt(label_date, "[DATE]#007fff %04d-%02d-%02d#", short(year), char(month), char(day));
|
lv_label_set_text_fmt(label_date, "#ffffff [DATE]# #007fff %04d-%02d-%02d#", short(year), char(month), char(day));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
currentWeather = weatherService.Current();
|
||||||
|
if (currentWeather.IsUpdated()) {
|
||||||
|
auto optCurrentWeather = currentWeather.Get();
|
||||||
|
if (optCurrentWeather) {
|
||||||
|
int16_t temp = optCurrentWeather->temperature;
|
||||||
|
char tempUnit = 'C';
|
||||||
|
lv_obj_set_style_local_text_color(weather, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, temperatureColor(temp));
|
||||||
|
if (settingsController.GetWeatherFormat() == Controllers::Settings::WeatherFormat::Imperial) {
|
||||||
|
temp = Controllers::SimpleWeatherService::CelsiusToFahrenheit(temp);
|
||||||
|
tempUnit = 'F';
|
||||||
|
}
|
||||||
|
lv_label_set_text_fmt(weather, "#ffffff [WTHR]# %i°%c %s ", temp / 100, tempUnit, Symbols::GetSimpleCondition(optCurrentWeather->iconId));
|
||||||
|
} else {
|
||||||
|
lv_label_set_text(weather, "#ffffff [WTHR]# ---");
|
||||||
|
lv_obj_set_style_local_text_color(weather, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::gray);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
powerPresent = batteryController.IsPowerPresent();
|
||||||
|
batteryPercentRemaining = batteryController.PercentRemaining();
|
||||||
|
if (batteryPercentRemaining.IsUpdated() || powerPresent.IsUpdated()) {
|
||||||
|
// HSV color model has red at 0° and green at 120°.
|
||||||
|
// We lock satuation and brightness at 100% and traverse the cilinder
|
||||||
|
// between red and green, thus avoiding the darker RGB on medium battery
|
||||||
|
// charges and giving us a much nicer color range.
|
||||||
|
uint8_t hue = batteryPercentRemaining.Get() * 120 / 100;
|
||||||
|
lv_obj_set_style_local_text_color(batteryValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hsv_to_rgb(hue, 100, 100));
|
||||||
|
lv_label_set_text_fmt(batteryValue, "#ffffff [BATT]# %d%%", batteryPercentRemaining.Get());
|
||||||
|
if (batteryController.IsCharging()) {
|
||||||
|
lv_label_ins_text(batteryValue, LV_LABEL_POS_LAST, " Charging");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stepCount = motionController.NbSteps();
|
||||||
|
if (stepCount.IsUpdated()) {
|
||||||
|
lv_label_set_text_fmt(stepValue, "#ffffff [STEP]# %lu steps", stepCount.Get());
|
||||||
|
}
|
||||||
|
|
||||||
heartbeat = heartRateController.HeartRate();
|
heartbeat = heartRateController.HeartRate();
|
||||||
heartbeatRunning = heartRateController.State() != Controllers::HeartRateController::States::Stopped;
|
heartbeatRunning = heartRateController.State() != Controllers::HeartRateController::States::Stopped;
|
||||||
if (heartbeat.IsUpdated() || heartbeatRunning.IsUpdated()) {
|
if (heartbeat.IsUpdated() || heartbeatRunning.IsUpdated()) {
|
||||||
if (heartbeatRunning.Get()) {
|
if (heartbeatRunning.Get()) {
|
||||||
lv_label_set_text_fmt(heartbeatValue, "[L_HR]#ee3311 %d bpm#", heartbeat.Get());
|
|
||||||
|
lv_obj_set_style_local_text_color(heartbeatValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::deepOrange);
|
||||||
|
lv_label_set_text_fmt(heartbeatValue, "#ffffff [L_HR]# %d bpm", heartbeat.Get());
|
||||||
} else {
|
} else {
|
||||||
lv_label_set_text_static(heartbeatValue, "[L_HR]#ee3311 ---#");
|
lv_label_set_text_static(heartbeatValue, "#ffffff [L_HR]# ---");
|
||||||
|
lv_obj_set_style_local_text_color(heartbeatValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::gray);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stepCount = motionController.NbSteps();
|
bleState = bleController.IsConnected();
|
||||||
if (stepCount.IsUpdated()) {
|
bleRadioEnabled = bleController.IsRadioEnabled();
|
||||||
lv_label_set_text_fmt(stepValue, "[STEP]#ee3377 %lu steps#", stepCount.Get());
|
if (bleState.IsUpdated() || bleRadioEnabled.IsUpdated()) {
|
||||||
|
if (!bleRadioEnabled.Get()) {
|
||||||
|
lv_label_set_text_static(connectState, "#ffffff [STAT]# Disabled");
|
||||||
|
lv_obj_set_style_local_text_color(connectState, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::gray);
|
||||||
|
} else {
|
||||||
|
if (bleState.Get()) {
|
||||||
|
lv_label_set_text_static(connectState, "#ffffff [STAT]# Connected");
|
||||||
|
lv_obj_set_style_local_text_color(connectState, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::blue);
|
||||||
|
} else {
|
||||||
|
lv_label_set_text_static(connectState, "#ffffff [STAT]# Disconnected");
|
||||||
|
lv_obj_set_style_local_text_color(connectState, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::gray);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include <displayapp/Controllers.h>
|
#include <displayapp/Controllers.h>
|
||||||
#include "displayapp/screens/Screen.h"
|
#include "displayapp/screens/Screen.h"
|
||||||
#include "components/datetime/DateTimeController.h"
|
#include "components/datetime/DateTimeController.h"
|
||||||
|
#include "components/ble/SimpleWeatherService.h"
|
||||||
#include "utility/DirtyValue.h"
|
#include "utility/DirtyValue.h"
|
||||||
|
|
||||||
namespace Pinetime {
|
namespace Pinetime {
|
||||||
|
@ -30,7 +31,8 @@ namespace Pinetime {
|
||||||
Controllers::NotificationManager& notificationManager,
|
Controllers::NotificationManager& notificationManager,
|
||||||
Controllers::Settings& settingsController,
|
Controllers::Settings& settingsController,
|
||||||
Controllers::HeartRateController& heartRateController,
|
Controllers::HeartRateController& heartRateController,
|
||||||
Controllers::MotionController& motionController);
|
Controllers::MotionController& motionController,
|
||||||
|
Controllers::SimpleWeatherService& weatherService);
|
||||||
~WatchFaceTerminal() override;
|
~WatchFaceTerminal() override;
|
||||||
|
|
||||||
void Refresh() override;
|
void Refresh() override;
|
||||||
|
@ -46,16 +48,18 @@ namespace Pinetime {
|
||||||
Utility::DirtyValue<bool> heartbeatRunning {};
|
Utility::DirtyValue<bool> heartbeatRunning {};
|
||||||
Utility::DirtyValue<bool> notificationState {};
|
Utility::DirtyValue<bool> notificationState {};
|
||||||
Utility::DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::days>> currentDate;
|
Utility::DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::days>> currentDate;
|
||||||
|
Utility::DirtyValue<std::optional<Controllers::SimpleWeatherService::CurrentWeather>> currentWeather {};
|
||||||
|
|
||||||
|
lv_obj_t* notificationIcon;
|
||||||
|
lv_obj_t* label_prompt_1;
|
||||||
lv_obj_t* label_time;
|
lv_obj_t* label_time;
|
||||||
lv_obj_t* label_date;
|
lv_obj_t* label_date;
|
||||||
lv_obj_t* label_prompt_1;
|
lv_obj_t* weather;
|
||||||
lv_obj_t* label_prompt_2;
|
|
||||||
lv_obj_t* batteryValue;
|
lv_obj_t* batteryValue;
|
||||||
lv_obj_t* heartbeatValue;
|
|
||||||
lv_obj_t* stepValue;
|
lv_obj_t* stepValue;
|
||||||
lv_obj_t* notificationIcon;
|
lv_obj_t* heartbeatValue;
|
||||||
lv_obj_t* connectState;
|
lv_obj_t* connectState;
|
||||||
|
lv_obj_t* label_prompt_2;
|
||||||
|
|
||||||
Controllers::DateTime& dateTimeController;
|
Controllers::DateTime& dateTimeController;
|
||||||
const Controllers::Battery& batteryController;
|
const Controllers::Battery& batteryController;
|
||||||
|
@ -64,6 +68,7 @@ namespace Pinetime {
|
||||||
Controllers::Settings& settingsController;
|
Controllers::Settings& settingsController;
|
||||||
Controllers::HeartRateController& heartRateController;
|
Controllers::HeartRateController& heartRateController;
|
||||||
Controllers::MotionController& motionController;
|
Controllers::MotionController& motionController;
|
||||||
|
Controllers::SimpleWeatherService& weatherService;
|
||||||
|
|
||||||
lv_task_t* taskRefresh;
|
lv_task_t* taskRefresh;
|
||||||
};
|
};
|
||||||
|
@ -81,7 +86,8 @@ namespace Pinetime {
|
||||||
controllers.notificationManager,
|
controllers.notificationManager,
|
||||||
controllers.settingsController,
|
controllers.settingsController,
|
||||||
controllers.heartRateController,
|
controllers.heartRateController,
|
||||||
controllers.motionController);
|
controllers.motionController,
|
||||||
|
*controllers.weatherController);
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool IsAvailable(Pinetime::Controllers::FS& /*filesystem*/) {
|
static bool IsAvailable(Pinetime::Controllers::FS& /*filesystem*/) {
|
||||||
|
|
|
@ -59,3 +59,28 @@ const char* Pinetime::Applications::Screens::Symbols::GetCondition(const Pinetim
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* Pinetime::Applications::Screens::Symbols::GetSimpleCondition(const Pinetime::Controllers::SimpleWeatherService::Icons icon) {
|
||||||
|
switch (icon) {
|
||||||
|
case Pinetime::Controllers::SimpleWeatherService::Icons::Sun:
|
||||||
|
return "Clear";
|
||||||
|
case Pinetime::Controllers::SimpleWeatherService::Icons::CloudsSun:
|
||||||
|
return "Clouds";
|
||||||
|
case Pinetime::Controllers::SimpleWeatherService::Icons::Clouds:
|
||||||
|
return "Clouds";
|
||||||
|
case Pinetime::Controllers::SimpleWeatherService::Icons::BrokenClouds:
|
||||||
|
return "Clouds";
|
||||||
|
case Pinetime::Controllers::SimpleWeatherService::Icons::CloudShowerHeavy:
|
||||||
|
return "Rain";
|
||||||
|
case Pinetime::Controllers::SimpleWeatherService::Icons::CloudSunRain:
|
||||||
|
return "Drizzle";
|
||||||
|
case Pinetime::Controllers::SimpleWeatherService::Icons::Thunderstorm:
|
||||||
|
return "Thunder";
|
||||||
|
case Pinetime::Controllers::SimpleWeatherService::Icons::Snow:
|
||||||
|
return "Snow";
|
||||||
|
case Pinetime::Controllers::SimpleWeatherService::Icons::Smog:
|
||||||
|
return "Mist";
|
||||||
|
default:
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ namespace Pinetime {
|
||||||
namespace Symbols {
|
namespace Symbols {
|
||||||
const char* GetSymbol(const Pinetime::Controllers::SimpleWeatherService::Icons icon);
|
const char* GetSymbol(const Pinetime::Controllers::SimpleWeatherService::Icons icon);
|
||||||
const char* GetCondition(const Pinetime::Controllers::SimpleWeatherService::Icons icon);
|
const char* GetCondition(const Pinetime::Controllers::SimpleWeatherService::Icons icon);
|
||||||
|
const char* GetSimpleCondition(const Pinetime::Controllers::SimpleWeatherService::Icons icon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,8 +24,7 @@ namespace {
|
||||||
|
|
||||||
constexpr std::array<uint16_t, 6> SettingDisplay::options;
|
constexpr std::array<uint16_t, 6> SettingDisplay::options;
|
||||||
|
|
||||||
SettingDisplay::SettingDisplay(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController)
|
SettingDisplay::SettingDisplay(Pinetime::Controllers::Settings& settingsController) : settingsController {settingsController} {
|
||||||
: app {app}, settingsController {settingsController} {
|
|
||||||
|
|
||||||
lv_obj_t* container1 = lv_cont_create(lv_scr_act(), nullptr);
|
lv_obj_t* container1 = lv_cont_create(lv_scr_act(), nullptr);
|
||||||
|
|
||||||
|
|
|
@ -14,14 +14,13 @@ namespace Pinetime {
|
||||||
|
|
||||||
class SettingDisplay : public Screen {
|
class SettingDisplay : public Screen {
|
||||||
public:
|
public:
|
||||||
SettingDisplay(DisplayApp* app, Pinetime::Controllers::Settings& settingsController);
|
SettingDisplay(Pinetime::Controllers::Settings& settingsController);
|
||||||
~SettingDisplay() override;
|
~SettingDisplay() override;
|
||||||
|
|
||||||
void UpdateSelected(lv_obj_t* object, lv_event_t event);
|
void UpdateSelected(lv_obj_t* object, lv_event_t event);
|
||||||
void ToggleAlwaysOn();
|
void ToggleAlwaysOn();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DisplayApp* app;
|
|
||||||
static constexpr std::array<uint16_t, 6> options = {5000, 7000, 10000, 15000, 20000, 30000};
|
static constexpr std::array<uint16_t, 6> options = {5000, 7000, 10000, 15000, 20000, 30000};
|
||||||
|
|
||||||
Controllers::Settings& settingsController;
|
Controllers::Settings& settingsController;
|
||||||
|
|
|
@ -15,8 +15,7 @@ bool SettingSetDateTime::OnTouchEvent(Pinetime::Applications::TouchEvents event)
|
||||||
SettingSetDateTime::SettingSetDateTime(Pinetime::Applications::DisplayApp* app,
|
SettingSetDateTime::SettingSetDateTime(Pinetime::Applications::DisplayApp* app,
|
||||||
Pinetime::Controllers::DateTime& dateTimeController,
|
Pinetime::Controllers::DateTime& dateTimeController,
|
||||||
Pinetime::Controllers::Settings& settingsController)
|
Pinetime::Controllers::Settings& settingsController)
|
||||||
: app {app},
|
: dateTimeController {dateTimeController},
|
||||||
dateTimeController {dateTimeController},
|
|
||||||
settingsController {settingsController},
|
settingsController {settingsController},
|
||||||
screens {app,
|
screens {app,
|
||||||
0,
|
0,
|
||||||
|
|
|
@ -20,7 +20,6 @@ namespace Pinetime {
|
||||||
void Quit();
|
void Quit();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DisplayApp* app;
|
|
||||||
Controllers::DateTime& dateTimeController;
|
Controllers::DateTime& dateTimeController;
|
||||||
Controllers::Settings& settingsController;
|
Controllers::Settings& settingsController;
|
||||||
|
|
||||||
|
|
|
@ -54,8 +54,7 @@ SettingWatchFace::SettingWatchFace(Pinetime::Applications::DisplayApp* app,
|
||||||
std::array<Screens::SettingWatchFace::Item, UserWatchFaceTypes::Count>&& watchfaceItems,
|
std::array<Screens::SettingWatchFace::Item, UserWatchFaceTypes::Count>&& watchfaceItems,
|
||||||
Pinetime::Controllers::Settings& settingsController,
|
Pinetime::Controllers::Settings& settingsController,
|
||||||
Pinetime::Controllers::FS& filesystem)
|
Pinetime::Controllers::FS& filesystem)
|
||||||
: app {app},
|
: watchfaceItems {std::move(watchfaceItems)},
|
||||||
watchfaceItems {std::move(watchfaceItems)},
|
|
||||||
settingsController {settingsController},
|
settingsController {settingsController},
|
||||||
filesystem {filesystem},
|
filesystem {filesystem},
|
||||||
screens {app, 0, CreateScreenList(), Screens::ScreenListModes::UpDown} {
|
screens {app, 0, CreateScreenList(), Screens::ScreenListModes::UpDown} {
|
||||||
|
|
|
@ -34,7 +34,6 @@ namespace Pinetime {
|
||||||
bool OnTouchEvent(TouchEvents event) override;
|
bool OnTouchEvent(TouchEvents event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DisplayApp* app;
|
|
||||||
auto CreateScreenList() const;
|
auto CreateScreenList() const;
|
||||||
std::unique_ptr<Screen> CreateScreen(unsigned int screenNum) const;
|
std::unique_ptr<Screen> CreateScreen(unsigned int screenNum) const;
|
||||||
|
|
||||||
|
|
|
@ -104,7 +104,7 @@ Pinetime::Controllers::DateTime dateTimeController {settingsController};
|
||||||
Pinetime::Drivers::Watchdog watchdog;
|
Pinetime::Drivers::Watchdog watchdog;
|
||||||
Pinetime::Controllers::NotificationManager notificationManager;
|
Pinetime::Controllers::NotificationManager notificationManager;
|
||||||
Pinetime::Controllers::MotionController motionController;
|
Pinetime::Controllers::MotionController motionController;
|
||||||
Pinetime::Controllers::AlarmController alarmController {dateTimeController};
|
Pinetime::Controllers::AlarmController alarmController {dateTimeController, fs};
|
||||||
Pinetime::Controllers::TouchHandler touchHandler;
|
Pinetime::Controllers::TouchHandler touchHandler;
|
||||||
Pinetime::Controllers::ButtonHandler buttonHandler;
|
Pinetime::Controllers::ButtonHandler buttonHandler;
|
||||||
Pinetime::Controllers::BrightnessController brightnessController {};
|
Pinetime::Controllers::BrightnessController brightnessController {};
|
||||||
|
|
|
@ -216,7 +216,7 @@ void SystemTask::Work() {
|
||||||
GoToSleep();
|
GoToSleep();
|
||||||
break;
|
break;
|
||||||
case Messages::OnNewTime:
|
case Messages::OnNewTime:
|
||||||
if (alarmController.State() == Controllers::AlarmController::AlarmState::Set) {
|
if (alarmController.IsEnabled()) {
|
||||||
alarmController.ScheduleAlarm();
|
alarmController.ScheduleAlarm();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -317,8 +317,7 @@ void SystemTask::Work() {
|
||||||
case Messages::OnNewHour:
|
case Messages::OnNewHour:
|
||||||
using Pinetime::Controllers::AlarmController;
|
using Pinetime::Controllers::AlarmController;
|
||||||
if (settingsController.GetNotificationStatus() != Controllers::Settings::Notification::Sleep &&
|
if (settingsController.GetNotificationStatus() != Controllers::Settings::Notification::Sleep &&
|
||||||
settingsController.GetChimeOption() == Controllers::Settings::ChimesOption::Hours &&
|
settingsController.GetChimeOption() == Controllers::Settings::ChimesOption::Hours && !alarmController.IsAlerting()) {
|
||||||
alarmController.State() != AlarmController::AlarmState::Alerting) {
|
|
||||||
GoToRunning();
|
GoToRunning();
|
||||||
displayApp.PushMessage(Pinetime::Applications::Display::Messages::Chime);
|
displayApp.PushMessage(Pinetime::Applications::Display::Messages::Chime);
|
||||||
}
|
}
|
||||||
|
@ -326,8 +325,7 @@ void SystemTask::Work() {
|
||||||
case Messages::OnNewHalfHour:
|
case Messages::OnNewHalfHour:
|
||||||
using Pinetime::Controllers::AlarmController;
|
using Pinetime::Controllers::AlarmController;
|
||||||
if (settingsController.GetNotificationStatus() != Controllers::Settings::Notification::Sleep &&
|
if (settingsController.GetNotificationStatus() != Controllers::Settings::Notification::Sleep &&
|
||||||
settingsController.GetChimeOption() == Controllers::Settings::ChimesOption::HalfHours &&
|
settingsController.GetChimeOption() == Controllers::Settings::ChimesOption::HalfHours && !alarmController.IsAlerting()) {
|
||||||
alarmController.State() != AlarmController::AlarmState::Alerting) {
|
|
||||||
GoToRunning();
|
GoToRunning();
|
||||||
displayApp.PushMessage(Pinetime::Applications::Display::Messages::Chime);
|
displayApp.PushMessage(Pinetime::Applications::Display::Messages::Chime);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue