From 7bc4234d6ffcd147e55d7ffaa371d729308fe4c0 Mon Sep 17 00:00:00 2001 From: jspkay Date: Sat, 12 Nov 2022 14:52:39 +0100 Subject: [PATCH 1/4] Notifications are better displayed --- src/displayapp/DisplayApp.cpp | 11 +++++++++++ src/displayapp/screens/Notifications.cpp | 17 ++++++++++++++--- src/displayapp/screens/Notifications.h | 4 ++++ 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index 108e380d..2c4bf9e9 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -165,11 +165,18 @@ void DisplayApp::Refresh() { brightnessController.Lower(); vTaskDelay(100); } + PushMessageToSystemTask(Pinetime::System::Messages::OnDisplayTaskSleeping); state = States::Idle; break; case Messages::GoToRunning: ApplyBrightness(); + + // reload main display app if we are notifications or quicksettings or app menu + if(currentApp == Apps::Launcher || currentApp == Apps::Notifications || currentApp == Apps::QuickSettings){ + LoadApp(Apps::Clock, DisplayApp::FullRefreshDirections::Up); + } + state = States::Running; break; case Messages::UpdateTimeOut: @@ -302,6 +309,7 @@ void DisplayApp::ReturnApp(Apps app, DisplayApp::FullRefreshDirections direction } void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction) { + NRF_LOG_INFO("Loading app...") touchHandler.CancelTap(); ApplyBrightness(); @@ -319,6 +327,7 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction) break; case Apps::None: case Apps::Clock: + NRF_LOG_INFO("Loading clock") currentScreen = std::make_unique(this, dateTimeController, batteryController, @@ -328,6 +337,7 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction) heartRateController, motionController, filesystem); + ReturnApp(Apps::Clock, FullRefreshDirections::Down, TouchEvents::SwipeDown); break; case Apps::Error: @@ -480,6 +490,7 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction) currentScreen = std::make_unique(this, motionController, settingsController); break; } + NRF_LOG_INFO("DONE") currentApp = app; } diff --git a/src/displayapp/screens/Notifications.cpp b/src/displayapp/screens/Notifications.cpp index 90a010f5..3e852323 100644 --- a/src/displayapp/screens/Notifications.cpp +++ b/src/displayapp/screens/Notifications.cpp @@ -79,6 +79,12 @@ void Notifications::Refresh() { timeoutLinePoints[1].x = pos; lv_line_set_points(timeoutLine, timeoutLinePoints, 2); } + + if(!this->scrolling && tick >= timeoutTickCountStart + timeoutStartScrolling){ + this->scrolling = true; + lv_label_set_long_mode(currentItem->alert_type, LV_LABEL_LONG_SROLL_CIRC); + } + } if (dismissingNotification) { @@ -127,13 +133,18 @@ void Notifications::OnPreviewInteraction() { } bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) { - if (mode != Modes::Normal) { + /*if (mode != Modes::Normal) { if (!interacted && event == TouchEvents::Tap) { interacted = true; OnPreviewInteraction(); return true; } return false; + }*/ + + if(mode == Modes::Preview){ + interacted=true; + OnPreviewInteraction(); } switch (event) { @@ -272,7 +283,7 @@ Notifications::NotificationItem::NotificationItem(const char* title, lv_label_set_text_fmt(alert_count, "%i/%i", notifNr, notifNb); lv_obj_align(alert_count, NULL, LV_ALIGN_IN_TOP_RIGHT, 0, 16); - lv_obj_t* alert_type = lv_label_create(container, nullptr); + alert_type = lv_label_create(container, nullptr); lv_obj_set_style_local_text_color(alert_type, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::orange); if (title == nullptr) { lv_label_set_text_static(alert_type, "Notification"); @@ -286,7 +297,7 @@ Notifications::NotificationItem::NotificationItem(const char* title, } lv_label_refr_text(alert_type); } - lv_label_set_long_mode(alert_type, LV_LABEL_LONG_SROLL_CIRC); + lv_label_set_long_mode(alert_type, LV_LABEL_LONG_CROP); lv_obj_set_width(alert_type, 180); lv_obj_align(alert_type, NULL, LV_ALIGN_IN_TOP_LEFT, 0, 16); diff --git a/src/displayapp/screens/Notifications.h b/src/displayapp/screens/Notifications.h index 9d843a9b..656579f3 100644 --- a/src/displayapp/screens/Notifications.h +++ b/src/displayapp/screens/Notifications.h @@ -47,6 +47,7 @@ namespace Pinetime { return running; } void OnCallButtonEvent(lv_obj_t*, lv_event_t event); + lv_obj_t *alert_type; private: lv_obj_t* container; @@ -57,6 +58,7 @@ namespace Pinetime { lv_obj_t* label_accept; lv_obj_t* label_mute; lv_obj_t* label_reject; + Pinetime::Controllers::AlertNotificationService& alertNotificationService; Pinetime::Controllers::MotorController& motorController; @@ -79,7 +81,9 @@ namespace Pinetime { TickType_t timeoutTickCountStart; static const TickType_t timeoutLength = pdMS_TO_TICKS(7000); + static const TickType_t timeoutStartScrolling = pdMS_TO_TICKS(1000); bool interacted = true; + bool scrolling = false; bool dismissingNotification = false; From 988a91ef516656342dbb7e7acb89c72f0dda0983 Mon Sep 17 00:00:00 2001 From: jspkay Date: Sun, 13 Nov 2022 20:18:32 +0100 Subject: [PATCH 2/4] Notification title in preview stay fixed for one second then starts scrolling --- src/displayapp/DisplayApp.cpp | 11 ----------- src/displayapp/screens/Notifications.cpp | 18 ++++++++---------- src/displayapp/screens/Notifications.h | 7 ++++--- 3 files changed, 12 insertions(+), 24 deletions(-) diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index 2c4bf9e9..108e380d 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -165,18 +165,11 @@ void DisplayApp::Refresh() { brightnessController.Lower(); vTaskDelay(100); } - PushMessageToSystemTask(Pinetime::System::Messages::OnDisplayTaskSleeping); state = States::Idle; break; case Messages::GoToRunning: ApplyBrightness(); - - // reload main display app if we are notifications or quicksettings or app menu - if(currentApp == Apps::Launcher || currentApp == Apps::Notifications || currentApp == Apps::QuickSettings){ - LoadApp(Apps::Clock, DisplayApp::FullRefreshDirections::Up); - } - state = States::Running; break; case Messages::UpdateTimeOut: @@ -309,7 +302,6 @@ void DisplayApp::ReturnApp(Apps app, DisplayApp::FullRefreshDirections direction } void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction) { - NRF_LOG_INFO("Loading app...") touchHandler.CancelTap(); ApplyBrightness(); @@ -327,7 +319,6 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction) break; case Apps::None: case Apps::Clock: - NRF_LOG_INFO("Loading clock") currentScreen = std::make_unique(this, dateTimeController, batteryController, @@ -337,7 +328,6 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction) heartRateController, motionController, filesystem); - ReturnApp(Apps::Clock, FullRefreshDirections::Down, TouchEvents::SwipeDown); break; case Apps::Error: @@ -490,7 +480,6 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction) currentScreen = std::make_unique(this, motionController, settingsController); break; } - NRF_LOG_INFO("DONE") currentApp = app; } diff --git a/src/displayapp/screens/Notifications.cpp b/src/displayapp/screens/Notifications.cpp index 3e852323..deeb9333 100644 --- a/src/displayapp/screens/Notifications.cpp +++ b/src/displayapp/screens/Notifications.cpp @@ -80,9 +80,9 @@ void Notifications::Refresh() { lv_line_set_points(timeoutLine, timeoutLinePoints, 2); } - if(!this->scrolling && tick >= timeoutTickCountStart + timeoutStartScrolling){ - this->scrolling = true; - lv_label_set_long_mode(currentItem->alert_type, LV_LABEL_LONG_SROLL_CIRC); + if(!this->isTitleScrolling && tick >= timeoutTickCountStart + timeoutStartScrolling){ + currentItem->StartTitleScroll(); + this->isTitleScrolling = true; } } @@ -133,20 +133,14 @@ void Notifications::OnPreviewInteraction() { } bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) { - /*if (mode != Modes::Normal) { + if (mode != Modes::Normal) { if (!interacted && event == TouchEvents::Tap) { interacted = true; OnPreviewInteraction(); return true; } return false; - }*/ - - if(mode == Modes::Preview){ - interacted=true; - OnPreviewInteraction(); } - switch (event) { case Pinetime::Applications::TouchEvents::SwipeRight: if (validDisplay) { @@ -370,3 +364,7 @@ void Notifications::NotificationItem::OnCallButtonEvent(lv_obj_t* obj, lv_event_ Notifications::NotificationItem::~NotificationItem() { lv_obj_clean(lv_scr_act()); } + +void Notifications::NotificationItem::StartTitleScroll(){ + lv_label_set_long_mode(this->alert_type, LV_LABEL_LONG_SROLL_CIRC); +} diff --git a/src/displayapp/screens/Notifications.h b/src/displayapp/screens/Notifications.h index 656579f3..2bb7f6f8 100644 --- a/src/displayapp/screens/Notifications.h +++ b/src/displayapp/screens/Notifications.h @@ -47,7 +47,7 @@ namespace Pinetime { return running; } void OnCallButtonEvent(lv_obj_t*, lv_event_t event); - lv_obj_t *alert_type; + void StartTitleScroll(); private: lv_obj_t* container; @@ -58,6 +58,7 @@ namespace Pinetime { lv_obj_t* label_accept; lv_obj_t* label_mute; lv_obj_t* label_reject; + lv_obj_t *alert_type; Pinetime::Controllers::AlertNotificationService& alertNotificationService; Pinetime::Controllers::MotorController& motorController; @@ -81,9 +82,9 @@ namespace Pinetime { TickType_t timeoutTickCountStart; static const TickType_t timeoutLength = pdMS_TO_TICKS(7000); - static const TickType_t timeoutStartScrolling = pdMS_TO_TICKS(1000); + static const TickType_t timeoutStartTitleScrolling = pdMS_TO_TICKS(1000); bool interacted = true; - bool scrolling = false; + bool isTitleScrolling = false; bool dismissingNotification = false; From d084d5c54ef9594d7f898d968d1ab050c5007493 Mon Sep 17 00:00:00 2001 From: jspkay Date: Sun, 13 Nov 2022 20:22:17 +0100 Subject: [PATCH 3/4] Fixed variable name --- src/displayapp/screens/Notifications.cpp | 2 +- src/displayapp/screens/Notifications.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/displayapp/screens/Notifications.cpp b/src/displayapp/screens/Notifications.cpp index deeb9333..2a85fa95 100644 --- a/src/displayapp/screens/Notifications.cpp +++ b/src/displayapp/screens/Notifications.cpp @@ -80,7 +80,7 @@ void Notifications::Refresh() { lv_line_set_points(timeoutLine, timeoutLinePoints, 2); } - if(!this->isTitleScrolling && tick >= timeoutTickCountStart + timeoutStartScrolling){ + if(!this->isTitleScrolling && tick >= timeoutTickCountStart + timeoutStartTitleScrolling){ currentItem->StartTitleScroll(); this->isTitleScrolling = true; } diff --git a/src/displayapp/screens/Notifications.h b/src/displayapp/screens/Notifications.h index 2bb7f6f8..0bc96b5e 100644 --- a/src/displayapp/screens/Notifications.h +++ b/src/displayapp/screens/Notifications.h @@ -47,7 +47,7 @@ namespace Pinetime { return running; } void OnCallButtonEvent(lv_obj_t*, lv_event_t event); - void StartTitleScroll(); + void StartTitleScroll(); private: lv_obj_t* container; From a4be63837642afd37c423a32a53849389de8db1f Mon Sep 17 00:00:00 2001 From: jspkay Date: Tue, 15 Nov 2022 12:39:01 +0100 Subject: [PATCH 4/4] Generalized the concept on NotificationItem rather than Notifictaions --- src/displayapp/screens/Notifications.cpp | 17 +++++++++++------ src/displayapp/screens/Notifications.h | 11 ++++++----- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/displayapp/screens/Notifications.cpp b/src/displayapp/screens/Notifications.cpp index 2a85fa95..73c6572c 100644 --- a/src/displayapp/screens/Notifications.cpp +++ b/src/displayapp/screens/Notifications.cpp @@ -79,12 +79,6 @@ void Notifications::Refresh() { timeoutLinePoints[1].x = pos; lv_line_set_points(timeoutLine, timeoutLinePoints, 2); } - - if(!this->isTitleScrolling && tick >= timeoutTickCountStart + timeoutStartTitleScrolling){ - currentItem->StartTitleScroll(); - this->isTitleScrolling = true; - } - } if (dismissingNotification) { @@ -141,6 +135,7 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) { } return false; } + switch (event) { case Pinetime::Applications::TouchEvents::SwipeRight: if (validDisplay) { @@ -341,6 +336,15 @@ Notifications::NotificationItem::NotificationItem(const char* title, lv_obj_set_style_local_bg_color(bt_mute, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::lightGray); } break; } + refreshTask = lv_task_create(Notifications::NotificationItem::Refresh, 1000, LV_TASK_PRIO_MID, this); + //lv_task_once(refreshTask); // The documentation says it exists, but I was unable to compile +} + +void Notifications::NotificationItem::Refresh(lv_task_t* tsk) { + static_cast(tsk->user_data)->StartTitleScroll(); + lv_task_del(tsk); // This substitutes the call to lv_task_once + // This method can be updated in the future for implementing other features. + // For now it is executed one single time after 1 second and then deleted. } void Notifications::NotificationItem::OnCallButtonEvent(lv_obj_t* obj, lv_event_t event) { @@ -363,6 +367,7 @@ void Notifications::NotificationItem::OnCallButtonEvent(lv_obj_t* obj, lv_event_ Notifications::NotificationItem::~NotificationItem() { lv_obj_clean(lv_scr_act()); + lv_task_del(refreshTask); } void Notifications::NotificationItem::StartTitleScroll(){ diff --git a/src/displayapp/screens/Notifications.h b/src/displayapp/screens/Notifications.h index 0bc96b5e..19561db2 100644 --- a/src/displayapp/screens/Notifications.h +++ b/src/displayapp/screens/Notifications.h @@ -47,7 +47,7 @@ namespace Pinetime { return running; } void OnCallButtonEvent(lv_obj_t*, lv_event_t event); - void StartTitleScroll(); + static void Refresh(lv_task_t* tsk); private: lv_obj_t* container; @@ -58,8 +58,11 @@ namespace Pinetime { lv_obj_t* label_accept; lv_obj_t* label_mute; lv_obj_t* label_reject; - lv_obj_t *alert_type; - + lv_obj_t* alert_type; + + void StartTitleScroll(); + lv_task_t* refreshTask; + Pinetime::Controllers::AlertNotificationService& alertNotificationService; Pinetime::Controllers::MotorController& motorController; @@ -82,9 +85,7 @@ namespace Pinetime { TickType_t timeoutTickCountStart; static const TickType_t timeoutLength = pdMS_TO_TICKS(7000); - static const TickType_t timeoutStartTitleScrolling = pdMS_TO_TICKS(1000); bool interacted = true; - bool isTitleScrolling = false; bool dismissingNotification = false;