Skip to content

Commit 44dc6d4

Browse files
JustScottvkareh
authored andcommitted
Add Timer's Time Remaining to the StatusIcons bar
When a timer is active the time remaining will be displayed in the StatusIcons bar along with an hour glass symbol, and will be set to hidden when the timer's off.
1 parent 7128fc0 commit 44dc6d4

File tree

13 files changed

+120
-17
lines changed

13 files changed

+120
-17
lines changed

src/components/timer/Timer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ void Timer::StartTimer(std::chrono::milliseconds duration) {
1515

1616
// nullopt if timer stopped (StopTimer called / StartTimer not yet called)
1717
// otherwise TimerStatus with the ticks until/since expiry (depending on state of expired flag)
18-
std::optional<Timer::TimerStatus> Timer::GetTimerState() {
18+
std::optional<Timer::TimerStatus> Timer::GetTimerState() const {
1919
if (IsRunning()) {
2020
TickType_t remainingTime = expiry - xTaskGetTickCount();
2121
return std::make_optional<Timer::TimerStatus>(
@@ -38,6 +38,6 @@ void Timer::StopTimer() {
3838
triggered = false;
3939
}
4040

41-
bool Timer::IsRunning() {
41+
bool Timer::IsRunning() const {
4242
return (xTimerIsTimerActive(timer) == pdTRUE);
4343
}

src/components/timer/Timer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ namespace Pinetime {
2121

2222
void StopTimer();
2323

24-
std::optional<TimerStatus> GetTimerState();
24+
std::optional<TimerStatus> GetTimerState() const;
2525

26-
bool IsRunning();
26+
bool IsRunning() const;
2727

2828
private:
2929
TimerHandle_t timer;

src/displayapp/DisplayApp.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,7 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio
530530
batteryController,
531531
bleController,
532532
alarmController,
533+
timer,
533534
dateTimeController,
534535
filesystem,
535536
std::move(apps));
@@ -584,7 +585,8 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio
584585
motorController,
585586
settingsController,
586587
bleController,
587-
alarmController);
588+
alarmController,
589+
timer);
588590
break;
589591
case Apps::Settings:
590592
currentScreen = std::make_unique<Screens::Settings>(this, settingsController);

src/displayapp/screens/ApplicationList.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ ApplicationList::ApplicationList(DisplayApp* app,
2222
const Pinetime::Controllers::Battery& batteryController,
2323
const Pinetime::Controllers::Ble& bleController,
2424
const Pinetime::Controllers::AlarmController& alarmController,
25+
const Controllers::Timer& timer,
2526
Controllers::DateTime& dateTimeController,
2627
Pinetime::Controllers::FS& filesystem,
2728
std::array<Tile::Applications, UserAppTypes::Count>&& apps)
@@ -30,6 +31,7 @@ ApplicationList::ApplicationList(DisplayApp* app,
3031
batteryController {batteryController},
3132
bleController {bleController},
3233
alarmController {alarmController},
34+
timer {timer},
3335
dateTimeController {dateTimeController},
3436
filesystem {filesystem},
3537
apps {std::move(apps)},
@@ -62,6 +64,7 @@ std::unique_ptr<Screen> ApplicationList::CreateScreen(unsigned int screenNum) co
6264
batteryController,
6365
bleController,
6466
alarmController,
67+
timer,
6568
dateTimeController,
6669
pageApps);
6770
}

src/displayapp/screens/ApplicationList.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ namespace Pinetime {
1919
const Pinetime::Controllers::Battery& batteryController,
2020
const Pinetime::Controllers::Ble& bleController,
2121
const Pinetime::Controllers::AlarmController& alarmController,
22+
const Pinetime::Controllers::Timer& timer,
2223
Controllers::DateTime& dateTimeController,
2324
Pinetime::Controllers::FS& filesystem,
2425
std::array<Tile::Applications, UserAppTypes::Count>&& apps);
@@ -34,6 +35,7 @@ namespace Pinetime {
3435
const Pinetime::Controllers::Battery& batteryController;
3536
const Pinetime::Controllers::Ble& bleController;
3637
const Pinetime::Controllers::AlarmController& alarmController;
38+
const Pinetime::Controllers::Timer& timer;
3739
Controllers::DateTime& dateTimeController;
3840
Pinetime::Controllers::FS& filesystem;
3941
std::array<Tile::Applications, UserAppTypes::Count> apps;

src/displayapp/screens/Tile.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,13 @@ Tile::Tile(uint8_t screenID,
3030
const Controllers::Battery& batteryController,
3131
const Controllers::Ble& bleController,
3232
const Controllers::AlarmController& alarmController,
33+
const Controllers::Timer& timer,
3334
Controllers::DateTime& dateTimeController,
3435
std::array<Applications, 6>& applications)
3536
: app {app},
3637
dateTimeController {dateTimeController},
3738
pageIndicator(screenID, numScreens),
38-
statusIcons(batteryController, bleController, alarmController) {
39+
statusIcons(batteryController, bleController, alarmController, timer, settingsController) {
3940

4041
settingsController.SetAppMenu(screenID);
4142

@@ -86,7 +87,7 @@ Tile::Tile(uint8_t screenID,
8687
btnm1->user_data = this;
8788
lv_obj_set_event_cb(btnm1, event_handler);
8889

89-
taskUpdate = lv_task_create(lv_update_task, 5000, LV_TASK_PRIO_MID, this);
90+
taskUpdate = lv_task_create(lv_update_task, 500, LV_TASK_PRIO_MID, this);
9091

9192
UpdateScreen();
9293
}

src/displayapp/screens/Tile.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ namespace Pinetime {
2929
const Controllers::Battery& batteryController,
3030
const Controllers::Ble& bleController,
3131
const Controllers::AlarmController& alarmController,
32+
const Controllers::Timer& timer,
3233
Controllers::DateTime& dateTimeController,
3334
std::array<Applications, 6>& applications);
3435

src/displayapp/screens/WatchFaceDigital.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ WatchFaceDigital::WatchFaceDigital(Controllers::DateTime& dateTimeController,
2020
const Controllers::Battery& batteryController,
2121
const Controllers::Ble& bleController,
2222
const Controllers::AlarmController& alarmController,
23+
const Controllers::Timer& timer,
2324
Controllers::NotificationManager& notificationManager,
2425
Controllers::Settings& settingsController,
2526
Controllers::HeartRateController& heartRateController,
@@ -32,7 +33,7 @@ WatchFaceDigital::WatchFaceDigital(Controllers::DateTime& dateTimeController,
3233
heartRateController {heartRateController},
3334
motionController {motionController},
3435
weatherService {weatherService},
35-
statusIcons(batteryController, bleController, alarmController) {
36+
statusIcons(batteryController, bleController, alarmController, timer, settingsController) {
3637

3738
statusIcons.Create();
3839

src/displayapp/screens/WatchFaceDigital.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ namespace Pinetime {
2121
class NotificationManager;
2222
class HeartRateController;
2323
class MotionController;
24+
class Timer;
2425
}
2526

2627
namespace Applications {
@@ -32,6 +33,7 @@ namespace Pinetime {
3233
const Controllers::Battery& batteryController,
3334
const Controllers::Ble& bleController,
3435
const Controllers::AlarmController& alarmController,
36+
const Controllers::Timer& timer,
3537
Controllers::NotificationManager& notificationManager,
3638
Controllers::Settings& settingsController,
3739
Controllers::HeartRateController& heartRateController,
@@ -87,6 +89,7 @@ namespace Pinetime {
8789
controllers.batteryController,
8890
controllers.bleController,
8991
controllers.alarmController,
92+
controllers.timer,
9093
controllers.notificationManager,
9194
controllers.settingsController,
9295
controllers.heartRateController,

src/displayapp/screens/settings/QuickSettings.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,14 @@ QuickSettings::QuickSettings(Pinetime::Applications::DisplayApp* app,
3434
Controllers::MotorController& motorController,
3535
Pinetime::Controllers::Settings& settingsController,
3636
const Controllers::Ble& bleController,
37-
const Controllers::AlarmController& alarmController)
37+
const Controllers::AlarmController& alarmController,
38+
const Controllers::Timer& timer)
3839
: app {app},
3940
dateTimeController {dateTimeController},
4041
brightness {brightness},
4142
motorController {motorController},
4243
settingsController {settingsController},
43-
statusIcons(batteryController, bleController, alarmController) {
44+
statusIcons(batteryController, bleController, alarmController, timer, settingsController) {
4445

4546
statusIcons.Create();
4647

@@ -119,7 +120,7 @@ QuickSettings::QuickSettings(Pinetime::Applications::DisplayApp* app,
119120
lv_obj_set_style_local_text_font(lbl_btn, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_sys_48);
120121
lv_label_set_text_static(lbl_btn, Symbols::settings);
121122

122-
taskUpdate = lv_task_create(lv_update_task, 5000, LV_TASK_PRIO_MID, this);
123+
taskUpdate = lv_task_create(lv_update_task, 500, LV_TASK_PRIO_MID, this);
123124

124125
UpdateScreen();
125126
}

0 commit comments

Comments
 (0)