From d13dd6dee3e6194a2f3ed2a1adfbbd32ced525a3 Mon Sep 17 00:00:00 2001 From: Florian Kraupa Date: Wed, 12 May 2021 20:23:04 +0200 Subject: implemented continuous vibration pattern for incoming calls --- src/systemtask/SystemTask.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/systemtask/SystemTask.cpp') diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index 6d695e2c..0d43b2f3 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -225,7 +225,11 @@ void SystemTask::Work() { case Messages::OnNewNotification: if (isSleeping && !isWakingUp) GoToRunning(); - motorController.SetDuration(35); + if (notificationManager.GetLastNotification().category == Controllers::NotificationManager::Categories::IncomingCall) { + motorController.startRunning(50); + } else { + motorController.RunForDuration(35); + } displayApp->PushMessage(Pinetime::Applications::Display::Messages::NewNotification); break; case Messages::BleConnected: -- cgit v1.2.3 From 5da65494b3da1a69d08f7b7e6c5242f6ce666e32 Mon Sep 17 00:00:00 2001 From: Florian Kraupa Date: Thu, 13 May 2021 00:08:40 +0200 Subject: only activate the timeout on call notification previews after they have been interacted with --- src/displayapp/screens/Notifications.cpp | 35 ++++++++++++++++++++++---------- src/displayapp/screens/Notifications.h | 8 ++++++-- src/systemtask/SystemTask.cpp | 2 +- 3 files changed, 31 insertions(+), 14 deletions(-) (limited to 'src/systemtask/SystemTask.cpp') diff --git a/src/displayapp/screens/Notifications.cpp b/src/displayapp/screens/Notifications.cpp index 482247e6..60349a64 100644 --- a/src/displayapp/screens/Notifications.cpp +++ b/src/displayapp/screens/Notifications.cpp @@ -29,7 +29,8 @@ Notifications::Notifications(DisplayApp* app, notificationManager.NbNotifications(), mode, alertNotificationService, - motorController); + motorController, + &timeoutTickCountEnd); validDisplay = true; } else { currentItem = std::make_unique("Notification", @@ -39,7 +40,8 @@ Notifications::Notifications(DisplayApp* app, notificationManager.NbNotifications(), Modes::Preview, alertNotificationService, - motorController); + motorController, + &timeoutTickCountEnd); } if (mode == Modes::Preview) { @@ -63,7 +65,7 @@ Notifications::~Notifications() { } bool Notifications::Refresh() { - if (mode == Modes::Preview) { + if (mode == Modes::Preview && !currentItem->timeoutOnHold) { auto tick = xTaskGetTickCount(); int32_t pos = 240 - ((tick - timeoutTickCountStart) / ((timeoutTickCountEnd - timeoutTickCountStart) / 240)); if (pos < 0) @@ -105,7 +107,8 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) { notificationManager.NbNotifications(), mode, alertNotificationService, - motorController); + motorController, + &timeoutTickCountEnd); } return true; case Pinetime::Applications::TouchEvents::SwipeUp: { @@ -131,7 +134,8 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) { notificationManager.NbNotifications(), mode, alertNotificationService, - motorController); + motorController, + &timeoutTickCountEnd); } return true; case Pinetime::Applications::TouchEvents::LongTap: { @@ -167,8 +171,10 @@ Notifications::NotificationItem::NotificationItem(const char* title, uint8_t notifNb, Modes mode, Pinetime::Controllers::AlertNotificationService& alertNotificationService, - Controllers::MotorController& motorController) - : notifNr {notifNr}, notifNb {notifNb}, mode {mode}, alertNotificationService {alertNotificationService}, motorController{motorController} { + Controllers::MotorController& motorController, + uint32_t* timeoutEnd) + : notifNr {notifNr}, notifNb {notifNb}, mode {mode}, alertNotificationService {alertNotificationService}, + motorController{motorController}, timeoutEnd{timeoutEnd} { lv_obj_t* container1 = lv_cont_create(lv_scr_act(), NULL); @@ -251,7 +257,7 @@ Notifications::NotificationItem::NotificationItem(const char* title, label_mute = lv_label_create(bt_mute, nullptr); lv_label_set_text(label_mute, Symbols::volumMute); lv_obj_set_style_local_bg_color(bt_mute, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY); - + timeoutOnHold = true; } break; } @@ -266,24 +272,31 @@ Notifications::NotificationItem::NotificationItem(const char* title, void Notifications::NotificationItem::OnAcceptIncomingCall(lv_event_t event) { if (event != LV_EVENT_CLICKED) return; - motorController.stopRunning(); + callPreviewInteraction(); alertNotificationService.AcceptIncomingCall(); } void Notifications::NotificationItem::OnMuteIncomingCall(lv_event_t event) { if (event != LV_EVENT_CLICKED) return; - motorController.stopRunning(); + callPreviewInteraction(); alertNotificationService.MuteIncomingCall(); } void Notifications::NotificationItem::OnRejectIncomingCall(lv_event_t event) { if (event != LV_EVENT_CLICKED) return; - motorController.stopRunning(); + callPreviewInteraction(); alertNotificationService.RejectIncomingCall(); } +inline void Notifications::NotificationItem::callPreviewInteraction() { + *timeoutEnd = xTaskGetTickCount() + (5 * 1024); + timeoutOnHold = false; + motorController.stopRunning(); +} + + Notifications::NotificationItem::~NotificationItem() { lv_obj_clean(lv_scr_act()); } diff --git a/src/displayapp/screens/Notifications.h b/src/displayapp/screens/Notifications.h index ae83e8ee..89b676ec 100644 --- a/src/displayapp/screens/Notifications.h +++ b/src/displayapp/screens/Notifications.h @@ -36,7 +36,8 @@ namespace Pinetime { uint8_t notifNb, Modes mode, Pinetime::Controllers::AlertNotificationService& alertNotificationService, - Controllers::MotorController& motorController); + Controllers::MotorController& motorController, + uint32_t* timeoutEnd); ~NotificationItem(); bool Refresh() { return false; @@ -44,8 +45,10 @@ namespace Pinetime { void OnAcceptIncomingCall(lv_event_t event); void OnMuteIncomingCall(lv_event_t event); void OnRejectIncomingCall(lv_event_t event); - + bool timeoutOnHold = false; private: + void callPreviewInteraction(); + uint8_t notifNr = 0; uint8_t notifNb = 0; char pageText[4]; @@ -61,6 +64,7 @@ namespace Pinetime { lv_obj_t* label_mute; lv_obj_t* label_reject; lv_obj_t* bottomPlaceholder; + uint32_t* timeoutEnd; Modes mode; Pinetime::Controllers::AlertNotificationService& alertNotificationService; Controllers::MotorController& motorController; diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index 0d43b2f3..2b5e7bbb 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -226,7 +226,7 @@ void SystemTask::Work() { if (isSleeping && !isWakingUp) GoToRunning(); if (notificationManager.GetLastNotification().category == Controllers::NotificationManager::Categories::IncomingCall) { - motorController.startRunning(50); + motorController.startRunning(500); } else { motorController.RunForDuration(35); } -- cgit v1.2.3 From 56af4a0b830cd93ff12753042cdf105b65d0bcc8 Mon Sep 17 00:00:00 2001 From: Florian Kraupa Date: Thu, 13 May 2021 00:35:36 +0200 Subject: cleaned up the code and reduced the size of the diff by removing things like additional whitespaces --- src/components/motor/MotorController.cpp | 2 +- src/components/motor/MotorController.h | 2 +- src/displayapp/screens/Notifications.cpp | 23 +++++++++-------------- src/displayapp/screens/Notifications.h | 2 +- src/displayapp/screens/settings/QuickSettings.cpp | 2 +- src/systemtask/SystemTask.cpp | 2 +- 6 files changed, 14 insertions(+), 19 deletions(-) (limited to 'src/systemtask/SystemTask.cpp') diff --git a/src/components/motor/MotorController.cpp b/src/components/motor/MotorController.cpp index 2a14f4b5..6f02a583 100644 --- a/src/components/motor/MotorController.cpp +++ b/src/components/motor/MotorController.cpp @@ -21,7 +21,7 @@ void MotorController::Init() { isBusy = false; } -void MotorController::RunForDuration(uint8_t motorDuration) { +void MotorController::runForDuration(uint8_t motorDuration) { if (settingsController.GetVibrationStatus() == Controllers::Settings::Vibration::OFF || isBusy) return; diff --git a/src/components/motor/MotorController.h b/src/components/motor/MotorController.h index be076ad4..5daeb8ce 100644 --- a/src/components/motor/MotorController.h +++ b/src/components/motor/MotorController.h @@ -12,7 +12,7 @@ namespace Pinetime { public: MotorController(Controllers::Settings& settingsController); void Init(); - void RunForDuration(uint8_t motorDuration); + void runForDuration(uint8_t motorDuration); void startRunning(uint8_t motorDuration); void stopRunning(); diff --git a/src/displayapp/screens/Notifications.cpp b/src/displayapp/screens/Notifications.cpp index 60349a64..e4abc67b 100644 --- a/src/displayapp/screens/Notifications.cpp +++ b/src/displayapp/screens/Notifications.cpp @@ -13,11 +13,11 @@ Notifications::Notifications(DisplayApp* app, Pinetime::Controllers::AlertNotificationService& alertNotificationService, Controllers::MotorController& motorController, Modes mode) - : Screen(app), - notificationManager {notificationManager}, - alertNotificationService {alertNotificationService}, - motorController{motorController}, - mode {mode} { + : Screen(app), + notificationManager{notificationManager}, + alertNotificationService{alertNotificationService}, + motorController{motorController}, + mode{mode} { notificationManager.ClearNewNotificationFlag(); auto notification = notificationManager.GetLastNotification(); if (notification.valid) { @@ -45,8 +45,6 @@ Notifications::Notifications(DisplayApp* app, } if (mode == Modes::Preview) { - - timeoutLine = lv_line_create(lv_scr_act(), nullptr); @@ -75,9 +73,8 @@ bool Notifications::Refresh() { lv_line_set_points(timeoutLine, timeoutLinePoints, 2); } //make sure we stop any vibrations before exiting - if (!running) { + if (!running) motorController.stopRunning(); - } return running; } @@ -173,9 +170,8 @@ Notifications::NotificationItem::NotificationItem(const char* title, Pinetime::Controllers::AlertNotificationService& alertNotificationService, Controllers::MotorController& motorController, uint32_t* timeoutEnd) - : notifNr {notifNr}, notifNb {notifNb}, mode {mode}, alertNotificationService {alertNotificationService}, - motorController{motorController}, timeoutEnd{timeoutEnd} { - + : notifNr{notifNr}, notifNb{notifNb}, mode{mode}, alertNotificationService{alertNotificationService}, + motorController{motorController}, timeoutEnd{timeoutEnd} { 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)); @@ -260,7 +256,6 @@ Notifications::NotificationItem::NotificationItem(const char* title, timeoutOnHold = true; } break; } - lv_obj_t* backgroundLabel = lv_label_create(lv_scr_act(), nullptr); lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP); @@ -291,7 +286,7 @@ void Notifications::NotificationItem::OnRejectIncomingCall(lv_event_t event) { } inline void Notifications::NotificationItem::callPreviewInteraction() { - *timeoutEnd = xTaskGetTickCount() + (5 * 1024); + *timeoutEnd = xTaskGetTickCount() + (5 * 1024); timeoutOnHold = false; motorController.stopRunning(); } diff --git a/src/displayapp/screens/Notifications.h b/src/displayapp/screens/Notifications.h index 89b676ec..99c95a8e 100644 --- a/src/displayapp/screens/Notifications.h +++ b/src/displayapp/screens/Notifications.h @@ -45,6 +45,7 @@ namespace Pinetime { void OnAcceptIncomingCall(lv_event_t event); void OnMuteIncomingCall(lv_event_t event); void OnRejectIncomingCall(lv_event_t event); + bool timeoutOnHold = false; private: void callPreviewInteraction(); @@ -81,7 +82,6 @@ namespace Pinetime { std::unique_ptr currentItem; Controllers::NotificationManager::Notification::Id currentId; Controllers::MotorController& motorController; - bool validDisplay = false; lv_point_t timeoutLinePoints[2] {{0, 1}, {239, 1}}; diff --git a/src/displayapp/screens/settings/QuickSettings.cpp b/src/displayapp/screens/settings/QuickSettings.cpp index 7681546f..501aee4f 100644 --- a/src/displayapp/screens/settings/QuickSettings.cpp +++ b/src/displayapp/screens/settings/QuickSettings.cpp @@ -140,7 +140,7 @@ void QuickSettings::OnButtonEvent(lv_obj_t* object, lv_event_t event) { if (lv_obj_get_state(btn3, LV_BTN_PART_MAIN) & LV_STATE_CHECKED) { settingsController.SetVibrationStatus(Controllers::Settings::Vibration::ON); - motorController.RunForDuration(35); + motorController.runForDuration(35); lv_label_set_text_static(btn3_lvl, Symbols::notificationsOn); } else { settingsController.SetVibrationStatus(Controllers::Settings::Vibration::OFF); diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index 2b5e7bbb..24fe4f4c 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -228,7 +228,7 @@ void SystemTask::Work() { if (notificationManager.GetLastNotification().category == Controllers::NotificationManager::Categories::IncomingCall) { motorController.startRunning(500); } else { - motorController.RunForDuration(35); + motorController.runForDuration(35); } displayApp->PushMessage(Pinetime::Applications::Display::Messages::NewNotification); break; -- cgit v1.2.3 From 0a0f28fff4be4c9fd9030d9375459fb7b5fdd004 Mon Sep 17 00:00:00 2001 From: Riku Isokoski Date: Thu, 22 Jul 2021 22:57:45 +0300 Subject: Make firmware updating more foolproof (#469) * Make firmware updating more foolproof and fix bugs * No need to manually handle overflow * Make startTime TickType_t * Don't process TouchEvents::None * Fix sleep getting re-enabled issue more directly --- src/components/ble/DfuService.cpp | 9 ++++----- src/displayapp/DisplayApp.cpp | 7 ++++++- src/displayapp/screens/FirmwareUpdate.cpp | 33 +++++++++++++++++++++++++------ src/displayapp/screens/FirmwareUpdate.h | 9 +++++++-- src/systemtask/SystemTask.cpp | 11 ++++++++--- 5 files changed, 52 insertions(+), 17 deletions(-) (limited to 'src/systemtask/SystemTask.cpp') diff --git a/src/components/ble/DfuService.cpp b/src/components/ble/DfuService.cpp index e6bcea81..4179994d 100644 --- a/src/components/ble/DfuService.cpp +++ b/src/components/ble/DfuService.cpp @@ -266,13 +266,14 @@ int DfuService::ControlPointHandler(uint16_t connectionHandle, os_mbuf* om) { static_cast(ErrorCodes::NoError)}; notificationManager.AsyncSend(connectionHandle, controlPointCharacteristicHandle, data, 3); } else { - bleController.State(Pinetime::Controllers::Ble::FirmwareUpdateStates::Error); NRF_LOG_INFO("Image Error : bad CRC"); uint8_t data[3] {static_cast(Opcodes::Response), static_cast(Opcodes::ValidateFirmware), static_cast(ErrorCodes::CrcError)}; notificationManager.AsyncSend(connectionHandle, controlPointCharacteristicHandle, data, 3); + bleController.State(Pinetime::Controllers::Ble::FirmwareUpdateStates::Error); + Reset(); } return 0; @@ -283,10 +284,8 @@ int DfuService::ControlPointHandler(uint16_t connectionHandle, os_mbuf* om) { return 0; } NRF_LOG_INFO("[DFU] -> Activate image and reset!"); - bleController.StopFirmwareUpdate(); - systemTask.PushMessage(Pinetime::System::Messages::BleFirmwareUpdateFinished); - Reset(); bleController.State(Pinetime::Controllers::Ble::FirmwareUpdateStates::Validated); + Reset(); return 0; default: return 0; @@ -294,6 +293,7 @@ int DfuService::ControlPointHandler(uint16_t connectionHandle, os_mbuf* om) { } void DfuService::OnTimeout() { + bleController.State(Pinetime::Controllers::Ble::FirmwareUpdateStates::Error); Reset(); } @@ -307,7 +307,6 @@ void DfuService::Reset() { applicationSize = 0; expectedCrc = 0; notificationManager.Reset(); - bleController.State(Pinetime::Controllers::Ble::FirmwareUpdateStates::Error); bleController.StopFirmwareUpdate(); systemTask.PushMessage(Pinetime::System::Messages::BleFirmwareUpdateFinished); } diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index 071af0c8..4d32a7e5 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -177,9 +177,13 @@ void DisplayApp::Refresh() { } break; case Messages::TouchEvent: { - if (state != States::Running) + if (state != States::Running) { break; + } auto gesture = OnTouchEvent(); + if (gesture == TouchEvents::None) { + break; + } if (!currentScreen->OnTouchEvent(gesture)) { if (currentApp == Apps::Clock) { switch (gesture) { @@ -286,6 +290,7 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction) break; case Apps::FirmwareUpdate: currentScreen = std::make_unique(this, bleController); + ReturnApp(Apps::Clock, FullRefreshDirections::Down, TouchEvents::None); break; case Apps::Notifications: diff --git a/src/displayapp/screens/FirmwareUpdate.cpp b/src/displayapp/screens/FirmwareUpdate.cpp index 4086b152..edb2e49d 100644 --- a/src/displayapp/screens/FirmwareUpdate.cpp +++ b/src/displayapp/screens/FirmwareUpdate.cpp @@ -27,9 +27,10 @@ FirmwareUpdate::FirmwareUpdate(Pinetime::Applications::DisplayApp* app, Pinetime lv_bar_set_value(bar1, 0, LV_ANIM_OFF); percentLabel = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_text(percentLabel, ""); + lv_label_set_text(percentLabel, "Waiting..."); lv_obj_set_auto_realign(percentLabel, true); lv_obj_align(percentLabel, bar1, LV_ALIGN_OUT_TOP_MID, 0, 60); + startTime = xTaskGetTickCount(); } FirmwareUpdate::~FirmwareUpdate() { @@ -40,26 +41,42 @@ bool FirmwareUpdate::Refresh() { switch (bleController.State()) { default: case Pinetime::Controllers::Ble::FirmwareUpdateStates::Idle: + // This condition makes sure that the app is exited if somehow it got + // launched without a firmware update. This should never happen. + if (state != States::Error) { + if (xTaskGetTickCount() - startTime > (60 * 1024)) { + UpdateError(); + state = States::Error; + } + } else if (xTaskGetTickCount() - startTime > (5 * 1024)) { + running = false; + } + break; case Pinetime::Controllers::Ble::FirmwareUpdateStates::Running: if (state != States::Running) state = States::Running; - return DisplayProgression(); + DisplayProgression(); + break; case Pinetime::Controllers::Ble::FirmwareUpdateStates::Validated: if (state != States::Validated) { UpdateValidated(); state = States::Validated; } - return running; + break; case Pinetime::Controllers::Ble::FirmwareUpdateStates::Error: if (state != States::Error) { UpdateError(); state = States::Error; } - return running; + if (xTaskGetTickCount() - startTime > (5 * 1024)) { + running = false; + } + break; } + return running; } -bool FirmwareUpdate::DisplayProgression() const { +void FirmwareUpdate::DisplayProgression() const { float current = bleController.FirmwareUpdateCurrentBytes() / 1024.0f; float total = bleController.FirmwareUpdateTotalBytes() / 1024.0f; int16_t pc = (current / total) * 100.0f; @@ -67,7 +84,6 @@ bool FirmwareUpdate::DisplayProgression() const { lv_label_set_text(percentLabel, percentStr); lv_bar_set_value(bar1, pc, LV_ANIM_OFF); - return running; } void FirmwareUpdate::UpdateValidated() { @@ -78,4 +94,9 @@ void FirmwareUpdate::UpdateValidated() { void FirmwareUpdate::UpdateError() { lv_label_set_recolor(percentLabel, true); lv_label_set_text(percentLabel, "#ff0000 Error!#"); + startTime = xTaskGetTickCount(); +} + +bool FirmwareUpdate::OnButtonPushed() { + return true; } diff --git a/src/displayapp/screens/FirmwareUpdate.h b/src/displayapp/screens/FirmwareUpdate.h index f4d34df0..90c99f4c 100644 --- a/src/displayapp/screens/FirmwareUpdate.h +++ b/src/displayapp/screens/FirmwareUpdate.h @@ -2,6 +2,7 @@ #include "Screen.h" #include +#include "FreeRTOS.h" namespace Pinetime { namespace Controllers { @@ -25,13 +26,17 @@ namespace Pinetime { lv_obj_t* titleLabel; mutable char percentStr[10]; - States state; + States state = States::Idle; - bool DisplayProgression() const; + void DisplayProgression() const; + + bool OnButtonPushed() override; void UpdateValidated(); void UpdateError(); + + TickType_t startTime; }; } } diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index d8b965b1..7efd1d6b 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -198,7 +198,11 @@ void SystemTask::Work() { Messages message = static_cast(msg); switch (message) { case Messages::EnableSleeping: - doNotGoToSleep = false; + // Make sure that exiting an app doesn't enable sleeping, + // if the exiting was caused by a firmware update + if (!bleController.IsFirmwareUpdating()) { + doNotGoToSleep = false; + } break; case Messages::DisableSleeping: doNotGoToSleep = true; @@ -275,10 +279,11 @@ void SystemTask::Work() { displayApp.PushMessage(Pinetime::Applications::Display::Messages::BleFirmwareUpdateStarted); break; case Messages::BleFirmwareUpdateFinished: + if (bleController.State() == Pinetime::Controllers::Ble::FirmwareUpdateStates::Validated) { + NVIC_SystemReset(); + } doNotGoToSleep = false; xTimerStart(idleTimer, 0); - if (bleController.State() == Pinetime::Controllers::Ble::FirmwareUpdateStates::Validated) - NVIC_SystemReset(); break; case Messages::OnTouchEvent: ReloadIdleTimer(); -- cgit v1.2.3 From 34949a47c59e7a4d8f67a0188bba6d08a046340d Mon Sep 17 00:00:00 2001 From: Riku Isokoski Date: Sat, 24 Jul 2021 21:29:10 +0300 Subject: Dim screen before sleep (#464) * Implement dimming --- src/displayapp/DisplayApp.cpp | 13 ++++++++++++- src/displayapp/Messages.h | 6 ++++-- src/systemtask/SystemTask.cpp | 45 ++++++++++++++++++++++++++++++++----------- src/systemtask/SystemTask.h | 7 ++++--- 4 files changed, 54 insertions(+), 17 deletions(-) (limited to 'src/systemtask/SystemTask.cpp') diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index b0948393..b5ad26f0 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -165,8 +165,15 @@ void DisplayApp::Refresh() { lastWakeTime = xTaskGetTickCount(); if (messageReceived) { switch (msg) { - case Messages::GoToSleep: + case Messages::DimScreen: + // Backup brightness is the brightness to return to after dimming or sleeping brightnessController.Backup(); + brightnessController.Set(Controllers::BrightnessController::Levels::Low); + break; + case Messages::RestoreBrightness: + brightnessController.Restore(); + break; + case Messages::GoToSleep: while (brightnessController.Level() != Controllers::BrightnessController::Levels::Off) { brightnessController.Lower(); vTaskDelay(100); @@ -230,6 +237,8 @@ void DisplayApp::Refresh() { } } else if (returnTouchEvent == gesture) { LoadApp(returnToApp, returnDirection); + brightnessController.Set(settingsController.GetBrightness()); + brightnessController.Backup(); } else if (touchMode == TouchModes::Gestures) { if (gesture == TouchEvents::Tap) { lvgl.SetNewTapEvent(info.x, info.y); @@ -243,6 +252,8 @@ void DisplayApp::Refresh() { } else { if (!currentScreen->OnButtonPushed()) { LoadApp(returnToApp, returnDirection); + brightnessController.Set(settingsController.GetBrightness()); + brightnessController.Backup(); } } break; diff --git a/src/displayapp/Messages.h b/src/displayapp/Messages.h index ce65f846..322505e6 100644 --- a/src/displayapp/Messages.h +++ b/src/displayapp/Messages.h @@ -13,8 +13,10 @@ namespace Pinetime { NewNotification, TimerDone, BleFirmwareUpdateStarted, - UpdateTimeOut + UpdateTimeOut, + DimScreen, + RestoreBrightness }; } } -} \ No newline at end of file +} diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index 7efd1d6b..8915ce74 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -33,6 +33,13 @@ namespace { } } +void DimTimerCallback(TimerHandle_t xTimer) { + + NRF_LOG_INFO("DimTimerCallback"); + auto sysTask = static_cast(pvTimerGetTimerID(xTimer)); + sysTask->OnDim(); +} + void IdleTimerCallback(TimerHandle_t xTimer) { NRF_LOG_INFO("IdleTimerCallback"); @@ -105,7 +112,7 @@ void SystemTask::Work() { APP_GPIOTE_INIT(2); app_timer_init(); - + spi.Init(); spiNorFlash.Init(); spiNorFlash.Wakeup(); @@ -114,7 +121,6 @@ void SystemTask::Work() { nimbleController.Init(); nimbleController.StartAdvertising(); - brightnessController.Init(); lcd.Init(); twiMaster.Init(); @@ -179,8 +185,9 @@ void SystemTask::Work() { nrf_gpio_cfg_sense_input(pinPowerPresentIrq, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_HIGH); } - idleTimer = xTimerCreate("idleTimer", pdMS_TO_TICKS(settingsController.GetScreenTimeOut()), pdFALSE, this, IdleTimerCallback); - xTimerStart(idleTimer, 0); + idleTimer = xTimerCreate("idleTimer", pdMS_TO_TICKS(2000), pdFALSE, this, IdleTimerCallback); + dimTimer = xTimerCreate("dimTimer", pdMS_TO_TICKS(settingsController.GetScreenTimeOut() - 2000), pdFALSE, this, DimTimerCallback); + xTimerStart(dimTimer, 0); // Suppress endless loop diagnostic #pragma clang diagnostic push @@ -208,7 +215,7 @@ void SystemTask::Work() { doNotGoToSleep = true; break; case Messages::UpdateTimeOut: - xTimerChangePeriod(idleTimer, pdMS_TO_TICKS(settingsController.GetScreenTimeOut()), 0); + xTimerChangePeriod(dimTimer, pdMS_TO_TICKS(settingsController.GetScreenTimeOut() - 2000), 0); break; case Messages::GoToRunning: spi.Wakeup(); @@ -220,7 +227,7 @@ void SystemTask::Work() { } nimbleController.StartAdvertising(); - xTimerStart(idleTimer, 0); + xTimerStart(dimTimer, 0); spiNorFlash.Wakeup(); lcd.Wakeup(); @@ -230,6 +237,7 @@ void SystemTask::Work() { isSleeping = false; isWakingUp = false; + isDimmed = false; break; case Messages::TouchWakeUp: { twiMaster.Wakeup(); @@ -246,6 +254,7 @@ void SystemTask::Work() { isGoingToSleep = true; NRF_LOG_INFO("[systemtask] Going to sleep"); xTimerStop(idleTimer, 0); + xTimerStop(dimTimer, 0); displayApp.PushMessage(Pinetime::Applications::Display::Messages::GoToSleep); heartRateApp.PushMessage(Pinetime::Applications::HeartRateTask::Messages::GoToSleep); break; @@ -283,13 +292,15 @@ void SystemTask::Work() { NVIC_SystemReset(); } doNotGoToSleep = false; - xTimerStart(idleTimer, 0); + xTimerStart(dimTimer, 0); break; case Messages::OnTouchEvent: ReloadIdleTimer(); + displayApp.PushMessage(Pinetime::Applications::Display::Messages::TouchEvent); break; case Messages::OnButtonEvent: ReloadIdleTimer(); + displayApp.PushMessage(Pinetime::Applications::Display::Messages::ButtonPushed); break; case Messages::OnDisplayTaskSleeping: if (BootloaderVersion::IsValid()) { @@ -381,7 +392,6 @@ void SystemTask::OnButtonPushed() { if (!isSleeping) { NRF_LOG_INFO("[systemtask] Button pushed"); PushMessage(Messages::OnButtonEvent); - displayApp.PushMessage(Pinetime::Applications::Display::Messages::ButtonPushed); } else { if (!isWakingUp) { NRF_LOG_INFO("[systemtask] Button pushed, waking up"); @@ -402,7 +412,6 @@ void SystemTask::OnTouchEvent() { return; if (!isSleeping) { PushMessage(Messages::OnTouchEvent); - displayApp.PushMessage(Pinetime::Applications::Display::Messages::TouchEvent); } else if (!isWakingUp) { if (settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::SingleTap) or settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::DoubleTap)) { @@ -430,6 +439,15 @@ void SystemTask::PushMessage(System::Messages msg) { } } +void SystemTask::OnDim() { + if (doNotGoToSleep) + return; + NRF_LOG_INFO("Dim timeout -> Dim screen") + displayApp.PushMessage(Pinetime::Applications::Display::Messages::DimScreen); + xTimerStart(idleTimer, 0); + isDimmed = true; +} + void SystemTask::OnIdle() { if (doNotGoToSleep) return; @@ -437,8 +455,13 @@ void SystemTask::OnIdle() { PushMessage(Messages::GoToSleep); } -void SystemTask::ReloadIdleTimer() const { +void SystemTask::ReloadIdleTimer() { if (isSleeping || isGoingToSleep) return; - xTimerReset(idleTimer, 0); + if (isDimmed) { + displayApp.PushMessage(Pinetime::Applications::Display::Messages::RestoreBrightness); + isDimmed = false; + } + xTimerReset(dimTimer, 0); + xTimerStop(idleTimer, 0); } diff --git a/src/systemtask/SystemTask.h b/src/systemtask/SystemTask.h index f8cf6370..ba434298 100644 --- a/src/systemtask/SystemTask.h +++ b/src/systemtask/SystemTask.h @@ -71,6 +71,7 @@ namespace Pinetime { void OnTouchEvent(); void OnIdle(); + void OnDim(); Pinetime::Controllers::NimbleController& nimble() { return nimbleController; @@ -99,6 +100,7 @@ namespace Pinetime { std::atomic isSleeping {false}; std::atomic isGoingToSleep {false}; std::atomic isWakingUp {false}; + std::atomic isDimmed {false}; Pinetime::Drivers::Watchdog& watchdog; Pinetime::Controllers::NotificationManager& notificationManager; Pinetime::Controllers::MotorController& motorController; @@ -106,8 +108,6 @@ namespace Pinetime { Pinetime::Drivers::Bma421& motionSensor; Pinetime::Controllers::Settings& settingsController; Pinetime::Controllers::HeartRateController& heartRateController; - - Controllers::BrightnessController brightnessController; Pinetime::Controllers::MotionController& motionController; Pinetime::Applications::DisplayApp& displayApp; @@ -126,9 +126,10 @@ namespace Pinetime { static void Process(void* instance); void Work(); - void ReloadIdleTimer() const; + void ReloadIdleTimer(); bool isBleDiscoveryTimerRunning = false; uint8_t bleDiscoveryTimer = 0; + TimerHandle_t dimTimer; TimerHandle_t idleTimer; bool doNotGoToSleep = false; -- cgit v1.2.3 From e6dcb3009fe6f847a7486dbb1b3143bbf49a15b9 Mon Sep 17 00:00:00 2001 From: Riku Isokoski Date: Sun, 1 Aug 2021 13:05:48 +0300 Subject: Improvements --- src/components/motor/MotorController.cpp | 40 ++++----- src/components/motor/MotorController.h | 12 +-- src/displayapp/DisplayApp.cpp | 4 +- src/displayapp/screens/Metronome.cpp | 4 +- src/displayapp/screens/Notifications.cpp | 103 ++++++---------------- src/displayapp/screens/Notifications.h | 27 ++---- src/displayapp/screens/settings/QuickSettings.cpp | 2 +- src/systemtask/SystemTask.cpp | 9 +- 8 files changed, 70 insertions(+), 131 deletions(-) (limited to 'src/systemtask/SystemTask.cpp') diff --git a/src/components/motor/MotorController.cpp b/src/components/motor/MotorController.cpp index 80883025..b25e6bc8 100644 --- a/src/components/motor/MotorController.cpp +++ b/src/components/motor/MotorController.cpp @@ -16,41 +16,37 @@ void MotorController::Init() { nrf_gpio_pin_set(pinMotor); app_timer_init(); - app_timer_create(&shortVibTimer, APP_TIMER_MODE_SINGLE_SHOT, vibrate); - app_timer_create(&longVibTimer, APP_TIMER_MODE_REPEATED, vibrate); - isBusy = false; + app_timer_create(&shortVibTimer, APP_TIMER_MODE_SINGLE_SHOT, StopMotor); + app_timer_create(&longVibTimer, APP_TIMER_MODE_REPEATED, Ring); } -void MotorController::runForDuration(uint8_t motorDuration) { +void MotorController::Ring(void* p_context) { + auto* motorController = static_cast(p_context); + motorController->RunForDuration(50); +} - if (settingsController.GetVibrationStatus() == Controllers::Settings::Vibration::OFF || isBusy) +void MotorController::RunForDuration(uint8_t motorDuration) { + if (settingsController.GetVibrationStatus() == Controllers::Settings::Vibration::OFF) { return; + } nrf_gpio_pin_clear(pinMotor); - /* Start timer for motorDuration miliseconds and timer triggers vibrate() when it finishes*/ - app_timer_start(shortVibTimer, APP_TIMER_TICKS(motorDuration), NULL); + app_timer_start(shortVibTimer, APP_TIMER_TICKS(motorDuration), nullptr); } -void MotorController::startRunning(uint8_t motorDuration) { - if (settingsController.GetVibrationStatus() == Controllers::Settings::Vibration::OFF || isBusy ) +void MotorController::StartRinging() { + if (settingsController.GetVibrationStatus() == Controllers::Settings::Vibration::OFF) { return; - //prevent other vibrations while running - isBusy = true; - nrf_gpio_pin_clear(pinMotor); - app_timer_start(longVibTimer, APP_TIMER_TICKS(motorDuration), NULL); + } + Ring(this); + app_timer_start(longVibTimer, APP_TIMER_TICKS(1000), this); } -void MotorController::stopRunning() { - +void MotorController::StopRinging() { app_timer_stop(longVibTimer); nrf_gpio_pin_set(pinMotor); - isBusy = false; } -void MotorController::vibrate(void* p_context) { - if (nrf_gpio_pin_out_read(pinMotor) == 0) { - nrf_gpio_pin_set(pinMotor); - } else { - nrf_gpio_pin_clear(pinMotor); - } +void MotorController::StopMotor(void* p_context) { + nrf_gpio_pin_set(pinMotor); } diff --git a/src/components/motor/MotorController.h b/src/components/motor/MotorController.h index 5daeb8ce..d2c9fe5f 100644 --- a/src/components/motor/MotorController.h +++ b/src/components/motor/MotorController.h @@ -12,14 +12,14 @@ namespace Pinetime { public: MotorController(Controllers::Settings& settingsController); void Init(); - void runForDuration(uint8_t motorDuration); - void startRunning(uint8_t motorDuration); - void stopRunning(); + void RunForDuration(uint8_t motorDuration); + void StartRinging(); + static void StopRinging(); private: + static void Ring(void* p_context); Controllers::Settings& settingsController; - static void vibrate(void* p_context); - bool isBusy; - }; + static void StopMotor(void* p_context); + }; } } diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index bdd703ee..d4a73f5e 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -336,12 +336,12 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction) case Apps::Notifications: currentScreen = std::make_unique( - this, notificationManager, systemTask->nimble().alertService(), motorController, Screens::Notifications::Modes::Normal); + this, notificationManager, systemTask->nimble().alertService(), Screens::Notifications::Modes::Normal); ReturnApp(Apps::Clock, FullRefreshDirections::Up, TouchEvents::SwipeUp); break; case Apps::NotificationsPreview: currentScreen = std::make_unique( - this, notificationManager, systemTask->nimble().alertService(), motorController, Screens::Notifications::Modes::Preview); + this, notificationManager, systemTask->nimble().alertService(), Screens::Notifications::Modes::Preview); ReturnApp(Apps::Clock, FullRefreshDirections::Up, TouchEvents::SwipeUp); break; case Apps::Timer: diff --git a/src/displayapp/screens/Metronome.cpp b/src/displayapp/screens/Metronome.cpp index 7bfbccb7..16c34f45 100644 --- a/src/displayapp/screens/Metronome.cpp +++ b/src/displayapp/screens/Metronome.cpp @@ -109,9 +109,9 @@ bool Metronome::Refresh() { startTime = xTaskGetTickCount(); if (counter == 0) { counter = bpb; - motorController.SetDuration(90); + motorController.RunForDuration(90); } else { - motorController.SetDuration(30); + motorController.RunForDuration(30); } } break; diff --git a/src/displayapp/screens/Notifications.cpp b/src/displayapp/screens/Notifications.cpp index 5eecb421..5096917e 100644 --- a/src/displayapp/screens/Notifications.cpp +++ b/src/displayapp/screens/Notifications.cpp @@ -11,13 +11,8 @@ extern lv_font_t jetbrains_mono_bold_20; Notifications::Notifications(DisplayApp* app, Pinetime::Controllers::NotificationManager& notificationManager, Pinetime::Controllers::AlertNotificationService& alertNotificationService, - Controllers::MotorController& motorController, Modes mode) - : Screen(app), - notificationManager{notificationManager}, - alertNotificationService{alertNotificationService}, - motorController{motorController}, - mode{mode} { + : Screen(app), notificationManager {notificationManager}, alertNotificationService {alertNotificationService}, mode {mode} { notificationManager.ClearNewNotificationFlag(); auto notification = notificationManager.GetLastNotification(); if (notification.valid) { @@ -28,10 +23,7 @@ Notifications::Notifications(DisplayApp* app, notification.category, notificationManager.NbNotifications(), mode, - alertNotificationService, - motorController, - &timeoutTickCountEnd, - &timeoutTickCountStart); + alertNotificationService); validDisplay = true; } else { currentItem = std::make_unique("Notification", @@ -40,14 +32,10 @@ Notifications::Notifications(DisplayApp* app, notification.category, notificationManager.NbNotifications(), Modes::Preview, - alertNotificationService, - motorController, - &timeoutTickCountEnd, - &timeoutTickCountStart); + alertNotificationService); } - if (mode == Modes::Preview) { - + if (mode == Modes::Preview && notification.category != Controllers::NotificationManager::Categories::IncomingCall) { timeoutLine = lv_line_create(lv_scr_act(), nullptr); lv_obj_set_style_local_line_width(timeoutLine, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, 3); @@ -61,11 +49,13 @@ Notifications::Notifications(DisplayApp* app, } Notifications::~Notifications() { + // make sure we stop any vibrations before exiting + Controllers::MotorController::StopRinging(); lv_obj_clean(lv_scr_act()); } bool Notifications::Refresh() { - if (mode == Modes::Preview && !currentItem->timeoutOnHold) { + if (mode == Modes::Preview && timeoutLine != nullptr) { auto tick = xTaskGetTickCount(); int32_t pos = 240 - ((tick - timeoutTickCountStart) / ((timeoutTickCountEnd - timeoutTickCountStart) / 240)); if (pos < 0) @@ -74,10 +64,7 @@ bool Notifications::Refresh() { timeoutLinePoints[1].x = pos; lv_line_set_points(timeoutLine, timeoutLinePoints, 2); } - //make sure we stop any vibrations before exiting - if (!running) - motorController.stopRunning(); - return running; + return running && currentItem->IsRunning(); } bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) { @@ -105,10 +92,7 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) { previousNotification.category, notificationManager.NbNotifications(), mode, - alertNotificationService, - motorController, - &timeoutTickCountEnd, - &timeoutTickCountStart); + alertNotificationService); } return true; case Pinetime::Applications::TouchEvents::SwipeUp: { @@ -133,10 +117,7 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) { nextNotification.category, notificationManager.NbNotifications(), mode, - alertNotificationService, - motorController, - &timeoutTickCountEnd, - &timeoutTickCountStart); + alertNotificationService); } return true; case Pinetime::Applications::TouchEvents::LongTap: { @@ -149,19 +130,9 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) { } namespace { - static void AcceptIncomingCallEventHandler(lv_obj_t* obj, lv_event_t event) { - auto* item = static_cast(obj->user_data); - item->OnAcceptIncomingCall(event); - } - - static void MuteIncomingCallEventHandler(lv_obj_t* obj, lv_event_t event) { + void CallEventHandler(lv_obj_t* obj, lv_event_t event) { auto* item = static_cast(obj->user_data); - item->OnMuteIncomingCall(event); - } - - static void RejectIncomingCallEventHandler(lv_obj_t* obj, lv_event_t event) { - auto* item = static_cast(obj->user_data); - item->OnRejectIncomingCall(event); + item->OnCallButtonEvent(obj, event); } } @@ -171,12 +142,8 @@ Notifications::NotificationItem::NotificationItem(const char* title, Controllers::NotificationManager::Categories category, uint8_t notifNb, Modes mode, - Pinetime::Controllers::AlertNotificationService& alertNotificationService, - Controllers::MotorController& motorController, - uint32_t* timeoutEnd, - uint32_t* timeoutStart) - : notifNr{notifNr}, notifNb{notifNb}, mode{mode}, alertNotificationService{alertNotificationService}, - motorController{motorController}, timeoutEnd{timeoutEnd}, timeoutStart{timeoutStart} { + Pinetime::Controllers::AlertNotificationService& alertNotificationService) + : notifNr {notifNr}, notifNb {notifNb}, mode {mode}, alertNotificationService {alertNotificationService} { 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)); @@ -234,7 +201,7 @@ Notifications::NotificationItem::NotificationItem(const char* title, bt_accept = lv_btn_create(lv_scr_act(), nullptr); bt_accept->user_data = this; - lv_obj_set_event_cb(bt_accept, AcceptIncomingCallEventHandler); + lv_obj_set_event_cb(bt_accept, CallEventHandler); lv_obj_set_size(bt_accept, 76, 76); lv_obj_align(bt_accept, NULL, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0); label_accept = lv_label_create(bt_accept, nullptr); @@ -243,7 +210,7 @@ Notifications::NotificationItem::NotificationItem(const char* title, bt_reject = lv_btn_create(lv_scr_act(), nullptr); bt_reject->user_data = this; - lv_obj_set_event_cb(bt_reject, RejectIncomingCallEventHandler); + lv_obj_set_event_cb(bt_reject, CallEventHandler); lv_obj_set_size(bt_reject, 76, 76); lv_obj_align(bt_reject, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, 0); label_reject = lv_label_create(bt_reject, nullptr); @@ -252,13 +219,12 @@ Notifications::NotificationItem::NotificationItem(const char* title, bt_mute = lv_btn_create(lv_scr_act(), nullptr); bt_mute->user_data = this; - lv_obj_set_event_cb(bt_mute, MuteIncomingCallEventHandler); + lv_obj_set_event_cb(bt_mute, CallEventHandler); lv_obj_set_size(bt_mute, 76, 76); lv_obj_align(bt_mute, NULL, LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0); label_mute = lv_label_create(bt_mute, nullptr); lv_label_set_text(label_mute, Symbols::volumMute); lv_obj_set_style_local_bg_color(bt_mute, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY); - timeoutOnHold = true; } break; } @@ -269,35 +235,24 @@ Notifications::NotificationItem::NotificationItem(const char* title, lv_label_set_text(backgroundLabel, ""); } -void Notifications::NotificationItem::OnAcceptIncomingCall(lv_event_t event) { - if (event != LV_EVENT_CLICKED) +void Notifications::NotificationItem::OnCallButtonEvent(lv_obj_t* obj, lv_event_t event) { + if (event != LV_EVENT_CLICKED) { return; - callPreviewInteraction(); - alertNotificationService.AcceptIncomingCall(); -} + } -void Notifications::NotificationItem::OnMuteIncomingCall(lv_event_t event) { - if (event != LV_EVENT_CLICKED) - return; - callPreviewInteraction(); - alertNotificationService.MuteIncomingCall(); -} + Controllers::MotorController::StopRinging(); -void Notifications::NotificationItem::OnRejectIncomingCall(lv_event_t event) { - if (event != LV_EVENT_CLICKED) - return; - callPreviewInteraction(); - alertNotificationService.RejectIncomingCall(); -} + if (obj == bt_accept) { + alertNotificationService.AcceptIncomingCall(); + } else if (obj == bt_reject) { + alertNotificationService.RejectIncomingCall(); + } else if (obj == bt_mute) { + alertNotificationService.MuteIncomingCall(); + } -inline void Notifications::NotificationItem::callPreviewInteraction() { - *timeoutStart = xTaskGetTickCount(); - *timeoutEnd = *timeoutStart + (5 * 1024); - timeoutOnHold = false; - motorController.stopRunning(); + running = false; } - Notifications::NotificationItem::~NotificationItem() { lv_obj_clean(lv_scr_act()); } diff --git a/src/displayapp/screens/Notifications.h b/src/displayapp/screens/Notifications.h index 32bd0770..9244e9fa 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 Controllers { @@ -20,7 +19,6 @@ namespace Pinetime { explicit Notifications(DisplayApp* app, Pinetime::Controllers::NotificationManager& notificationManager, Pinetime::Controllers::AlertNotificationService& alertNotificationService, - Controllers::MotorController& motorController, Modes mode); ~Notifications() override; @@ -35,22 +33,14 @@ namespace Pinetime { Controllers::NotificationManager::Categories, uint8_t notifNb, Modes mode, - Pinetime::Controllers::AlertNotificationService& alertNotificationService, - Controllers::MotorController& motorController, - uint32_t* timeoutEnd, - uint32_t* timeoutStart); + Pinetime::Controllers::AlertNotificationService& alertNotificationService); ~NotificationItem(); - bool Refresh() { - return false; + bool IsRunning() const { + return running; } - void OnAcceptIncomingCall(lv_event_t event); - void OnMuteIncomingCall(lv_event_t event); - void OnRejectIncomingCall(lv_event_t event); - - bool timeoutOnHold = false; + void OnCallButtonEvent(lv_obj_t*, lv_event_t event); + private: - void callPreviewInteraction(); - uint8_t notifNr = 0; uint8_t notifNb = 0; char pageText[4]; @@ -66,11 +56,9 @@ namespace Pinetime { lv_obj_t* label_mute; lv_obj_t* label_reject; lv_obj_t* bottomPlaceholder; - uint32_t* timeoutEnd; - uint32_t* timeoutStart; Modes mode; Pinetime::Controllers::AlertNotificationService& alertNotificationService; - Controllers::MotorController& motorController; + bool running = true; }; private: @@ -83,11 +71,10 @@ namespace Pinetime { Modes mode = Modes::Normal; std::unique_ptr currentItem; Controllers::NotificationManager::Notification::Id currentId; - Controllers::MotorController& motorController; bool validDisplay = false; lv_point_t timeoutLinePoints[2] {{0, 1}, {239, 1}}; - lv_obj_t* timeoutLine; + lv_obj_t* timeoutLine = nullptr; uint32_t timeoutTickCountStart; uint32_t timeoutTickCountEnd; }; diff --git a/src/displayapp/screens/settings/QuickSettings.cpp b/src/displayapp/screens/settings/QuickSettings.cpp index 5e46e2e5..0421d103 100644 --- a/src/displayapp/screens/settings/QuickSettings.cpp +++ b/src/displayapp/screens/settings/QuickSettings.cpp @@ -140,7 +140,7 @@ void QuickSettings::OnButtonEvent(lv_obj_t* object, lv_event_t event) { if (lv_obj_get_state(btn3, LV_BTN_PART_MAIN) & LV_STATE_CHECKED) { settingsController.SetVibrationStatus(Controllers::Settings::Vibration::ON); - motorController.runForDuration(35); + motorController.RunForDuration(35); lv_label_set_text_static(btn3_lvl, Symbols::notificationsOn); } else { settingsController.SetVibrationStatus(Controllers::Settings::Vibration::OFF); diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index f05ade65..7426ac2f 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -267,16 +267,17 @@ void SystemTask::Work() { GoToRunning(); } if (notificationManager.GetLastNotification().category == Controllers::NotificationManager::Categories::IncomingCall) { - motorController.startRunning(500); + motorController.StartRinging(); } else { - motorController.runForDuration(35); + motorController.RunForDuration(35); } displayApp.PushMessage(Pinetime::Applications::Display::Messages::NewNotification); + break; case Messages::OnTimerDone: if (isSleeping && !isWakingUp) { GoToRunning(); } - motorController.runForDuration(35); + motorController.RunForDuration(35); displayApp.PushMessage(Pinetime::Applications::Display::Messages::TimerDone); break; case Messages::BleConnected: @@ -329,7 +330,7 @@ void SystemTask::Work() { stepCounterMustBeReset = true; break; case Messages::OnChargingEvent: - motorController.SetDuration(15); + motorController.RunForDuration(15); // Battery level is updated on every message - there's no need to do anything break; -- cgit v1.2.3 From f9319dfb91a38c773b4af221f2fd0d975cf061f2 Mon Sep 17 00:00:00 2001 From: Riku Isokoski Date: Sun, 1 Aug 2021 21:19:33 +0300 Subject: Remove leftover --- src/systemtask/SystemTask.cpp | 5 ----- 1 file changed, 5 deletions(-) (limited to 'src/systemtask/SystemTask.cpp') diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index 7426ac2f..3553f449 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -266,11 +266,6 @@ void SystemTask::Work() { if (isSleeping && !isWakingUp) { GoToRunning(); } - if (notificationManager.GetLastNotification().category == Controllers::NotificationManager::Categories::IncomingCall) { - motorController.StartRinging(); - } else { - motorController.RunForDuration(35); - } displayApp.PushMessage(Pinetime::Applications::Display::Messages::NewNotification); break; case Messages::OnTimerDone: -- cgit v1.2.3