Skip to content

Commit

Permalink
Show alarm controller state in status icons
Browse files Browse the repository at this point in the history
  • Loading branch information
jmlich committed Oct 8, 2023
1 parent eac460f commit 844ef9b
Show file tree
Hide file tree
Showing 13 changed files with 40 additions and 10 deletions.
6 changes: 4 additions & 2 deletions src/displayapp/DisplayApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio
switch (app) {
case Apps::Launcher:
currentScreen =
std::make_unique<Screens::ApplicationList>(this, settingsController, batteryController, bleController, dateTimeController, filesystem);
std::make_unique<Screens::ApplicationList>(this, settingsController, batteryController, bleController, alarmController, dateTimeController, filesystem);
break;
case Apps::Motion:
// currentScreen = std::make_unique<Screens::Motion>(motionController);
Expand All @@ -414,6 +414,7 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio
currentScreen = std::make_unique<Screens::Clock>(dateTimeController,
batteryController,
bleController,
alarmController,
notificationManager,
settingsController,
heartRateController,
Expand Down Expand Up @@ -468,7 +469,8 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio
brightnessController,
motorController,
settingsController,
bleController);
bleController,
alarmController);
break;
case Apps::Settings:
currentScreen = std::make_unique<Screens::Settings>(this, settingsController);
Expand Down
3 changes: 3 additions & 0 deletions src/displayapp/screens/ApplicationList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ ApplicationList::ApplicationList(Pinetime::Applications::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)
: app {app},
settingsController {settingsController},
batteryController {batteryController},
bleController {bleController},
alarmController {alarmController},
dateTimeController {dateTimeController},
filesystem{filesystem},
screens {app, settingsController.GetAppMenu(), CreateScreenList(), Screens::ScreenListModes::UpDown} {
Expand All @@ -51,6 +53,7 @@ std::unique_ptr<Screen> ApplicationList::CreateScreen(unsigned int screenNum) co
settingsController,
batteryController,
bleController,
alarmController,
dateTimeController,
apps);
}
2 changes: 2 additions & 0 deletions src/displayapp/screens/ApplicationList.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,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);
~ApplicationList() override;
Expand All @@ -34,6 +35,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;

Expand Down
3 changes: 3 additions & 0 deletions src/displayapp/screens/Clock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ 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,
Expand All @@ -29,6 +30,7 @@ Clock::Clock(Controllers::DateTime& dateTimeController,
: dateTimeController {dateTimeController},
batteryController {batteryController},
bleController {bleController},
alarmController {alarmController},
notificationManager {notificationManager},
settingsController {settingsController},
heartRateController {heartRateController},
Expand Down Expand Up @@ -77,6 +79,7 @@ std::unique_ptr<Screen> Clock::WatchFaceDigitalScreen() {
return std::make_unique<Screens::WatchFaceDigital>(dateTimeController,
batteryController,
bleController,
alarmController,
notificationManager,
settingsController,
heartRateController,
Expand Down
3 changes: 3 additions & 0 deletions src/displayapp/screens/Clock.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace Pinetime {
class Settings;
class Battery;
class Ble;
class AlarmController;
class NotificationManager;
class MotionController;
}
Expand All @@ -25,6 +26,7 @@ namespace Pinetime {
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,
Expand All @@ -40,6 +42,7 @@ namespace Pinetime {
Controllers::DateTime& dateTimeController;
const Controllers::Battery& batteryController;
const Controllers::Ble& bleController;
const Controllers::AlarmController& alarmController;
Controllers::NotificationManager& notificationManager;
Controllers::Settings& settingsController;
Controllers::HeartRateController& heartRateController;
Expand Down
3 changes: 2 additions & 1 deletion src/displayapp/screens/Tile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ 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, 6>& 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);

Expand Down
1 change: 1 addition & 0 deletions src/displayapp/screens/Tile.h
Original file line number Diff line number Diff line change
Expand Up @@ -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, 6>& applications);

Expand Down
3 changes: 2 additions & 1 deletion src/displayapp/screens/WatchFaceDigital.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,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,
Expand All @@ -26,7 +27,7 @@ WatchFaceDigital::WatchFaceDigital(Controllers::DateTime& dateTimeController,
settingsController {settingsController},
heartRateController {heartRateController},
motionController {motionController},
statusIcons(batteryController, bleController) {
statusIcons(batteryController, bleController, alarmController) {

statusIcons.Create();

Expand Down
2 changes: 2 additions & 0 deletions src/displayapp/screens/WatchFaceDigital.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ namespace Pinetime {
class Settings;
class Battery;
class Ble;
class AlarmController;
class NotificationManager;
class HeartRateController;
class MotionController;
Expand All @@ -28,6 +29,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,
Expand Down
5 changes: 3 additions & 2 deletions src/displayapp/screens/settings/QuickSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
3 changes: 2 additions & 1 deletion src/displayapp/screens/settings/QuickSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
11 changes: 9 additions & 2 deletions src/displayapp/widgets/StatusIcons.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#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() {
Expand All @@ -20,6 +22,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);
Expand All @@ -37,6 +42,8 @@ void StatusIcons::Update() {
batteryIcon.SetBatteryPercentage(batteryPercent);
}

lv_obj_set_hidden(alarmIcon, (alarmController.State() == Pinetime::Controllers::AlarmController::AlarmState::Not_Set));

bleState = bleController.IsConnected();
bleRadioEnabled = bleController.IsRadioEnabled();
if (bleState.IsUpdated() || bleRadioEnabled.IsUpdated()) {
Expand Down
5 changes: 4 additions & 1 deletion src/displayapp/widgets/StatusIcons.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -13,7 +14,7 @@ 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();

Expand All @@ -27,13 +28,15 @@ namespace Pinetime {
Screens::BatteryIcon batteryIcon;
const Pinetime::Controllers::Battery& batteryController;
const Controllers::Ble& bleController;
const Controllers::AlarmController& alarmController;

Utility::DirtyValue<uint8_t> batteryPercentRemaining {};
Utility::DirtyValue<bool> powerPresent {};
Utility::DirtyValue<bool> bleState {};
Utility::DirtyValue<bool> bleRadioEnabled {};

lv_obj_t* bleIcon;
lv_obj_t* alarmIcon;
lv_obj_t* batteryPlug;
lv_obj_t* container;
};
Expand Down

0 comments on commit 844ef9b

Please sign in to comment.