Notifications: use motorController object instead of class function

We get the motoroController object, so store and use it.
This commit is contained in:
Reinhold Gschweicher 2022-01-29 23:34:09 +01:00 committed by JF
parent d5b78ecd66
commit 04eca81a95
2 changed files with 19 additions and 10 deletions

View File

@ -17,6 +17,7 @@ Notifications::Notifications(DisplayApp* app,
: Screen(app), : Screen(app),
notificationManager {notificationManager}, notificationManager {notificationManager},
alertNotificationService {alertNotificationService}, alertNotificationService {alertNotificationService},
motorController {motorController},
systemTask {systemTask}, systemTask {systemTask},
mode {mode} { mode {mode} {
notificationManager.ClearNewNotificationFlag(); notificationManager.ClearNewNotificationFlag();
@ -29,7 +30,8 @@ Notifications::Notifications(DisplayApp* app,
notification.category, notification.category,
notificationManager.NbNotifications(), notificationManager.NbNotifications(),
mode, mode,
alertNotificationService); alertNotificationService,
motorController);
validDisplay = true; validDisplay = true;
} else { } else {
currentItem = std::make_unique<NotificationItem>("Notification", currentItem = std::make_unique<NotificationItem>("Notification",
@ -38,7 +40,8 @@ Notifications::Notifications(DisplayApp* app,
notification.category, notification.category,
notificationManager.NbNotifications(), notificationManager.NbNotifications(),
Modes::Preview, Modes::Preview,
alertNotificationService); alertNotificationService,
motorController);
} }
if (mode == Modes::Preview) { if (mode == Modes::Preview) {
@ -66,7 +69,7 @@ Notifications::Notifications(DisplayApp* app,
Notifications::~Notifications() { Notifications::~Notifications() {
lv_task_del(taskRefresh); lv_task_del(taskRefresh);
// make sure we stop any vibrations before exiting // make sure we stop any vibrations before exiting
Controllers::MotorController::StopRinging(); motorController.StopRinging();
systemTask.PushMessage(System::Messages::EnableSleeping); systemTask.PushMessage(System::Messages::EnableSleeping);
lv_obj_clean(lv_scr_act()); lv_obj_clean(lv_scr_act());
} }
@ -87,7 +90,7 @@ void Notifications::Refresh() {
void Notifications::OnPreviewInteraction() { void Notifications::OnPreviewInteraction() {
systemTask.PushMessage(System::Messages::EnableSleeping); systemTask.PushMessage(System::Messages::EnableSleeping);
Controllers::MotorController::StopRinging(); motorController.StopRinging();
if (timeoutLine != nullptr) { if (timeoutLine != nullptr) {
lv_obj_del(timeoutLine); lv_obj_del(timeoutLine);
timeoutLine = nullptr; timeoutLine = nullptr;
@ -125,7 +128,8 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
previousNotification.category, previousNotification.category,
notificationManager.NbNotifications(), notificationManager.NbNotifications(),
mode, mode,
alertNotificationService); alertNotificationService,
motorController);
} }
return true; return true;
case Pinetime::Applications::TouchEvents::SwipeUp: { case Pinetime::Applications::TouchEvents::SwipeUp: {
@ -150,7 +154,8 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
nextNotification.category, nextNotification.category,
notificationManager.NbNotifications(), notificationManager.NbNotifications(),
mode, mode,
alertNotificationService); alertNotificationService,
motorController);
} }
return true; return true;
default: default:
@ -171,8 +176,9 @@ Notifications::NotificationItem::NotificationItem(const char* title,
Controllers::NotificationManager::Categories category, Controllers::NotificationManager::Categories category,
uint8_t notifNb, uint8_t notifNb,
Modes mode, Modes mode,
Pinetime::Controllers::AlertNotificationService& alertNotificationService) Pinetime::Controllers::AlertNotificationService& alertNotificationService,
: mode {mode}, alertNotificationService {alertNotificationService} { Pinetime::Controllers::MotorController& motorController)
: mode {mode}, alertNotificationService {alertNotificationService}, motorController {motorController} {
lv_obj_t* container1 = lv_cont_create(lv_scr_act(), NULL); lv_obj_t* container1 = lv_cont_create(lv_scr_act(), NULL);
lv_obj_set_style_local_bg_color(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x222222)); 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_
return; return;
} }
Controllers::MotorController::StopRinging(); motorController.StopRinging();
if (obj == bt_accept) { if (obj == bt_accept) {
alertNotificationService.AcceptIncomingCall(); alertNotificationService.AcceptIncomingCall();

View File

@ -39,7 +39,8 @@ namespace Pinetime {
Controllers::NotificationManager::Categories, Controllers::NotificationManager::Categories,
uint8_t notifNb, uint8_t notifNb,
Modes mode, Modes mode,
Pinetime::Controllers::AlertNotificationService& alertNotificationService); Pinetime::Controllers::AlertNotificationService& alertNotificationService,
Pinetime::Controllers::MotorController& motorController);
~NotificationItem(); ~NotificationItem();
bool IsRunning() const { bool IsRunning() const {
return running; return running;
@ -56,6 +57,7 @@ namespace Pinetime {
lv_obj_t* label_reject; lv_obj_t* label_reject;
Modes mode; Modes mode;
Pinetime::Controllers::AlertNotificationService& alertNotificationService; Pinetime::Controllers::AlertNotificationService& alertNotificationService;
Pinetime::Controllers::MotorController& motorController;
bool running = true; bool running = true;
}; };
@ -66,6 +68,7 @@ namespace Pinetime {
}; };
Pinetime::Controllers::NotificationManager& notificationManager; Pinetime::Controllers::NotificationManager& notificationManager;
Pinetime::Controllers::AlertNotificationService& alertNotificationService; Pinetime::Controllers::AlertNotificationService& alertNotificationService;
Pinetime::Controllers::MotorController& motorController;
System::SystemTask& systemTask; System::SystemTask& systemTask;
Modes mode = Modes::Normal; Modes mode = Modes::Normal;
std::unique_ptr<NotificationItem> currentItem; std::unique_ptr<NotificationItem> currentItem;