Skip to content

Commit ae6fb5d

Browse files
committed
Notification screen at max brightness when walking
1 parent 8250565 commit ae6fb5d

5 files changed

Lines changed: 31 additions & 0 deletions

File tree

src/components/motion/MotionController.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ void MotionController::Update(int16_t x, int16_t y, int16_t z, uint32_t nbSteps)
7676
int32_t deltaSteps = nbSteps - oldSteps;
7777
if (deltaSteps > 0) {
7878
currentTripSteps += deltaSteps;
79+
locomotionDecay = 50; // 5 seconds x 10Hz
80+
} else if (locomotionDecay > 0) {
81+
locomotionDecay--;
7982
}
8083
SetSteps(Days::Today, nbSteps);
8184
}

src/components/motion/MotionController.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ namespace Pinetime {
7474
return service;
7575
}
7676

77+
bool Locomotion() const {
78+
return (locomotionDecay != 0);
79+
}
80+
7781
private:
7882
Utility::CircularBuffer<uint32_t, stepHistorySize> nbSteps = {0};
7983
uint32_t currentTripSteps = 0;
@@ -112,6 +116,7 @@ namespace Pinetime {
112116

113117
DeviceTypes deviceType = DeviceTypes::Unknown;
114118
Pinetime::Controllers::MotionService* service = nullptr;
119+
uint8_t locomotionDecay = 0;
115120
};
116121
}
117122
}

src/displayapp/DisplayApp.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,8 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio
568568
notificationManager,
569569
systemTask->nimble().alertService(),
570570
motorController,
571+
brightnessController,
572+
motionController,
571573
*systemTask,
572574
Screens::Notifications::Modes::Normal);
573575
break;
@@ -576,6 +578,8 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio
576578
notificationManager,
577579
systemTask->nimble().alertService(),
578580
motorController,
581+
brightnessController,
582+
motionController,
579583
*systemTask,
580584
Screens::Notifications::Modes::Preview);
581585
break;

src/displayapp/screens/Notifications.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#include "displayapp/DisplayApp.h"
33
#include "components/ble/MusicService.h"
44
#include "components/ble/AlertNotificationService.h"
5+
#include "components/brightness/BrightnessController.h"
6+
#include "components/motion/MotionController.h"
57
#include "displayapp/screens/Symbols.h"
68
#include <algorithm>
79
#include "displayapp/InfiniTimeTheme.h"
@@ -14,12 +16,16 @@ Notifications::Notifications(DisplayApp* app,
1416
Pinetime::Controllers::NotificationManager& notificationManager,
1517
Pinetime::Controllers::AlertNotificationService& alertNotificationService,
1618
Pinetime::Controllers::MotorController& motorController,
19+
Pinetime::Controllers::BrightnessController& brightnessController,
20+
Pinetime::Controllers::MotionController& motionController,
1721
System::SystemTask& systemTask,
1822
Modes mode)
1923
: app {app},
2024
notificationManager {notificationManager},
2125
alertNotificationService {alertNotificationService},
2226
motorController {motorController},
27+
brightnessController {brightnessController},
28+
motionController {motionController},
2329
wakeLock(systemTask),
2430
mode {mode} {
2531

@@ -58,6 +64,10 @@ Notifications::Notifications(DisplayApp* app,
5864
interacted = false;
5965
}
6066

67+
previousBrightnessLevel = brightnessController.Level();
68+
if (motionController.Locomotion()) {
69+
brightnessController.Set(Pinetime::Controllers::BrightnessController::Levels::High);
70+
}
6171
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
6272
}
6373

@@ -66,6 +76,7 @@ Notifications::~Notifications() {
6676
// make sure we stop any vibrations before exiting
6777
motorController.StopRinging();
6878
lv_obj_clean(lv_scr_act());
79+
brightnessController.Set(previousBrightnessLevel);
6980
}
7081

7182
void Notifications::Refresh() {

src/displayapp/screens/Notifications.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#include "displayapp/screens/Screen.h"
88
#include "components/ble/NotificationManager.h"
99
#include "components/motor/MotorController.h"
10+
#include "components/brightness/BrightnessController.h"
11+
#include "components/motion/MotionController.h"
1012
#include "systemtask/SystemTask.h"
1113
#include "systemtask/WakeLock.h"
1214

@@ -25,6 +27,8 @@ namespace Pinetime {
2527
Pinetime::Controllers::NotificationManager& notificationManager,
2628
Pinetime::Controllers::AlertNotificationService& alertNotificationService,
2729
Pinetime::Controllers::MotorController& motorController,
30+
Pinetime::Controllers::BrightnessController& brightnessController,
31+
Pinetime::Controllers::MotionController& motionController,
2832
System::SystemTask& systemTask,
2933
Modes mode);
3034
~Notifications() override;
@@ -74,6 +78,8 @@ namespace Pinetime {
7478
Pinetime::Controllers::NotificationManager& notificationManager;
7579
Pinetime::Controllers::AlertNotificationService& alertNotificationService;
7680
Pinetime::Controllers::MotorController& motorController;
81+
Pinetime::Controllers::BrightnessController& brightnessController;
82+
Pinetime::Controllers::MotionController& motionController;
7783
System::WakeLock wakeLock;
7884
Modes mode = Modes::Normal;
7985
std::unique_ptr<NotificationItem> currentItem;
@@ -90,6 +96,8 @@ namespace Pinetime {
9096

9197
bool dismissingNotification = false;
9298

99+
Pinetime::Controllers::BrightnessController::Levels previousBrightnessLevel;
100+
93101
lv_task_t* taskRefresh;
94102
};
95103
}

0 commit comments

Comments
 (0)