|
|
@ -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,10 +42,13 @@ 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);
|
|
|
|
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_width(timeoutLine, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, 3);
|
|
|
@ -49,8 +57,7 @@ Notifications::Notifications(DisplayApp* app,
|
|
|
|
|
|
|
|
|
|
|
|
lv_line_set_points(timeoutLine, timeoutLinePoints, 2);
|
|
|
|
lv_line_set_points(timeoutLine, timeoutLinePoints, 2);
|
|
|
|
timeoutTickCountStart = xTaskGetTickCount();
|
|
|
|
timeoutTickCountStart = xTaskGetTickCount();
|
|
|
|
timeoutTickCountEnd = timeoutTickCountStart + (5 * 1024);
|
|
|
|
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;
|
|
|
|
timeoutLinePoints[1].x = pos;
|
|
|
|
lv_line_set_points(timeoutLine, timeoutLinePoints, 2);
|
|
|
|
lv_line_set_points(timeoutLine, timeoutLinePoints, 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
running = currentItem->IsRunning() && running;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Notifications::OnPreviewInteraction() {
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|