Improved notification timeout
This commit is contained in:
parent
e0013e7304
commit
5e6868d9eb
|
@ -362,12 +362,12 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
|
||||||
|
|
||||||
case Apps::Notifications:
|
case Apps::Notifications:
|
||||||
currentScreen = std::make_unique<Screens::Notifications>(
|
currentScreen = std::make_unique<Screens::Notifications>(
|
||||||
this, notificationManager, systemTask->nimble().alertService(), motorController, Screens::Notifications::Modes::Normal);
|
this, notificationManager, systemTask->nimble().alertService(), motorController, *systemTask, Screens::Notifications::Modes::Normal);
|
||||||
ReturnApp(Apps::Clock, FullRefreshDirections::Up, TouchEvents::SwipeUp);
|
ReturnApp(Apps::Clock, FullRefreshDirections::Up, TouchEvents::SwipeUp);
|
||||||
break;
|
break;
|
||||||
case Apps::NotificationsPreview:
|
case Apps::NotificationsPreview:
|
||||||
currentScreen = std::make_unique<Screens::Notifications>(
|
currentScreen = std::make_unique<Screens::Notifications>(
|
||||||
this, notificationManager, systemTask->nimble().alertService(), motorController, Screens::Notifications::Modes::Preview);
|
this, notificationManager, systemTask->nimble().alertService(), motorController, *systemTask, Screens::Notifications::Modes::Preview);
|
||||||
ReturnApp(Apps::Clock, FullRefreshDirections::Up, TouchEvents::SwipeUp);
|
ReturnApp(Apps::Clock, FullRefreshDirections::Up, TouchEvents::SwipeUp);
|
||||||
break;
|
break;
|
||||||
case Apps::Timer:
|
case Apps::Timer:
|
||||||
|
|
|
@ -12,8 +12,13 @@ Notifications::Notifications(DisplayApp* app,
|
||||||
Pinetime::Controllers::NotificationManager& notificationManager,
|
Pinetime::Controllers::NotificationManager& notificationManager,
|
||||||
Pinetime::Controllers::AlertNotificationService& alertNotificationService,
|
Pinetime::Controllers::AlertNotificationService& alertNotificationService,
|
||||||
Pinetime::Controllers::MotorController& motorController,
|
Pinetime::Controllers::MotorController& motorController,
|
||||||
|
System::SystemTask& systemTask,
|
||||||
Modes mode)
|
Modes mode)
|
||||||
: Screen(app), notificationManager {notificationManager}, alertNotificationService {alertNotificationService}, mode {mode} {
|
: Screen(app),
|
||||||
|
notificationManager {notificationManager},
|
||||||
|
alertNotificationService {alertNotificationService},
|
||||||
|
systemTask {systemTask},
|
||||||
|
mode {mode} {
|
||||||
notificationManager.ClearNewNotificationFlag();
|
notificationManager.ClearNewNotificationFlag();
|
||||||
auto notification = notificationManager.GetLastNotification();
|
auto notification = notificationManager.GetLastNotification();
|
||||||
if (notification.valid) {
|
if (notification.valid) {
|
||||||
|
@ -37,20 +42,22 @@ Notifications::Notifications(DisplayApp* app,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode == Modes::Preview) {
|
if (mode == Modes::Preview) {
|
||||||
|
systemTask.PushMessage(System::Messages::DisableSleeping);
|
||||||
if (notification.category == Controllers::NotificationManager::Categories::IncomingCall) {
|
if (notification.category == Controllers::NotificationManager::Categories::IncomingCall) {
|
||||||
motorController.StartRinging();
|
motorController.StartRinging();
|
||||||
} else {
|
} else {
|
||||||
motorController.RunForDuration(35);
|
motorController.RunForDuration(35);
|
||||||
timeoutLine = lv_line_create(lv_scr_act(), nullptr);
|
|
||||||
|
|
||||||
lv_obj_set_style_local_line_width(timeoutLine, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, 3);
|
|
||||||
lv_obj_set_style_local_line_color(timeoutLine, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
|
|
||||||
lv_obj_set_style_local_line_rounded(timeoutLine, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, true);
|
|
||||||
|
|
||||||
lv_line_set_points(timeoutLine, timeoutLinePoints, 2);
|
|
||||||
timeoutTickCountStart = xTaskGetTickCount();
|
|
||||||
timeoutTickCountEnd = timeoutTickCountStart + (5 * 1024);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
timeoutLine = lv_line_create(lv_scr_act(), nullptr);
|
||||||
|
|
||||||
|
lv_obj_set_style_local_line_width(timeoutLine, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, 3);
|
||||||
|
lv_obj_set_style_local_line_color(timeoutLine, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
|
||||||
|
lv_obj_set_style_local_line_rounded(timeoutLine, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, true);
|
||||||
|
|
||||||
|
lv_line_set_points(timeoutLine, timeoutLinePoints, 2);
|
||||||
|
timeoutTickCountStart = xTaskGetTickCount();
|
||||||
|
interacted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
|
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
|
||||||
|
@ -60,23 +67,40 @@ Notifications::~Notifications() {
|
||||||
lv_task_del(taskRefresh);
|
lv_task_del(taskRefresh);
|
||||||
// make sure we stop any vibrations before exiting
|
// make sure we stop any vibrations before exiting
|
||||||
Controllers::MotorController::StopRinging();
|
Controllers::MotorController::StopRinging();
|
||||||
|
systemTask.PushMessage(System::Messages::EnableSleeping);
|
||||||
lv_obj_clean(lv_scr_act());
|
lv_obj_clean(lv_scr_act());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Notifications::Refresh() {
|
void Notifications::Refresh() {
|
||||||
if (mode == Modes::Preview && timeoutLine != nullptr) {
|
if (mode == Modes::Preview && timeoutLine != nullptr) {
|
||||||
auto tick = xTaskGetTickCount();
|
TickType_t tick = xTaskGetTickCount();
|
||||||
int32_t pos = 240 - ((tick - timeoutTickCountStart) / ((timeoutTickCountEnd - timeoutTickCountStart) / 240));
|
int32_t pos = 240 - ((tick - timeoutTickCountStart) / (timeoutLength / 240));
|
||||||
if (pos < 0)
|
if (pos <= 0) {
|
||||||
running = false;
|
running = false;
|
||||||
|
} else {
|
||||||
|
timeoutLinePoints[1].x = pos;
|
||||||
|
lv_line_set_points(timeoutLine, timeoutLinePoints, 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
running = currentItem->IsRunning() && running;
|
||||||
|
}
|
||||||
|
|
||||||
timeoutLinePoints[1].x = pos;
|
void Notifications::OnPreviewInteraction() {
|
||||||
lv_line_set_points(timeoutLine, timeoutLinePoints, 2);
|
systemTask.PushMessage(System::Messages::EnableSleeping);
|
||||||
|
Controllers::MotorController::StopRinging();
|
||||||
|
if (timeoutLine != nullptr) {
|
||||||
|
lv_obj_del(timeoutLine);
|
||||||
|
timeoutLine = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <lvgl/lvgl.h>
|
#include <lvgl/lvgl.h>
|
||||||
|
#include <FreeRTOS.h>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include "displayapp/screens/Screen.h"
|
#include "displayapp/screens/Screen.h"
|
||||||
#include "components/ble/NotificationManager.h"
|
#include "components/ble/NotificationManager.h"
|
||||||
#include "components/motor/MotorController.h"
|
#include "components/motor/MotorController.h"
|
||||||
|
#include "systemtask/SystemTask.h"
|
||||||
|
|
||||||
namespace Pinetime {
|
namespace Pinetime {
|
||||||
namespace Controllers {
|
namespace Controllers {
|
||||||
|
@ -21,11 +23,13 @@ namespace Pinetime {
|
||||||
Pinetime::Controllers::NotificationManager& notificationManager,
|
Pinetime::Controllers::NotificationManager& notificationManager,
|
||||||
Pinetime::Controllers::AlertNotificationService& alertNotificationService,
|
Pinetime::Controllers::AlertNotificationService& alertNotificationService,
|
||||||
Pinetime::Controllers::MotorController& motorController,
|
Pinetime::Controllers::MotorController& motorController,
|
||||||
|
System::SystemTask& systemTask,
|
||||||
Modes mode);
|
Modes mode);
|
||||||
~Notifications() override;
|
~Notifications() override;
|
||||||
|
|
||||||
void Refresh() override;
|
void Refresh() override;
|
||||||
bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override;
|
bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override;
|
||||||
|
void OnPreviewInteraction();
|
||||||
|
|
||||||
class NotificationItem {
|
class NotificationItem {
|
||||||
public:
|
public:
|
||||||
|
@ -62,6 +66,7 @@ namespace Pinetime {
|
||||||
};
|
};
|
||||||
Pinetime::Controllers::NotificationManager& notificationManager;
|
Pinetime::Controllers::NotificationManager& notificationManager;
|
||||||
Pinetime::Controllers::AlertNotificationService& alertNotificationService;
|
Pinetime::Controllers::AlertNotificationService& alertNotificationService;
|
||||||
|
System::SystemTask& systemTask;
|
||||||
Modes mode = Modes::Normal;
|
Modes mode = Modes::Normal;
|
||||||
std::unique_ptr<NotificationItem> currentItem;
|
std::unique_ptr<NotificationItem> currentItem;
|
||||||
Controllers::NotificationManager::Notification::Id currentId;
|
Controllers::NotificationManager::Notification::Id currentId;
|
||||||
|
@ -69,8 +74,9 @@ namespace Pinetime {
|
||||||
|
|
||||||
lv_point_t timeoutLinePoints[2] {{0, 1}, {239, 1}};
|
lv_point_t timeoutLinePoints[2] {{0, 1}, {239, 1}};
|
||||||
lv_obj_t* timeoutLine = nullptr;
|
lv_obj_t* timeoutLine = nullptr;
|
||||||
uint32_t timeoutTickCountStart;
|
TickType_t timeoutTickCountStart;
|
||||||
uint32_t timeoutTickCountEnd;
|
static const TickType_t timeoutLength = pdMS_TO_TICKS(7000);
|
||||||
|
bool interacted = true;
|
||||||
|
|
||||||
lv_task_t* taskRefresh;
|
lv_task_t* taskRefresh;
|
||||||
};
|
};
|
||||||
|
|
|
@ -239,6 +239,7 @@ void SystemTask::Work() {
|
||||||
if (!bleController.IsFirmwareUpdating()) {
|
if (!bleController.IsFirmwareUpdating()) {
|
||||||
doNotGoToSleep = false;
|
doNotGoToSleep = false;
|
||||||
}
|
}
|
||||||
|
ReloadIdleTimer();
|
||||||
break;
|
break;
|
||||||
case Messages::DisableSleeping:
|
case Messages::DisableSleeping:
|
||||||
doNotGoToSleep = true;
|
doNotGoToSleep = true;
|
||||||
|
|
Loading…
Reference in a new issue