Skip to content

Commit 04eca81

Browse files
NeroBurnerJF002
authored andcommitted
Notifications: use motorController object instead of class function
We get the motoroController object, so store and use it.
1 parent d5b78ec commit 04eca81

2 files changed

Lines changed: 19 additions & 10 deletions

File tree

src/displayapp/screens/Notifications.cpp

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Notifications::Notifications(DisplayApp* app,
1717
: Screen(app),
1818
notificationManager {notificationManager},
1919
alertNotificationService {alertNotificationService},
20+
motorController {motorController},
2021
systemTask {systemTask},
2122
mode {mode} {
2223
notificationManager.ClearNewNotificationFlag();
@@ -29,7 +30,8 @@ Notifications::Notifications(DisplayApp* app,
2930
notification.category,
3031
notificationManager.NbNotifications(),
3132
mode,
32-
alertNotificationService);
33+
alertNotificationService,
34+
motorController);
3335
validDisplay = true;
3436
} else {
3537
currentItem = std::make_unique<NotificationItem>("Notification",
@@ -38,7 +40,8 @@ Notifications::Notifications(DisplayApp* app,
3840
notification.category,
3941
notificationManager.NbNotifications(),
4042
Modes::Preview,
41-
alertNotificationService);
43+
alertNotificationService,
44+
motorController);
4245
}
4346

4447
if (mode == Modes::Preview) {
@@ -66,7 +69,7 @@ Notifications::Notifications(DisplayApp* app,
6669
Notifications::~Notifications() {
6770
lv_task_del(taskRefresh);
6871
// make sure we stop any vibrations before exiting
69-
Controllers::MotorController::StopRinging();
72+
motorController.StopRinging();
7073
systemTask.PushMessage(System::Messages::EnableSleeping);
7174
lv_obj_clean(lv_scr_act());
7275
}
@@ -87,7 +90,7 @@ void Notifications::Refresh() {
8790

8891
void Notifications::OnPreviewInteraction() {
8992
systemTask.PushMessage(System::Messages::EnableSleeping);
90-
Controllers::MotorController::StopRinging();
93+
motorController.StopRinging();
9194
if (timeoutLine != nullptr) {
9295
lv_obj_del(timeoutLine);
9396
timeoutLine = nullptr;
@@ -125,7 +128,8 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
125128
previousNotification.category,
126129
notificationManager.NbNotifications(),
127130
mode,
128-
alertNotificationService);
131+
alertNotificationService,
132+
motorController);
129133
}
130134
return true;
131135
case Pinetime::Applications::TouchEvents::SwipeUp: {
@@ -150,7 +154,8 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
150154
nextNotification.category,
151155
notificationManager.NbNotifications(),
152156
mode,
153-
alertNotificationService);
157+
alertNotificationService,
158+
motorController);
154159
}
155160
return true;
156161
default:
@@ -171,8 +176,9 @@ Notifications::NotificationItem::NotificationItem(const char* title,
171176
Controllers::NotificationManager::Categories category,
172177
uint8_t notifNb,
173178
Modes mode,
174-
Pinetime::Controllers::AlertNotificationService& alertNotificationService)
175-
: mode {mode}, alertNotificationService {alertNotificationService} {
179+
Pinetime::Controllers::AlertNotificationService& alertNotificationService,
180+
Pinetime::Controllers::MotorController& motorController)
181+
: mode {mode}, alertNotificationService {alertNotificationService}, motorController {motorController} {
176182
lv_obj_t* container1 = lv_cont_create(lv_scr_act(), NULL);
177183

178184
lv_obj_set_style_local_bg_color(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x222222));
@@ -269,7 +275,7 @@ void Notifications::NotificationItem::OnCallButtonEvent(lv_obj_t* obj, lv_event_
269275
return;
270276
}
271277

272-
Controllers::MotorController::StopRinging();
278+
motorController.StopRinging();
273279

274280
if (obj == bt_accept) {
275281
alertNotificationService.AcceptIncomingCall();

src/displayapp/screens/Notifications.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ namespace Pinetime {
3939
Controllers::NotificationManager::Categories,
4040
uint8_t notifNb,
4141
Modes mode,
42-
Pinetime::Controllers::AlertNotificationService& alertNotificationService);
42+
Pinetime::Controllers::AlertNotificationService& alertNotificationService,
43+
Pinetime::Controllers::MotorController& motorController);
4344
~NotificationItem();
4445
bool IsRunning() const {
4546
return running;
@@ -56,6 +57,7 @@ namespace Pinetime {
5657
lv_obj_t* label_reject;
5758
Modes mode;
5859
Pinetime::Controllers::AlertNotificationService& alertNotificationService;
60+
Pinetime::Controllers::MotorController& motorController;
5961
bool running = true;
6062
};
6163

@@ -66,6 +68,7 @@ namespace Pinetime {
6668
};
6769
Pinetime::Controllers::NotificationManager& notificationManager;
6870
Pinetime::Controllers::AlertNotificationService& alertNotificationService;
71+
Pinetime::Controllers::MotorController& motorController;
6972
System::SystemTask& systemTask;
7073
Modes mode = Modes::Normal;
7174
std::unique_ptr<NotificationItem> currentItem;

0 commit comments

Comments
 (0)