Skip to content

Commit

Permalink
Show alarm controller state in status icon
Browse files Browse the repository at this point in the history
  • Loading branch information
jmlich committed Dec 22, 2024
1 parent d69cfcf commit fad6d20
Show file tree
Hide file tree
Showing 14 changed files with 243 additions and 9 deletions.
4 changes: 3 additions & 1 deletion src/displayapp/DisplayApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,7 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio
settingsController,
batteryController,
bleController,
alarmController,
dateTimeController,
filesystem,
std::move(apps));
Expand Down Expand Up @@ -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<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 @@ -21,13 +21,15 @@ 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<Tile::Applications, UserAppTypes::Count>&& apps)
: app {app},
settingsController {settingsController},
batteryController {batteryController},
bleController {bleController},
alarmController {alarmController},
dateTimeController {dateTimeController},
filesystem {filesystem},
apps {std::move(apps)},
Expand Down Expand Up @@ -59,6 +61,7 @@ std::unique_ptr<Screen> ApplicationList::CreateScreen(unsigned int screenNum) co
settingsController,
batteryController,
bleController,
alarmController,
dateTimeController,
pageApps);
}
2 changes: 2 additions & 0 deletions src/displayapp/screens/ApplicationList.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<Tile::Applications, UserAppTypes::Count>&& apps);
Expand All @@ -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<Tile::Applications, UserAppTypes::Count> apps;
Expand Down
136 changes: 136 additions & 0 deletions src/displayapp/screens/Clock.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
#include "displayapp/screens/Clock.h"

#include <lvgl/lvgl.h>
#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<Screen> Clock::WatchFaceDigitalScreen() {
return std::make_unique<Screens::WatchFaceDigital>(dateTimeController,
batteryController,
bleController,
alarmController,
notificationManager,
settingsController,
heartRateController,
motionController);
}

std::unique_ptr<Screen> Clock::WatchFaceAnalogScreen() {
return std::make_unique<Screens::WatchFaceAnalog>(dateTimeController,
batteryController,
bleController,
notificationManager,
settingsController);
}

std::unique_ptr<Screen> Clock::WatchFacePineTimeStyleScreen() {
return std::make_unique<Screens::WatchFacePineTimeStyle>(dateTimeController,
batteryController,
bleController,
notificationManager,
settingsController,
motionController,
weatherService);
}

std::unique_ptr<Screen> Clock::WatchFaceTerminalScreen() {
return std::make_unique<Screens::WatchFaceTerminal>(dateTimeController,
batteryController,
bleController,
notificationManager,
settingsController,
heartRateController,
motionController);
}

std::unique_ptr<Screen> Clock::WatchFaceInfineatScreen() {
return std::make_unique<Screens::WatchFaceInfineat>(dateTimeController,
batteryController,
bleController,
notificationManager,
settingsController,
motionController,
filesystem);
}

std::unique_ptr<Screen> Clock::WatchFaceCasioStyleG7710() {
return std::make_unique<Screens::WatchFaceCasioStyleG7710>(dateTimeController,
batteryController,
bleController,
notificationManager,
settingsController,
heartRateController,
motionController,
filesystem);
}
66 changes: 66 additions & 0 deletions src/displayapp/screens/Clock.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#pragma once

#include <chrono>
#include <cstdint>
#include <memory>
#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> screen;
std::unique_ptr<Screen> WatchFaceDigitalScreen();
std::unique_ptr<Screen> WatchFaceAnalogScreen();
std::unique_ptr<Screen> WatchFacePineTimeStyleScreen();
std::unique_ptr<Screen> WatchFaceTerminalScreen();
std::unique_ptr<Screen> WatchFaceInfineatScreen();
std::unique_ptr<Screen> WatchFaceCasioStyleG7710();
};
}
}
}
1 change: 1 addition & 0 deletions src/displayapp/screens/SystemInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen2() {

extern int mallocFailedCount;
extern int stackOverflowCount;

std::unique_ptr<Screen> SystemInfo::CreateScreen3() {
lv_mem_monitor_t mon;
lv_mem_monitor(&mon);
Expand Down
6 changes: 5 additions & 1 deletion src/displayapp/screens/Tile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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, 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 @@ -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,
Expand All @@ -31,7 +32,7 @@ WatchFaceDigital::WatchFaceDigital(Controllers::DateTime& dateTimeController,
heartRateController {heartRateController},
motionController {motionController},
weatherService {weatherService},
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 @@ -17,6 +17,7 @@ namespace Pinetime {
class Settings;
class Battery;
class Ble;
class AlarmController;
class NotificationManager;
class HeartRateController;
class MotionController;
Expand All @@ -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,
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
13 changes: 11 additions & 2 deletions src/displayapp/widgets/StatusIcons.cpp
Original file line number Diff line number Diff line change
@@ -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() {
Expand All @@ -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);
Expand All @@ -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()) {
Expand Down
Loading

0 comments on commit fad6d20

Please sign in to comment.