From fad6d20e46306724e92dafcd5c47d1de44addf0b Mon Sep 17 00:00:00 2001 From: Jozef Mlich Date: Sun, 22 Dec 2024 12:42:59 +0100 Subject: [PATCH] Show alarm controller state in status icon --- src/displayapp/DisplayApp.cpp | 4 +- src/displayapp/screens/ApplicationList.cpp | 3 + src/displayapp/screens/ApplicationList.h | 2 + src/displayapp/screens/Clock.cpp | 136 ++++++++++++++++++ src/displayapp/screens/Clock.h | 66 +++++++++ src/displayapp/screens/SystemInfo.cpp | 1 + src/displayapp/screens/Tile.cpp | 6 +- src/displayapp/screens/Tile.h | 1 + src/displayapp/screens/WatchFaceDigital.cpp | 3 +- src/displayapp/screens/WatchFaceDigital.h | 2 + .../screens/settings/QuickSettings.cpp | 5 +- .../screens/settings/QuickSettings.h | 3 +- src/displayapp/widgets/StatusIcons.cpp | 13 +- src/displayapp/widgets/StatusIcons.h | 7 +- 14 files changed, 243 insertions(+), 9 deletions(-) create mode 100644 src/displayapp/screens/Clock.cpp create mode 100644 src/displayapp/screens/Clock.h diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index b1594f197c..6671ac9e51 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -526,6 +526,7 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio settingsController, batteryController, bleController, + alarmController, dateTimeController, filesystem, std::move(apps)); @@ -580,7 +581,8 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio brightnessController, motorController, settingsController, - bleController); + bleController, + alarmController); break; case Apps::Settings: currentScreen = std::make_unique(this, settingsController); diff --git a/src/displayapp/screens/ApplicationList.cpp b/src/displayapp/screens/ApplicationList.cpp index 41735349da..fb46b41384 100644 --- a/src/displayapp/screens/ApplicationList.cpp +++ b/src/displayapp/screens/ApplicationList.cpp @@ -21,6 +21,7 @@ ApplicationList::ApplicationList(DisplayApp* app, Pinetime::Controllers::Settings& settingsController, const Pinetime::Controllers::Battery& batteryController, const Pinetime::Controllers::Ble& bleController, + const Pinetime::Controllers::AlarmController& alarmController, Controllers::DateTime& dateTimeController, Pinetime::Controllers::FS& filesystem, std::array&& apps) @@ -28,6 +29,7 @@ ApplicationList::ApplicationList(DisplayApp* app, settingsController {settingsController}, batteryController {batteryController}, bleController {bleController}, + alarmController {alarmController}, dateTimeController {dateTimeController}, filesystem {filesystem}, apps {std::move(apps)}, @@ -59,6 +61,7 @@ std::unique_ptr ApplicationList::CreateScreen(unsigned int screenNum) co settingsController, batteryController, bleController, + alarmController, dateTimeController, pageApps); } diff --git a/src/displayapp/screens/ApplicationList.h b/src/displayapp/screens/ApplicationList.h index 41a413af1a..4a57d7c034 100644 --- a/src/displayapp/screens/ApplicationList.h +++ b/src/displayapp/screens/ApplicationList.h @@ -18,6 +18,7 @@ namespace Pinetime { Pinetime::Controllers::Settings& settingsController, const Pinetime::Controllers::Battery& batteryController, const Pinetime::Controllers::Ble& bleController, + const Pinetime::Controllers::AlarmController& alarmController, Controllers::DateTime& dateTimeController, Pinetime::Controllers::FS& filesystem, std::array&& apps); @@ -32,6 +33,7 @@ namespace Pinetime { Controllers::Settings& settingsController; const Pinetime::Controllers::Battery& batteryController; const Pinetime::Controllers::Ble& bleController; + const Pinetime::Controllers::AlarmController& alarmController; Controllers::DateTime& dateTimeController; Pinetime::Controllers::FS& filesystem; std::array apps; diff --git a/src/displayapp/screens/Clock.cpp b/src/displayapp/screens/Clock.cpp new file mode 100644 index 0000000000..4bbf4e868c --- /dev/null +++ b/src/displayapp/screens/Clock.cpp @@ -0,0 +1,136 @@ +#include "displayapp/screens/Clock.h" + +#include +#include "components/battery/BatteryController.h" +#include "components/motion/MotionController.h" +#include "components/ble/BleController.h" +#include "components/ble/NotificationManager.h" +#include "components/settings/Settings.h" +#include "displayapp/DisplayApp.h" +#include "displayapp/screens/WatchFaceDigital.h" +#include "displayapp/screens/WatchFaceTerminal.h" +#include "displayapp/screens/WatchFaceInfineat.h" +#include "displayapp/screens/WatchFaceAnalog.h" +#include "displayapp/screens/WatchFacePineTimeStyle.h" +#include "displayapp/screens/WatchFaceCasioStyleG7710.h" + +using namespace Pinetime::Applications::Screens; +using namespace Pinetime::Applications; + +Clock::Clock(Controllers::DateTime& dateTimeController, + const Controllers::Battery& batteryController, + const Controllers::Ble& bleController, + const Controllers::AlarmController& alarmController, + Controllers::NotificationManager& notificationManager, + Controllers::Settings& settingsController, + Controllers::HeartRateController& heartRateController, + Controllers::MotionController& motionController, + Controllers::WeatherService& weatherService, + Controllers::FS& filesystem) + : dateTimeController {dateTimeController}, + batteryController {batteryController}, + bleController {bleController}, + alarmController {alarmController}, + notificationManager {notificationManager}, + settingsController {settingsController}, + heartRateController {heartRateController}, + motionController {motionController}, + weatherService {weatherService}, + filesystem {filesystem}, + screen {[this, &settingsController]() { + switch (settingsController.GetWatchFace()) { + case WatchFace::Digital: + return WatchFaceDigitalScreen(); + break; + case WatchFace::Analog: + return WatchFaceAnalogScreen(); + break; + case WatchFace::PineTimeStyle: + return WatchFacePineTimeStyleScreen(); + break; + case WatchFace::Terminal: + return WatchFaceTerminalScreen(); + break; + case WatchFace::Infineat: + return WatchFaceInfineatScreen(); + break; + case WatchFace::CasioStyleG7710: + return WatchFaceCasioStyleG7710(); + break; + } + return WatchFaceDigitalScreen(); + }()} { + settingsController.SetAppMenu(0); +} + +Clock::~Clock() { + lv_obj_clean(lv_scr_act()); +} + +bool Clock::OnTouchEvent(Pinetime::Applications::TouchEvents event) { + return screen->OnTouchEvent(event); +} + +bool Clock::OnButtonPushed() { + return screen->OnButtonPushed(); +} + +std::unique_ptr Clock::WatchFaceDigitalScreen() { + return std::make_unique(dateTimeController, + batteryController, + bleController, + alarmController, + notificationManager, + settingsController, + heartRateController, + motionController); +} + +std::unique_ptr Clock::WatchFaceAnalogScreen() { + return std::make_unique(dateTimeController, + batteryController, + bleController, + notificationManager, + settingsController); +} + +std::unique_ptr Clock::WatchFacePineTimeStyleScreen() { + return std::make_unique(dateTimeController, + batteryController, + bleController, + notificationManager, + settingsController, + motionController, + weatherService); +} + +std::unique_ptr Clock::WatchFaceTerminalScreen() { + return std::make_unique(dateTimeController, + batteryController, + bleController, + notificationManager, + settingsController, + heartRateController, + motionController); +} + +std::unique_ptr Clock::WatchFaceInfineatScreen() { + return std::make_unique(dateTimeController, + batteryController, + bleController, + notificationManager, + settingsController, + motionController, + filesystem); +} + +std::unique_ptr Clock::WatchFaceCasioStyleG7710() { + return std::make_unique(dateTimeController, + batteryController, + bleController, + notificationManager, + settingsController, + heartRateController, + motionController, + filesystem); +} diff --git a/src/displayapp/screens/Clock.h b/src/displayapp/screens/Clock.h new file mode 100644 index 0000000000..d4ac818388 --- /dev/null +++ b/src/displayapp/screens/Clock.h @@ -0,0 +1,66 @@ +#pragma once + +#include +#include +#include +#include "displayapp/Controllers.h" +#include "displayapp/screens/Screen.h" +#include "displayapp/Apps.h" +#include "Symbols.h" + +namespace Pinetime { + namespace Controllers { + class Settings; + class Battery; + class Ble; + class AlarmController; + class NotificationManager; + class MotionController; + class DateTime; + class HeartRateController; + class WeatherService; + class FS; + } + + namespace Applications { + namespace Screens { + class Clock : public Screen { + public: + Clock(Controllers::DateTime& dateTimeController, + const Controllers::Battery& batteryController, + const Controllers::Ble& bleController, + const Controllers::AlarmController& alarmController, + Controllers::NotificationManager& notificationManager, + Controllers::Settings& settingsController, + Controllers::HeartRateController& heartRateController, + Controllers::MotionController& motionController, + Controllers::WeatherService& weatherService, + Controllers::FS& filesystem); + ~Clock() override; + + bool OnTouchEvent(TouchEvents event) override; + bool OnButtonPushed() override; + + private: + Controllers::DateTime& dateTimeController; + const Controllers::Battery& batteryController; + const Controllers::Ble& bleController; + const Controllers::AlarmController& alarmController; + Controllers::NotificationManager& notificationManager; + Controllers::Settings& settingsController; + Controllers::HeartRateController& heartRateController; + Controllers::MotionController& motionController; + Controllers::WeatherService& weatherService; + Controllers::FS& filesystem; + + std::unique_ptr screen; + std::unique_ptr WatchFaceDigitalScreen(); + std::unique_ptr WatchFaceAnalogScreen(); + std::unique_ptr WatchFacePineTimeStyleScreen(); + std::unique_ptr WatchFaceTerminalScreen(); + std::unique_ptr WatchFaceInfineatScreen(); + std::unique_ptr WatchFaceCasioStyleG7710(); + }; + } + } +} diff --git a/src/displayapp/screens/SystemInfo.cpp b/src/displayapp/screens/SystemInfo.cpp index 886dacb6c6..f208a4fd86 100644 --- a/src/displayapp/screens/SystemInfo.cpp +++ b/src/displayapp/screens/SystemInfo.cpp @@ -180,6 +180,7 @@ std::unique_ptr SystemInfo::CreateScreen2() { extern int mallocFailedCount; extern int stackOverflowCount; + std::unique_ptr SystemInfo::CreateScreen3() { lv_mem_monitor_t mon; lv_mem_monitor(&mon); diff --git a/src/displayapp/screens/Tile.cpp b/src/displayapp/screens/Tile.cpp index 7c392c59e5..7c585a4b97 100644 --- a/src/displayapp/screens/Tile.cpp +++ b/src/displayapp/screens/Tile.cpp @@ -29,9 +29,13 @@ Tile::Tile(uint8_t screenID, Controllers::Settings& settingsController, const Controllers::Battery& batteryController, const Controllers::Ble& bleController, + const Controllers::AlarmController& alarmController, Controllers::DateTime& dateTimeController, std::array& applications) - : app {app}, dateTimeController {dateTimeController}, pageIndicator(screenID, numScreens), statusIcons(batteryController, bleController) { + : app {app}, + dateTimeController {dateTimeController}, + pageIndicator(screenID, numScreens), + statusIcons(batteryController, bleController, alarmController) { settingsController.SetAppMenu(screenID); diff --git a/src/displayapp/screens/Tile.h b/src/displayapp/screens/Tile.h index f1b86246ce..c16151d0e1 100644 --- a/src/displayapp/screens/Tile.h +++ b/src/displayapp/screens/Tile.h @@ -28,6 +28,7 @@ namespace Pinetime { Controllers::Settings& settingsController, const Controllers::Battery& batteryController, const Controllers::Ble& bleController, + const Controllers::AlarmController& alarmController, Controllers::DateTime& dateTimeController, std::array& applications); diff --git a/src/displayapp/screens/WatchFaceDigital.cpp b/src/displayapp/screens/WatchFaceDigital.cpp index d944117dd7..3163c6e750 100644 --- a/src/displayapp/screens/WatchFaceDigital.cpp +++ b/src/displayapp/screens/WatchFaceDigital.cpp @@ -19,6 +19,7 @@ using namespace Pinetime::Applications::Screens; WatchFaceDigital::WatchFaceDigital(Controllers::DateTime& dateTimeController, const Controllers::Battery& batteryController, const Controllers::Ble& bleController, + const Controllers::AlarmController& alarmController, Controllers::NotificationManager& notificationManager, Controllers::Settings& settingsController, Controllers::HeartRateController& heartRateController, @@ -31,7 +32,7 @@ WatchFaceDigital::WatchFaceDigital(Controllers::DateTime& dateTimeController, heartRateController {heartRateController}, motionController {motionController}, weatherService {weatherService}, - statusIcons(batteryController, bleController) { + statusIcons(batteryController, bleController, alarmController) { statusIcons.Create(); diff --git a/src/displayapp/screens/WatchFaceDigital.h b/src/displayapp/screens/WatchFaceDigital.h index 7bb713cbb8..96d25714cc 100644 --- a/src/displayapp/screens/WatchFaceDigital.h +++ b/src/displayapp/screens/WatchFaceDigital.h @@ -17,6 +17,7 @@ namespace Pinetime { class Settings; class Battery; class Ble; + class AlarmController; class NotificationManager; class HeartRateController; class MotionController; @@ -30,6 +31,7 @@ namespace Pinetime { WatchFaceDigital(Controllers::DateTime& dateTimeController, const Controllers::Battery& batteryController, const Controllers::Ble& bleController, + const Controllers::AlarmController& alarmController, Controllers::NotificationManager& notificationManager, Controllers::Settings& settingsController, Controllers::HeartRateController& heartRateController, diff --git a/src/displayapp/screens/settings/QuickSettings.cpp b/src/displayapp/screens/settings/QuickSettings.cpp index 0548488855..c5c3071aef 100644 --- a/src/displayapp/screens/settings/QuickSettings.cpp +++ b/src/displayapp/screens/settings/QuickSettings.cpp @@ -33,13 +33,14 @@ QuickSettings::QuickSettings(Pinetime::Applications::DisplayApp* app, Controllers::BrightnessController& brightness, Controllers::MotorController& motorController, Pinetime::Controllers::Settings& settingsController, - const Controllers::Ble& bleController) + const Controllers::Ble& bleController, + const Controllers::AlarmController& alarmController) : app {app}, dateTimeController {dateTimeController}, brightness {brightness}, motorController {motorController}, settingsController {settingsController}, - statusIcons(batteryController, bleController) { + statusIcons(batteryController, bleController, alarmController) { statusIcons.Create(); diff --git a/src/displayapp/screens/settings/QuickSettings.h b/src/displayapp/screens/settings/QuickSettings.h index 55da617629..87c126b7fa 100644 --- a/src/displayapp/screens/settings/QuickSettings.h +++ b/src/displayapp/screens/settings/QuickSettings.h @@ -23,7 +23,8 @@ namespace Pinetime { Controllers::BrightnessController& brightness, Controllers::MotorController& motorController, Pinetime::Controllers::Settings& settingsController, - const Controllers::Ble& bleController); + const Controllers::Ble& bleController, + const Controllers::AlarmController& alarmController); ~QuickSettings() override; diff --git a/src/displayapp/widgets/StatusIcons.cpp b/src/displayapp/widgets/StatusIcons.cpp index 423b53d97a..81173f2a4b 100644 --- a/src/displayapp/widgets/StatusIcons.cpp +++ b/src/displayapp/widgets/StatusIcons.cpp @@ -1,10 +1,13 @@ #include "displayapp/widgets/StatusIcons.h" #include "displayapp/screens/Symbols.h" +#include "components/alarm/AlarmController.h" using namespace Pinetime::Applications::Widgets; -StatusIcons::StatusIcons(const Controllers::Battery& batteryController, const Controllers::Ble& bleController) - : batteryIcon(true), batteryController {batteryController}, bleController {bleController} { +StatusIcons::StatusIcons(const Controllers::Battery& batteryController, + const Controllers::Ble& bleController, + const Controllers::AlarmController& alarmController) + : batteryIcon(true), batteryController {batteryController}, bleController {bleController}, alarmController {alarmController} { } void StatusIcons::Create() { @@ -20,6 +23,9 @@ void StatusIcons::Create() { batteryPlug = lv_label_create(container, nullptr); lv_label_set_text_static(batteryPlug, Screens::Symbols::plug); + alarmIcon = lv_label_create(container, nullptr); + lv_label_set_text_static(alarmIcon, Screens::Symbols::clock); + batteryIcon.Create(container); lv_obj_align(container, nullptr, LV_ALIGN_IN_TOP_RIGHT, 0, 0); @@ -37,6 +43,9 @@ void StatusIcons::Update() { batteryIcon.SetBatteryPercentage(batteryPercent); } + bool alarmNotSet = (alarmController.State() == Pinetime::Controllers::AlarmController::AlarmState::Not_Set); + lv_obj_set_hidden(alarmIcon, alarmNotSet); + bleState = bleController.IsConnected(); bleRadioEnabled = bleController.IsRadioEnabled(); if (bleState.IsUpdated() || bleRadioEnabled.IsUpdated()) { diff --git a/src/displayapp/widgets/StatusIcons.h b/src/displayapp/widgets/StatusIcons.h index 9e21d3add0..00f2b04de6 100644 --- a/src/displayapp/widgets/StatusIcons.h +++ b/src/displayapp/widgets/StatusIcons.h @@ -5,6 +5,7 @@ #include "displayapp/screens/Screen.h" #include "components/battery/BatteryController.h" #include "components/ble/BleController.h" +#include "components/alarm/AlarmController.h" #include "displayapp/screens/BatteryIcon.h" #include "utility/DirtyValue.h" @@ -13,7 +14,9 @@ namespace Pinetime { namespace Widgets { class StatusIcons { public: - StatusIcons(const Controllers::Battery& batteryController, const Controllers::Ble& bleController); + StatusIcons(const Controllers::Battery& batteryController, + const Controllers::Ble& bleController, + const Controllers::AlarmController& alarmController); void Align(); void Create(); @@ -27,6 +30,7 @@ namespace Pinetime { Screens::BatteryIcon batteryIcon; const Pinetime::Controllers::Battery& batteryController; const Controllers::Ble& bleController; + const Controllers::AlarmController& alarmController; Utility::DirtyValue batteryPercentRemaining {}; Utility::DirtyValue powerPresent {}; @@ -34,6 +38,7 @@ namespace Pinetime { Utility::DirtyValue bleRadioEnabled {}; lv_obj_t* bleIcon; + lv_obj_t* alarmIcon; lv_obj_t* batteryPlug; lv_obj_t* container; };