From 10ba20876f37c8e18307dfbc8d06d70bb94d5fae Mon Sep 17 00:00:00 2001 From: Rasmus Schenstrom Date: Tue, 27 Oct 2020 19:51:06 +0100 Subject: Add incoming call functionality Add categories to AlertNotification Add new alert notification screens bases Add Incoming Call Add Modal Add event to AlertNotification Co-authored-by: Robin Karlsson --- src/systemtask/SystemTask.cpp | 4 ++++ src/systemtask/SystemTask.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'src/systemtask') diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index 13a84c26..2fbc8cf0 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -161,6 +161,10 @@ void SystemTask::Work() { if(isSleeping && !isWakingUp) GoToRunning(); displayApp->PushMessage(Pinetime::Applications::DisplayApp::Messages::NewNotification); break; + case Messages::OnNewCall: + if(isSleeping && !isWakingUp) GoToRunning(); + displayApp->PushMessage(Pinetime::Applications::DisplayApp::Messages::NewCall); + break; case Messages::BleConnected: ReloadIdleTimer(); isBleDiscoveryTimerRunning = true; diff --git a/src/systemtask/SystemTask.h b/src/systemtask/SystemTask.h index cf3f1021..7e031b52 100644 --- a/src/systemtask/SystemTask.h +++ b/src/systemtask/SystemTask.h @@ -27,7 +27,7 @@ namespace Pinetime { namespace System { class SystemTask { public: - enum class Messages {GoToSleep, GoToRunning, OnNewTime, OnNewNotification, BleConnected, + enum class Messages {GoToSleep, GoToRunning, OnNewTime, OnNewNotification, OnNewCall, BleConnected, BleFirmwareUpdateStarted, BleFirmwareUpdateFinished, OnTouchEvent, OnButtonEvent, OnDisplayTaskSleeping }; -- cgit v1.2.3 From 219bafb01ac11a2dc0591d37f00e1acc6d478b54 Mon Sep 17 00:00:00 2001 From: Jean-François Milants Date: Sun, 24 Jan 2021 17:22:39 +0100 Subject: Handle call notification the same way than other notifications. Display the call notifications in the Notification app, with buttons to accept/reject the call. --- src/CMakeLists.txt | 2 - src/components/ble/AlertNotificationService.cpp | 34 ++++-- src/components/ble/AlertNotificationService.h | 38 ++++--- src/displayapp/DisplayApp.cpp | 11 +- src/displayapp/DisplayApp.h | 3 +- src/displayapp/screens/Navigation.h | 4 +- src/displayapp/screens/Notifications.cpp | 133 +++++++++++++++++++++--- src/displayapp/screens/Notifications.h | 46 ++++---- src/displayapp/screens/Tile.cpp | 1 - src/displayapp/screens/Tile.h | 2 - src/main.cpp | 4 +- src/systemtask/SystemTask.cpp | 7 +- src/systemtask/SystemTask.h | 3 +- 13 files changed, 198 insertions(+), 90 deletions(-) (limited to 'src/systemtask') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5955d393..fda2b48e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -426,7 +426,6 @@ list(APPEND SOURCE_FILES displayapp/screens/InfiniPaint.cpp displayapp/screens/Paddle.cpp displayapp/screens/DropDownDemo.cpp - displayapp/screens/Modal.cpp displayapp/screens/BatteryIcon.cpp displayapp/screens/BleIcon.cpp displayapp/screens/NotificationIcon.cpp @@ -520,7 +519,6 @@ set(INCLUDE_FILES displayapp/screens/InfiniPaint.h displayapp/screens/Paddle.h displayapp/screens/DropDownDemo.h - displayapp/screens/Modal.h displayapp/screens/BatteryIcon.h displayapp/screens/BleIcon.h displayapp/screens/NotificationIcon.h diff --git a/src/components/ble/AlertNotificationService.cpp b/src/components/ble/AlertNotificationService.cpp index 88d2ea8a..5fb8338b 100644 --- a/src/components/ble/AlertNotificationService.cpp +++ b/src/components/ble/AlertNotificationService.cpp @@ -69,30 +69,46 @@ int AlertNotificationService::OnAlert(uint16_t conn_handle, uint16_t attr_handle const auto dbgPacketLen = OS_MBUF_PKTLEN(ctxt->om); size_t bufferSize = std::min(dbgPacketLen + stringTerminatorSize, maxBufferSize); auto messageSize = std::min(maxMessageSize, (bufferSize-headerSize)); - uint8_t* category = new uint8_t[1]; + Categories category; NotificationManager::Notification notif; os_mbuf_copydata(ctxt->om, headerSize, messageSize-1, notif.message.data()); - os_mbuf_copydata(ctxt->om, 0, 1, category); + os_mbuf_copydata(ctxt->om, 0, 1, &category); notif.message[messageSize-1] = '\0'; - notif.category = Pinetime::Controllers::NotificationManager::Categories::SimpleAlert; - Pinetime::System::SystemTask::Messages event = Pinetime::System::SystemTask::Messages::OnNewNotification; - switch(*category) { - case (uint8_t) ANS_TYPE_NOTIFICATION_CALL: + // TODO convert all ANS categories to NotificationController categories + switch(category) { + case Categories::Call: notif.category = Pinetime::Controllers::NotificationManager::Categories::IncomingCall; - event = Pinetime::System::SystemTask::Messages::OnNewCall; + break; + default: + notif.category = Pinetime::Controllers::NotificationManager::Categories::SimpleAlert; break; } + auto event = Pinetime::System::SystemTask::Messages::OnNewNotification; notificationManager.Push(std::move(notif)); systemTask.PushMessage(event); } return 0; } -void AlertNotificationService::event(char event) { - auto *om = ble_hs_mbuf_from_flat(&event, 1); +void AlertNotificationService::AcceptIncomingCall() { + auto response = IncomingCallResponses::Answer; + auto *om = ble_hs_mbuf_from_flat(&response, 1); + + uint16_t connectionHandle = systemTask.nimble().connHandle(); + + if (connectionHandle == 0 || connectionHandle == BLE_HS_CONN_HANDLE_NONE) { + return; + } + + ble_gattc_notify_custom(connectionHandle, eventHandle, om); +} + +void AlertNotificationService::RejectIncomingCall() { + auto response = IncomingCallResponses::Reject; + auto *om = ble_hs_mbuf_from_flat(&response, 1); uint16_t connectionHandle = systemTask.nimble().connHandle(); diff --git a/src/components/ble/AlertNotificationService.h b/src/components/ble/AlertNotificationService.h index 17153681..612a8a32 100644 --- a/src/components/ble/AlertNotificationService.h +++ b/src/components/ble/AlertNotificationService.h @@ -7,8 +7,8 @@ #undef max #undef min -//00020000-78fc-48fe-8e23-433b3a1942d0 -#define NOTIFICATION_EVENT_SERVICE_UUID_BASE {0xd0, 0x42, 0x19, 0x3a, 0x3b, 0x43, 0x23, 0x8e, 0xfe, 0x48, 0xfc, 0x78, 0x00, 0x00, 0x02, 0x00} +//00020001-78fc-48fe-8e23-433b3a1942d0 +#define NOTIFICATION_EVENT_SERVICE_UUID_BASE {0xd0, 0x42, 0x19, 0x3a, 0x3b, 0x43, 0x23, 0x8e, 0xfe, 0x48, 0xfc, 0x78, 0x01, 0x00, 0x02, 0x00} namespace Pinetime { @@ -27,24 +27,28 @@ namespace Pinetime { int OnAlert(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt *ctxt); - void event(char event); - - static const char EVENT_HANG_UP_CALL = 0x00; - static const char EVENT_ANSWER_CALL = 0x01; + void AcceptIncomingCall(); + void RejectIncomingCall(); + enum class IncomingCallResponses : uint8_t { + Reject = 0x00, + Answer = 0x01 + }; private: - static const char ANS_TYPE_SIMPLE_ALERT = 0x00; - static const char ANS_TYPE_EMAIL = 0x01; - static const char ANS_TYPE_NEWS = 0x02; - static const char ANS_TYPE_NOTIFICATION_CALL = 0x03; - static const char ANS_TYPE_MISSED_CALL = 0x04; - static const char ANS_TYPE_SMS_MMS = 0x05; - static const char ANS_TYPE_VOICE_MAIL = 0x06; - static const char ANS_TYPE_SCHEDULE = 0x07; - static const char ANS_TYPE_HIGH_PRIORITIZED_ALERT = 0x08; - static const char ANS_TYPE_INSTANT_MESSAGE = 0x09; - static const char ANS_TYPE_ALL_ALERTS = 0xff; + enum class Categories : uint8_t { + SimpleAlert = 0x00, + Email = 0x01, + News = 0x02, + Call = 0x03, + MissedCall = 0x04, + MmsSms = 0x05, + VoiceMail = 0x06, + Schedule = 0x07, + HighPrioritizedAlert = 0x08, + InstantMessage = 0x09, + All = 0xff + }; static constexpr uint16_t ansId {0x1811}; static constexpr uint16_t ansCharId {0x2a46}; diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index 879b5f22..292c21f1 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -46,7 +46,6 @@ DisplayApp::DisplayApp(Drivers::St7789 &lcd, Components::LittleVgl &lvgl, Driver heartRateController{heartRateController} { msgQueue = xQueueCreate(queueSize, itemSize); onClockApp = true; - modal.reset(new Screens::Modal(this)); } void DisplayApp::Start() { @@ -110,9 +109,6 @@ void DisplayApp::Refresh() { brightnessController.Restore(); state = States::Running; break; - case Messages::UpdateDateTime: -// modal->Show(); - break; case Messages::UpdateBleConnection: // clockScreen.SetBleConnectionState(bleController.IsConnected() ? Screens::Clock::BleConnectionStates::Connected : Screens::Clock::BleConnectionStates::NotConnected); break; @@ -124,13 +120,10 @@ void DisplayApp::Refresh() { currentScreen.reset(nullptr); lvgl.SetFullRefresh(Components::LittleVgl::FullRefreshDirections::Up); onClockApp = false; - currentScreen.reset(new Screens::Notifications(this, notificationManager, Screens::Notifications::Modes::Preview)); + currentScreen.reset(new Screens::Notifications(this, notificationManager, systemTask.nimble().alertService(), Screens::Notifications::Modes::Preview)); } } break; - case Messages::NewCall: - modal->NewNotification(notificationManager, &systemTask.nimble().alertService()); - break; case Messages::TouchEvent: { if (state != States::Running) break; auto gesture = OnTouchEvent(); @@ -218,7 +211,7 @@ void DisplayApp::RunningState() { case Apps::Music : currentScreen.reset(new Screens::Music(this, systemTask.nimble().music())); break; case Apps::Navigation : currentScreen.reset(new Screens::Navigation(this, systemTask.nimble().navigation())); break; case Apps::FirmwareValidation: currentScreen.reset(new Screens::FirmwareValidation(this, validator)); break; - case Apps::Notifications: currentScreen.reset(new Screens::Notifications(this, notificationManager, Screens::Notifications::Modes::Normal)); break; + case Apps::Notifications: currentScreen.reset(new Screens::Notifications(this, notificationManager, systemTask.nimble().alertService(), Screens::Notifications::Modes::Normal)); break; case Apps::HeartRate: currentScreen.reset(new Screens::HeartRate(this, heartRateController)); break; } nextApp = Apps::None; diff --git a/src/displayapp/DisplayApp.h b/src/displayapp/DisplayApp.h index b79df51a..077cbba0 100644 --- a/src/displayapp/DisplayApp.h +++ b/src/displayapp/DisplayApp.h @@ -34,7 +34,7 @@ namespace Pinetime { public: enum class States {Idle, Running}; enum class Messages : uint8_t {GoToSleep, GoToRunning, UpdateDateTime, UpdateBleConnection, UpdateBatteryLevel, TouchEvent, ButtonPushed, - NewNotification, NewCall, BleFirmwareUpdateStarted }; + NewNotification, BleFirmwareUpdateStarted }; enum class FullRefreshDirections { None, Up, Down }; enum class TouchModes { Gestures, Polling }; @@ -85,7 +85,6 @@ namespace Pinetime { Apps nextApp = Apps::None; bool onClockApp = false; // TODO find a better way to know that we should handle gestures and button differently for the Clock app. Controllers::BrightnessController brightnessController; - std::unique_ptr modal; Pinetime::Controllers::NotificationManager& notificationManager; Pinetime::Controllers::FirmwareValidator validator; TouchModes touchMode = TouchModes::Gestures; diff --git a/src/displayapp/screens/Navigation.h b/src/displayapp/screens/Navigation.h index 9fdd37d9..ab622496 100644 --- a/src/displayapp/screens/Navigation.h +++ b/src/displayapp/screens/Navigation.h @@ -145,7 +145,7 @@ namespace Pinetime { const lv_img_dsc_t* iconForName(std::string icon); - std::array, 89 > m_iconMap = { { + std::array, 89 > m_iconMap;/* = { { {"arrive-left", &arrive_left}, {"arrive-right", &arrive_right}, {"arrive-straight", &arrive_straight}, @@ -231,7 +231,7 @@ namespace Pinetime { {"turn-slight-right", &turn_slight_right}, {"turn-straight", &turn_straight}, {"updown", &updown}, - {"uturn", &uturn} } }; + {"uturn", &uturn} } };*/ }; } } diff --git a/src/displayapp/screens/Notifications.cpp b/src/displayapp/screens/Notifications.cpp index 51a601c4..79189164 100644 --- a/src/displayapp/screens/Notifications.cpp +++ b/src/displayapp/screens/Notifications.cpp @@ -1,18 +1,34 @@ #include "Notifications.h" #include +#include "components/ble/MusicService.h" using namespace Pinetime::Applications::Screens; -Notifications::Notifications(DisplayApp *app, Pinetime::Controllers::NotificationManager ¬ificationManager, Modes mode) : - Screen(app), notificationManager{notificationManager}, mode{mode} { +Notifications::Notifications(DisplayApp *app, + Pinetime::Controllers::NotificationManager ¬ificationManager, + Pinetime::Controllers::AlertNotificationService& alertNotificationService, + Modes mode) : + Screen(app), notificationManager{notificationManager}, alertNotificationService{alertNotificationService}, mode{mode} { notificationManager.ClearNewNotificationFlag(); auto notification = notificationManager.GetLastNotification(); if(notification.valid) { currentId = notification.id; - currentItem.reset(new NotificationItem("\nNotification", notification.message.data(), notification.index, notificationManager.NbNotifications(), mode)); + currentItem.reset(new NotificationItem("\nNotification", + notification.message.data(), + notification.index, + notification.category, + notificationManager.NbNotifications(), + mode, + alertNotificationService)); validDisplay = true; } else { - currentItem.reset(new NotificationItem("\nNotification", "No notification to display", 0, notificationManager.NbNotifications(), Modes::Preview)); + currentItem.reset(new NotificationItem("\nNotification", + "No notification to display", + 0, + notification.category, + notificationManager.NbNotifications(), + Modes::Preview, + alertNotificationService)); } if(mode == Modes::Preview) { @@ -69,7 +85,13 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) { currentId = previousNotification.id; currentItem.reset(nullptr); app->SetFullRefresh(DisplayApp::FullRefreshDirections::Up); - currentItem.reset(new NotificationItem("\nNotification", previousNotification.message.data(), previousNotification.index, notificationManager.NbNotifications(), mode)); + currentItem.reset(new NotificationItem("\nNotification", + previousNotification.message.data(), + previousNotification.index, + previousNotification.category, + notificationManager.NbNotifications(), + mode, + alertNotificationService)); } return true; case Pinetime::Applications::TouchEvents::SwipeDown: { @@ -85,7 +107,13 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) { currentId = nextNotification.id; currentItem.reset(nullptr); app->SetFullRefresh(DisplayApp::FullRefreshDirections::Down); - currentItem.reset(new NotificationItem("\nNotification", nextNotification.message.data(), nextNotification.index, notificationManager.NbNotifications(), mode)); + currentItem.reset(new NotificationItem("\nNotification", + nextNotification.message.data(), + nextNotification.index, + nextNotification.category, + notificationManager.NbNotifications(), + mode, + alertNotificationService)); } return true; default: @@ -99,9 +127,26 @@ bool Notifications::OnButtonPushed() { return true; } +namespace { + static void AcceptIncomingCallEventHandler(lv_obj_t *obj, lv_event_t event) { + auto* item = static_cast(obj->user_data); + item->OnAcceptIncomingCall(event); + } -Notifications::NotificationItem::NotificationItem(const char *title, const char *msg, uint8_t notifNr, uint8_t notifNb, Modes mode) - : notifNr{notifNr}, notifNb{notifNb}, mode{mode} { + static void RejectIncomingCallEventHandler(lv_obj_t *obj, lv_event_t event) { + auto* item = static_cast(obj->user_data); + item->OnRejectIncomingCall(event); + } +} + +Notifications::NotificationItem::NotificationItem(const char *title, + const char *msg, + uint8_t notifNr, + Controllers::NotificationManager::Categories category, + uint8_t notifNb, + Modes mode, + Pinetime::Controllers::AlertNotificationService& alertNotificationService) + : notifNr{notifNr}, notifNb{notifNb}, mode{mode}, alertNotificationService{alertNotificationService} { container1 = lv_cont_create(lv_scr_act(), nullptr); static lv_style_t contStyle; lv_style_copy(&contStyle, lv_cont_get_style(container1, LV_CONT_STYLE_MAIN)); @@ -142,16 +187,59 @@ Notifications::NotificationItem::NotificationItem(const char *title, const char auto titleHeight = lv_obj_get_height(t1); - l1 = lv_label_create(container1, nullptr); - lv_label_set_style(l1, LV_LABEL_STYLE_MAIN, &textStyle); - lv_obj_set_pos(l1, textStyle.body.padding.left, - titleHeight + offscreenOffset + textStyle.body.padding.bottom + - textStyle.body.padding.top); + switch(category) { + default: { + l1 = lv_label_create(container1, nullptr); + lv_label_set_style(l1, LV_LABEL_STYLE_MAIN, &textStyle); + lv_obj_set_pos(l1, textStyle.body.padding.left, + titleHeight + offscreenOffset + textStyle.body.padding.bottom + + textStyle.body.padding.top); + + lv_label_set_long_mode(l1, LV_LABEL_LONG_BREAK); + lv_label_set_body_draw(l1, true); + lv_obj_set_width(l1, LV_HOR_RES - (textStyle.body.padding.left + textStyle.body.padding.right)); + lv_label_set_text(l1, msg); + } + break; + case Controllers::NotificationManager::Categories::IncomingCall: { + l1 = lv_label_create(container1, nullptr); + lv_label_set_style(l1, LV_LABEL_STYLE_MAIN, &textStyle); + lv_obj_set_pos(l1, textStyle.body.padding.left, + titleHeight + offscreenOffset + textStyle.body.padding.bottom + + textStyle.body.padding.top); + + lv_label_set_long_mode(l1, LV_LABEL_LONG_BREAK); + lv_label_set_body_draw(l1, true); + lv_obj_set_width(l1, LV_HOR_RES - (textStyle.body.padding.left + textStyle.body.padding.right)); + lv_label_set_text(l1, "Incoming call from "); + auto l1Height = lv_obj_get_height(l1); + + l2 = lv_label_create(container1, nullptr); + lv_label_set_style(l2, LV_LABEL_STYLE_MAIN, &textStyle); + lv_obj_set_pos(l2, textStyle.body.padding.left, + titleHeight + l1Height + offscreenOffset + (textStyle.body.padding.bottom*2) + + (textStyle.body.padding.top*2)); + lv_label_set_long_mode(l2, LV_LABEL_LONG_BREAK); + lv_label_set_body_draw(l2, true); + lv_obj_set_width(l2, LV_HOR_RES - (textStyle.body.padding.left + textStyle.body.padding.right)); + lv_label_set_text(l2, msg); + + bt_accept = lv_btn_create(container1, nullptr); + lv_obj_align(bt_accept, lv_scr_act(), LV_ALIGN_IN_BOTTOM_LEFT, 0, -20); + bt_accept->user_data = this; + lv_obj_set_event_cb(bt_accept, AcceptIncomingCallEventHandler); - lv_label_set_long_mode(l1, LV_LABEL_LONG_BREAK); - lv_label_set_body_draw(l1, true); - lv_obj_set_width(l1, LV_HOR_RES - (textStyle.body.padding.left + textStyle.body.padding.right)); - lv_label_set_text(l1, msg); + label_accept = lv_label_create(bt_accept, nullptr); + lv_label_set_text(label_accept, "Accept"); + + bt_reject = lv_btn_create(container1, nullptr); + lv_obj_align(bt_reject, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, 0, -20); + bt_reject->user_data = this; + lv_obj_set_event_cb(bt_reject, RejectIncomingCallEventHandler); + label_reject = lv_label_create(bt_reject, nullptr); + lv_label_set_text(label_reject, "Reject"); + } + } if(mode == Modes::Normal) { if(notifNr < notifNb) { @@ -166,6 +254,17 @@ Notifications::NotificationItem::NotificationItem(const char *title, const char } } +void Notifications::NotificationItem::OnAcceptIncomingCall(lv_event_t event) { + if (event != LV_EVENT_CLICKED) return; + + alertNotificationService.AcceptIncomingCall(); +} + +void Notifications::NotificationItem::OnRejectIncomingCall(lv_event_t event) { + if (event != LV_EVENT_CLICKED) return; + + alertNotificationService.RejectIncomingCall(); +} Notifications::NotificationItem::~NotificationItem() { lv_obj_clean(lv_scr_act()); diff --git a/src/displayapp/screens/Notifications.h b/src/displayapp/screens/Notifications.h index f5c6a860..4305c796 100644 --- a/src/displayapp/screens/Notifications.h +++ b/src/displayapp/screens/Notifications.h @@ -19,26 +19,36 @@ namespace Pinetime { bool OnButtonPushed() override; bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override; + class NotificationItem { + public: + NotificationItem(const char* title, const char* msg, uint8_t notifNr, Controllers::NotificationManager::Categories, uint8_t notifNb, Modes mode, Pinetime::Controllers::AlertNotificationService& alertNotificationService); + ~NotificationItem(); + bool Refresh() {return false;} + void OnAcceptIncomingCall(lv_event_t event); + void OnRejectIncomingCall(lv_event_t event); + private: - bool running = true; + uint8_t notifNr = 0; + uint8_t notifNb = 0; + char pageText[4]; - class NotificationItem { - public: - NotificationItem(const char* title, const char* msg, uint8_t notifNr, uint8_t notifNb, Modes mode); - ~NotificationItem(); - bool Refresh() {return false;} - - private: - uint8_t notifNr = 0; - uint8_t notifNb = 0; - char pageText[4]; - - lv_obj_t* container1; - lv_obj_t* t1; - lv_obj_t* l1; - lv_obj_t* bottomPlaceholder; - Modes mode; - }; + lv_obj_t* container1; + lv_obj_t* t1; + lv_obj_t* l1; + lv_obj_t* l2; + lv_obj_t* bt_accept; + lv_obj_t* bt_reject; + lv_obj_t* label_accept; + lv_obj_t* label_reject; + lv_obj_t* bottomPlaceholder; + Modes mode; + Pinetime::Controllers::AlertNotificationService& alertNotificationService; + + + }; + + private: + bool running = true; struct NotificationData { const char* title; diff --git a/src/displayapp/screens/Tile.cpp b/src/displayapp/screens/Tile.cpp index c1a5e94f..214d2736 100644 --- a/src/displayapp/screens/Tile.cpp +++ b/src/displayapp/screens/Tile.cpp @@ -22,7 +22,6 @@ Tile::Tile(DisplayApp* app, std::array& applications) : Screen( appIndex++; } } - modal.reset(new Modal(app)); btnm1 = lv_btnm_create(lv_scr_act(), nullptr); lv_btnm_set_map(btnm1, btnm_map1); diff --git a/src/displayapp/screens/Tile.h b/src/displayapp/screens/Tile.h index 7edf67b2..bf3f5d67 100644 --- a/src/displayapp/screens/Tile.h +++ b/src/displayapp/screens/Tile.h @@ -29,8 +29,6 @@ namespace Pinetime { lv_obj_t * btnm1; bool running = true; - std::unique_ptr modal; - const char* btnm_map1[8]; Pinetime::Applications::Apps apps[6]; }; diff --git a/src/main.cpp b/src/main.cpp index 3b993ee9..01ee3d86 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -98,8 +98,6 @@ void ble_manager_set_ble_disconnection_callback(void (*disconnection)()); static constexpr uint8_t pinTouchIrq = 28; std::unique_ptr systemTask; -Pinetime::Controllers::NotificationManager notificationManager; - void nrfx_gpiote_evt_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action) { if(pin == pinTouchIrq) { systemTask->OnTouchEvent(); @@ -241,7 +239,7 @@ int main(void) { debounceTimer = xTimerCreate ("debounceTimer", 200, pdFALSE, (void *) 0, DebounceTimerCallback); systemTask.reset(new Pinetime::System::SystemTask(spi, lcd, spiNorFlash, twiMaster, touchPanel, lvgl, batteryController, bleController, - dateTimeController, notificationManager, heartRateSensor)); + dateTimeController, heartRateSensor)); systemTask->Start(); nimble_port_init(); diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index 2fbc8cf0..f998ac82 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -40,13 +40,12 @@ SystemTask::SystemTask(Drivers::SpiMaster &spi, Drivers::St7789 &lcd, Components::LittleVgl &lvgl, Controllers::Battery &batteryController, Controllers::Ble &bleController, Controllers::DateTime &dateTimeController, - Pinetime::Controllers::NotificationManager& notificationManager, Pinetime::Drivers::Hrs3300& heartRateSensor) : spi{spi}, lcd{lcd}, spiNorFlash{spiNorFlash}, twiMaster{twiMaster}, touchPanel{touchPanel}, lvgl{lvgl}, batteryController{batteryController}, heartRateController{*this}, bleController{bleController}, dateTimeController{dateTimeController}, - watchdog{}, watchdogView{watchdog}, notificationManager{notificationManager}, + watchdog{}, watchdogView{watchdog}, heartRateSensor{heartRateSensor}, nimbleController(*this, bleController,dateTimeController, notificationManager, batteryController, spiNorFlash, heartRateController) { systemTasksMsgQueue = xQueueCreate(10, 1); @@ -161,10 +160,6 @@ void SystemTask::Work() { if(isSleeping && !isWakingUp) GoToRunning(); displayApp->PushMessage(Pinetime::Applications::DisplayApp::Messages::NewNotification); break; - case Messages::OnNewCall: - if(isSleeping && !isWakingUp) GoToRunning(); - displayApp->PushMessage(Pinetime::Applications::DisplayApp::Messages::NewCall); - break; case Messages::BleConnected: ReloadIdleTimer(); isBleDiscoveryTimerRunning = true; diff --git a/src/systemtask/SystemTask.h b/src/systemtask/SystemTask.h index 7e031b52..ed3574c0 100644 --- a/src/systemtask/SystemTask.h +++ b/src/systemtask/SystemTask.h @@ -37,7 +37,6 @@ namespace Pinetime { Components::LittleVgl &lvgl, Controllers::Battery &batteryController, Controllers::Ble &bleController, Controllers::DateTime &dateTimeController, - Pinetime::Controllers::NotificationManager& manager, Pinetime::Drivers::Hrs3300& heartRateSensor); @@ -73,7 +72,7 @@ namespace Pinetime { std::atomic isWakingUp{false}; Pinetime::Drivers::Watchdog watchdog; Pinetime::Drivers::WatchdogView watchdogView; - Pinetime::Controllers::NotificationManager& notificationManager; + Pinetime::Controllers::NotificationManager notificationManager; Pinetime::Drivers::Hrs3300& heartRateSensor; Pinetime::Controllers::NimbleController nimbleController; -- cgit v1.2.3 From 3dd88339f39089232c40f043a478b9ba47cb1dad Mon Sep 17 00:00:00 2001 From: petter <39340152+petterhs@users.noreply.github.com> Date: Mon, 25 Jan 2021 16:47:52 +0100 Subject: create motorcontroller in main and pass by reference --- src/displayapp/DisplayApp.cpp | 7 +++++-- src/displayapp/DisplayApp.h | 3 +++ src/displayapp/screens/Notifications.cpp | 10 +++++++--- src/displayapp/screens/Notifications.h | 7 +++++-- src/main.cpp | 4 +++- src/systemtask/SystemTask.cpp | 7 +++++-- src/systemtask/SystemTask.h | 3 +++ 7 files changed, 31 insertions(+), 10 deletions(-) (limited to 'src/systemtask') diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index b6ad90b4..12efe62b 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -5,6 +5,7 @@ #include "components/ble/BleController.h" #include "components/datetime/DateTimeController.h" #include "components/ble/NotificationManager.h" +#include "components/motor/MotorController.h" #include "displayapp/screens/ApplicationList.h" #include "displayapp/screens/Brightness.h" #include "displayapp/screens/Clock.h" @@ -32,6 +33,7 @@ DisplayApp::DisplayApp(Drivers::St7789 &lcd, Components::LittleVgl &lvgl, Driver Controllers::DateTime &dateTimeController, Drivers::WatchdogView &watchdog, System::SystemTask &systemTask, Pinetime::Controllers::NotificationManager& notificationManager, + Pinetime::Controllers::MotorController& motorController, Pinetime::Controllers::HeartRateController& heartRateController) : lcd{lcd}, lvgl{lvgl}, @@ -43,6 +45,7 @@ DisplayApp::DisplayApp(Drivers::St7789 &lcd, Components::LittleVgl &lvgl, Driver currentScreen{new Screens::Clock(this, dateTimeController, batteryController, bleController, notificationManager, heartRateController) }, systemTask{systemTask}, notificationManager{notificationManager}, + motorController{motorController}, heartRateController{heartRateController} { msgQueue = xQueueCreate(queueSize, itemSize); onClockApp = true; @@ -124,7 +127,7 @@ void DisplayApp::Refresh() { currentScreen.reset(nullptr); lvgl.SetFullRefresh(Components::LittleVgl::FullRefreshDirections::Up); onClockApp = false; - currentScreen.reset(new Screens::Notifications(this, notificationManager, Screens::Notifications::Modes::Preview)); + currentScreen.reset(new Screens::Notifications(this, notificationManager, motorController, Screens::Notifications::Modes::Preview)); } } break; @@ -215,7 +218,7 @@ void DisplayApp::RunningState() { case Apps::Music : currentScreen.reset(new Screens::Music(this, systemTask.nimble().music())); break; case Apps::Navigation : currentScreen.reset(new Screens::Navigation(this, systemTask.nimble().navigation())); break; case Apps::FirmwareValidation: currentScreen.reset(new Screens::FirmwareValidation(this, validator)); break; - case Apps::Notifications: currentScreen.reset(new Screens::Notifications(this, notificationManager, Screens::Notifications::Modes::Normal)); break; + case Apps::Notifications: currentScreen.reset(new Screens::Notifications(this, notificationManager, motorController, Screens::Notifications::Modes::Normal)); break; case Apps::HeartRate: currentScreen.reset(new Screens::HeartRate(this, heartRateController)); break; } nextApp = Apps::None; diff --git a/src/displayapp/DisplayApp.h b/src/displayapp/DisplayApp.h index da5a7b22..68730468 100644 --- a/src/displayapp/DisplayApp.h +++ b/src/displayapp/DisplayApp.h @@ -23,6 +23,7 @@ namespace Pinetime { class Ble; class DateTime; class NotificationManager; + class MotorController; class HeartRateController; } @@ -44,6 +45,7 @@ namespace Pinetime { Controllers::DateTime &dateTimeController, Drivers::WatchdogView &watchdog, System::SystemTask &systemTask, Pinetime::Controllers::NotificationManager& notificationManager, + Pinetime::Controllers::MotorController& motorController, Pinetime::Controllers::HeartRateController& heartRateController); void Start(); void PushMessage(Messages msg); @@ -87,6 +89,7 @@ namespace Pinetime { Controllers::BrightnessController brightnessController; std::unique_ptr modal; Pinetime::Controllers::NotificationManager& notificationManager; + Pinetime::Controllers::MotorController& motorController; Pinetime::Controllers::FirmwareValidator validator; TouchModes touchMode = TouchModes::Gestures; Pinetime::Controllers::HeartRateController& heartRateController; diff --git a/src/displayapp/screens/Notifications.cpp b/src/displayapp/screens/Notifications.cpp index cfcecec2..b777aca8 100644 --- a/src/displayapp/screens/Notifications.cpp +++ b/src/displayapp/screens/Notifications.cpp @@ -3,12 +3,16 @@ using namespace Pinetime::Applications::Screens; -Notifications::Notifications(DisplayApp *app, Pinetime::Controllers::NotificationManager ¬ificationManager, Modes mode) : - Screen(app), notificationManager{notificationManager}, mode{mode} { +Notifications::Notifications(DisplayApp *app, + Pinetime::Controllers::NotificationManager ¬ificationManager, + Pinetime::Controllers::MotorController& motorController, + Modes mode) : + Screen(app), notificationManager{notificationManager}, + motorController{motorController}, mode{mode} { + notificationManager.ClearNewNotificationFlag(); auto notification = notificationManager.GetLastNotification(); - motorController.Init(); //start the vibration timer setups if(notification.valid) { currentId = notification.id; diff --git a/src/displayapp/screens/Notifications.h b/src/displayapp/screens/Notifications.h index 345ad15a..85d13545 100644 --- a/src/displayapp/screens/Notifications.h +++ b/src/displayapp/screens/Notifications.h @@ -13,7 +13,10 @@ namespace Pinetime { class Notifications : public Screen { public: enum class Modes {Normal, Preview}; - explicit Notifications(DisplayApp* app, Pinetime::Controllers::NotificationManager& notificationManager, Modes mode); + explicit Notifications(DisplayApp* app, + Pinetime::Controllers::NotificationManager& notificationManager, + Pinetime::Controllers::MotorController& motorController, + Modes mode); ~Notifications() override; bool Refresh() override; @@ -46,7 +49,7 @@ namespace Pinetime { const char* text; }; Pinetime::Controllers::NotificationManager& notificationManager; - Pinetime::Controllers::MotorController motorController; + Pinetime::Controllers::MotorController& motorController; Modes mode = Modes::Normal; std::unique_ptr currentItem; Controllers::NotificationManager::Notification::Id currentId; diff --git a/src/main.cpp b/src/main.cpp index 3b993ee9..78a2cf5b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -30,6 +30,7 @@ #include "components/battery/BatteryController.h" #include "components/ble/BleController.h" #include "components/ble/NotificationManager.h" +#include "components/motor/MotorController.h" #include "components/datetime/DateTimeController.h" #include "displayapp/DisplayApp.h" #include "displayapp/LittleVgl.h" @@ -99,6 +100,7 @@ static constexpr uint8_t pinTouchIrq = 28; std::unique_ptr systemTask; Pinetime::Controllers::NotificationManager notificationManager; +Pinetime::Controllers::MotorController motorController; void nrfx_gpiote_evt_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action) { if(pin == pinTouchIrq) { @@ -241,7 +243,7 @@ int main(void) { debounceTimer = xTimerCreate ("debounceTimer", 200, pdFALSE, (void *) 0, DebounceTimerCallback); systemTask.reset(new Pinetime::System::SystemTask(spi, lcd, spiNorFlash, twiMaster, touchPanel, lvgl, batteryController, bleController, - dateTimeController, notificationManager, heartRateSensor)); + dateTimeController, notificationManager, motorController, heartRateSensor)); systemTask->Start(); nimble_port_init(); diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index 13a84c26..4b9cb429 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -41,13 +41,14 @@ SystemTask::SystemTask(Drivers::SpiMaster &spi, Drivers::St7789 &lcd, Controllers::Battery &batteryController, Controllers::Ble &bleController, Controllers::DateTime &dateTimeController, Pinetime::Controllers::NotificationManager& notificationManager, + Pinetime::Controllers::MotorController& motorController, Pinetime::Drivers::Hrs3300& heartRateSensor) : spi{spi}, lcd{lcd}, spiNorFlash{spiNorFlash}, twiMaster{twiMaster}, touchPanel{touchPanel}, lvgl{lvgl}, batteryController{batteryController}, heartRateController{*this}, bleController{bleController}, dateTimeController{dateTimeController}, watchdog{}, watchdogView{watchdog}, notificationManager{notificationManager}, - heartRateSensor{heartRateSensor}, + motorController{motorController}, heartRateSensor{heartRateSensor}, nimbleController(*this, bleController,dateTimeController, notificationManager, batteryController, spiNorFlash, heartRateController) { systemTasksMsgQueue = xQueueCreate(10, 1); } @@ -81,12 +82,14 @@ void SystemTask::Work() { batteryController.Init(); displayApp.reset(new Pinetime::Applications::DisplayApp(lcd, lvgl, touchPanel, batteryController, bleController, - dateTimeController, watchdogView, *this, notificationManager, heartRateController)); + dateTimeController, watchdogView, *this, notificationManager, + motorController, heartRateController)); displayApp->Start(); batteryController.Update(); displayApp->PushMessage(Pinetime::Applications::DisplayApp::Messages::UpdateBatteryLevel); + motorController.Init(); heartRateSensor.Init(); heartRateSensor.Disable(); diff --git a/src/systemtask/SystemTask.h b/src/systemtask/SystemTask.h index cf3f1021..70abf5f3 100644 --- a/src/systemtask/SystemTask.h +++ b/src/systemtask/SystemTask.h @@ -12,6 +12,7 @@ #include "components/battery/BatteryController.h" #include "components/ble/NimbleController.h" #include "components/ble/NotificationManager.h" +#include "components/motor/MotorController.h" #include "displayapp/DisplayApp.h" #include "drivers/Watchdog.h" @@ -38,6 +39,7 @@ namespace Pinetime { Controllers::Battery &batteryController, Controllers::Ble &bleController, Controllers::DateTime &dateTimeController, Pinetime::Controllers::NotificationManager& manager, + Pinetime::Controllers::MotorController& motorController, Pinetime::Drivers::Hrs3300& heartRateSensor); @@ -74,6 +76,7 @@ namespace Pinetime { Pinetime::Drivers::Watchdog watchdog; Pinetime::Drivers::WatchdogView watchdogView; Pinetime::Controllers::NotificationManager& notificationManager; + Pinetime::Controllers::MotorController& motorController; Pinetime::Drivers::Hrs3300& heartRateSensor; Pinetime::Controllers::NimbleController nimbleController; -- cgit v1.2.3 From 1bd5457848babefbc0c129e77c9a2a314c55b780 Mon Sep 17 00:00:00 2001 From: petter <39340152+petterhs@users.noreply.github.com> Date: Fri, 5 Feb 2021 15:43:20 +0100 Subject: trigger vibration from systemtask --- src/displayapp/DisplayApp.cpp | 7 ++----- src/displayapp/DisplayApp.h | 3 --- src/displayapp/screens/Notifications.cpp | 10 +++------- src/displayapp/screens/Notifications.h | 3 --- src/systemtask/SystemTask.cpp | 7 ++++--- 5 files changed, 9 insertions(+), 21 deletions(-) (limited to 'src/systemtask') diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index 12efe62b..b6ad90b4 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -5,7 +5,6 @@ #include "components/ble/BleController.h" #include "components/datetime/DateTimeController.h" #include "components/ble/NotificationManager.h" -#include "components/motor/MotorController.h" #include "displayapp/screens/ApplicationList.h" #include "displayapp/screens/Brightness.h" #include "displayapp/screens/Clock.h" @@ -33,7 +32,6 @@ DisplayApp::DisplayApp(Drivers::St7789 &lcd, Components::LittleVgl &lvgl, Driver Controllers::DateTime &dateTimeController, Drivers::WatchdogView &watchdog, System::SystemTask &systemTask, Pinetime::Controllers::NotificationManager& notificationManager, - Pinetime::Controllers::MotorController& motorController, Pinetime::Controllers::HeartRateController& heartRateController) : lcd{lcd}, lvgl{lvgl}, @@ -45,7 +43,6 @@ DisplayApp::DisplayApp(Drivers::St7789 &lcd, Components::LittleVgl &lvgl, Driver currentScreen{new Screens::Clock(this, dateTimeController, batteryController, bleController, notificationManager, heartRateController) }, systemTask{systemTask}, notificationManager{notificationManager}, - motorController{motorController}, heartRateController{heartRateController} { msgQueue = xQueueCreate(queueSize, itemSize); onClockApp = true; @@ -127,7 +124,7 @@ void DisplayApp::Refresh() { currentScreen.reset(nullptr); lvgl.SetFullRefresh(Components::LittleVgl::FullRefreshDirections::Up); onClockApp = false; - currentScreen.reset(new Screens::Notifications(this, notificationManager, motorController, Screens::Notifications::Modes::Preview)); + currentScreen.reset(new Screens::Notifications(this, notificationManager, Screens::Notifications::Modes::Preview)); } } break; @@ -218,7 +215,7 @@ void DisplayApp::RunningState() { case Apps::Music : currentScreen.reset(new Screens::Music(this, systemTask.nimble().music())); break; case Apps::Navigation : currentScreen.reset(new Screens::Navigation(this, systemTask.nimble().navigation())); break; case Apps::FirmwareValidation: currentScreen.reset(new Screens::FirmwareValidation(this, validator)); break; - case Apps::Notifications: currentScreen.reset(new Screens::Notifications(this, notificationManager, motorController, Screens::Notifications::Modes::Normal)); break; + case Apps::Notifications: currentScreen.reset(new Screens::Notifications(this, notificationManager, Screens::Notifications::Modes::Normal)); break; case Apps::HeartRate: currentScreen.reset(new Screens::HeartRate(this, heartRateController)); break; } nextApp = Apps::None; diff --git a/src/displayapp/DisplayApp.h b/src/displayapp/DisplayApp.h index 68730468..da5a7b22 100644 --- a/src/displayapp/DisplayApp.h +++ b/src/displayapp/DisplayApp.h @@ -23,7 +23,6 @@ namespace Pinetime { class Ble; class DateTime; class NotificationManager; - class MotorController; class HeartRateController; } @@ -45,7 +44,6 @@ namespace Pinetime { Controllers::DateTime &dateTimeController, Drivers::WatchdogView &watchdog, System::SystemTask &systemTask, Pinetime::Controllers::NotificationManager& notificationManager, - Pinetime::Controllers::MotorController& motorController, Pinetime::Controllers::HeartRateController& heartRateController); void Start(); void PushMessage(Messages msg); @@ -89,7 +87,6 @@ namespace Pinetime { Controllers::BrightnessController brightnessController; std::unique_ptr modal; Pinetime::Controllers::NotificationManager& notificationManager; - Pinetime::Controllers::MotorController& motorController; Pinetime::Controllers::FirmwareValidator validator; TouchModes touchMode = TouchModes::Gestures; Pinetime::Controllers::HeartRateController& heartRateController; diff --git a/src/displayapp/screens/Notifications.cpp b/src/displayapp/screens/Notifications.cpp index b777aca8..ece9eb07 100644 --- a/src/displayapp/screens/Notifications.cpp +++ b/src/displayapp/screens/Notifications.cpp @@ -5,11 +5,9 @@ using namespace Pinetime::Applications::Screens; Notifications::Notifications(DisplayApp *app, Pinetime::Controllers::NotificationManager ¬ificationManager, - Pinetime::Controllers::MotorController& motorController, - Modes mode) : - Screen(app), notificationManager{notificationManager}, - motorController{motorController}, mode{mode} { - + Modes mode) : + Screen(app), notificationManager{notificationManager}, mode{mode} { + notificationManager.ClearNewNotificationFlag(); auto notification = notificationManager.GetLastNotification(); @@ -29,8 +27,6 @@ Notifications::Notifications(DisplayApp *app, style_line.line.width = 3; style_line.line.rounded = 0; - motorController.SetDuration(35); - timeoutLine = lv_line_create(lv_scr_act(), nullptr); lv_line_set_style(timeoutLine, LV_LINE_STYLE_MAIN, &style_line); lv_line_set_points(timeoutLine, timeoutLinePoints, 2); diff --git a/src/displayapp/screens/Notifications.h b/src/displayapp/screens/Notifications.h index 85d13545..b621b777 100644 --- a/src/displayapp/screens/Notifications.h +++ b/src/displayapp/screens/Notifications.h @@ -5,7 +5,6 @@ #include #include "Screen.h" #include "components/ble/NotificationManager.h" -#include "components/motor/MotorController.h" namespace Pinetime { namespace Applications { @@ -15,7 +14,6 @@ namespace Pinetime { enum class Modes {Normal, Preview}; explicit Notifications(DisplayApp* app, Pinetime::Controllers::NotificationManager& notificationManager, - Pinetime::Controllers::MotorController& motorController, Modes mode); ~Notifications() override; @@ -49,7 +47,6 @@ namespace Pinetime { const char* text; }; Pinetime::Controllers::NotificationManager& notificationManager; - Pinetime::Controllers::MotorController& motorController; Modes mode = Modes::Normal; std::unique_ptr currentItem; Controllers::NotificationManager::Notification::Id currentId; diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index 4b9cb429..e195de8e 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -80,17 +80,17 @@ void SystemTask::Work() { twiMaster.Init(); touchPanel.Init(); batteryController.Init(); + motorController.Init(); + displayApp.reset(new Pinetime::Applications::DisplayApp(lcd, lvgl, touchPanel, batteryController, bleController, dateTimeController, watchdogView, *this, notificationManager, - motorController, heartRateController)); + heartRateController)); displayApp->Start(); batteryController.Update(); displayApp->PushMessage(Pinetime::Applications::DisplayApp::Messages::UpdateBatteryLevel); - motorController.Init(); - heartRateSensor.Init(); heartRateSensor.Disable(); heartRateApp.reset(new Pinetime::Applications::HeartRateTask(heartRateSensor, heartRateController)); @@ -162,6 +162,7 @@ void SystemTask::Work() { break; case Messages::OnNewNotification: if(isSleeping && !isWakingUp) GoToRunning(); + motorController.SetDuration(35); displayApp->PushMessage(Pinetime::Applications::DisplayApp::Messages::NewNotification); break; case Messages::BleConnected: -- cgit v1.2.3 From 1e2cc3ce91b402459790332b84e3f8dcbe5dc340 Mon Sep 17 00:00:00 2001 From: petter <39340152+petterhs@users.noreply.github.com> Date: Sun, 7 Feb 2021 13:31:02 +0100 Subject: add vibration toggle --- src/components/ble/NotificationManager.cpp | 8 ++++++++ src/components/ble/NotificationManager.h | 3 +++ src/displayapp/screens/Notifications.cpp | 4 ++++ src/systemtask/SystemTask.cpp | 2 +- 4 files changed, 16 insertions(+), 1 deletion(-) (limited to 'src/systemtask') diff --git a/src/components/ble/NotificationManager.cpp b/src/components/ble/NotificationManager.cpp index dabcb4ba..fd66c194 100644 --- a/src/components/ble/NotificationManager.cpp +++ b/src/components/ble/NotificationManager.cpp @@ -71,6 +71,14 @@ bool NotificationManager::AreNewNotificationsAvailable() { return newNotification; } +bool NotificationManager::isVibrationEnabled() { + return vibrationEnabled; +} + +void NotificationManager::toggleVibrations() { + vibrationEnabled = !vibrationEnabled; +} + bool NotificationManager::ClearNewNotificationFlag() { return newNotification.exchange(false); } diff --git a/src/components/ble/NotificationManager.h b/src/components/ble/NotificationManager.h index 036d2ed9..4dce4eda 100644 --- a/src/components/ble/NotificationManager.h +++ b/src/components/ble/NotificationManager.h @@ -28,6 +28,8 @@ namespace Pinetime { Notification GetPrevious(Notification::Id id); bool ClearNewNotificationFlag(); bool AreNewNotificationsAvailable(); + bool isVibrationEnabled(); + void toggleVibrations(); static constexpr size_t MaximumMessageSize() { return MessageSize; }; size_t NbNotifications() const; @@ -40,6 +42,7 @@ namespace Pinetime { uint8_t writeIndex = 0; bool empty = true; std::atomic newNotification{false}; + bool vibrationEnabled = true; }; } } \ No newline at end of file diff --git a/src/displayapp/screens/Notifications.cpp b/src/displayapp/screens/Notifications.cpp index ece9eb07..b481c972 100644 --- a/src/displayapp/screens/Notifications.cpp +++ b/src/displayapp/screens/Notifications.cpp @@ -92,6 +92,10 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) { currentItem.reset(new NotificationItem("\nNotification", nextNotification.message.data(), nextNotification.index, notificationManager.NbNotifications(), mode)); } return true; + case Pinetime::Applications::TouchEvents::LongTap: { + notificationManager.toggleVibrations(); + return true; + } default: return false; } diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index e195de8e..250a4ab4 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -162,7 +162,7 @@ void SystemTask::Work() { break; case Messages::OnNewNotification: if(isSleeping && !isWakingUp) GoToRunning(); - motorController.SetDuration(35); + if(notificationManager.isVibrationEnabled()) motorController.SetDuration(35); displayApp->PushMessage(Pinetime::Applications::DisplayApp::Messages::NewNotification); break; case Messages::BleConnected: -- cgit v1.2.3