From 5040733a97560f8f0ef73f7df7982c5acaf15b47 Mon Sep 17 00:00:00 2001 From: mark9064 <30447455+mark9064@users.noreply.github.com> Date: Thu, 22 Aug 2024 16:49:18 +0100 Subject: [PATCH] Clean unused DisplayApp messages --- src/displayapp/DisplayApp.cpp | 32 +++++--------------------------- src/displayapp/Messages.h | 4 ++-- src/systemtask/SystemTask.cpp | 5 ----- 3 files changed, 7 insertions(+), 34 deletions(-) diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index 3be7656d..79519621 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -209,21 +209,6 @@ void DisplayApp::Refresh() { LoadScreen(returnAppStack.Pop(), returnDirection); }; - auto DimScreen = [this]() { - if (brightnessController.Level() != Controllers::BrightnessController::Levels::Off) { - isDimmed = true; - brightnessController.Set(Controllers::BrightnessController::Levels::Low); - } - }; - - auto RestoreBrightness = [this]() { - if (brightnessController.Level() != Controllers::BrightnessController::Levels::Off) { - isDimmed = false; - lv_disp_trig_activity(nullptr); - ApplyBrightness(); - } - }; - auto IsPastDimTime = [this]() -> bool { return lv_disp_get_inactive_time(nullptr) >= pdMS_TO_TICKS(settingsController.GetScreenTimeOut() - 2000); }; @@ -267,14 +252,16 @@ void DisplayApp::Refresh() { if (!systemTask->IsSleepDisabled() && IsPastDimTime()) { if (!isDimmed) { - DimScreen(); + isDimmed = true; + brightnessController.Set(Controllers::BrightnessController::Levels::Low); } if (IsPastSleepTime()) { systemTask->PushMessage(System::Messages::GoToSleep); state = States::Idle; } } else if (isDimmed) { - RestoreBrightness(); + isDimmed = false; + ApplyBrightness(); } break; default: @@ -285,9 +272,6 @@ void DisplayApp::Refresh() { Messages msg; if (xQueueReceive(msgQueue, &msg, queueTimeout) == pdTRUE) { switch (msg) { - case Messages::DimScreen: - DimScreen(); - break; case Messages::GoToSleep: while (brightnessController.Level() != Controllers::BrightnessController::Levels::Low) { brightnessController.Lower(); @@ -333,8 +317,7 @@ void DisplayApp::Refresh() { state = States::Running; break; case Messages::UpdateBleConnection: - // clockScreen.SetBleConnectionState(bleController.IsConnected() ? Screens::Clock::BleConnectionStates::Connected : - // Screens::Clock::BleConnectionStates::NotConnected); + // Only used for recovery firmware break; case Messages::NewNotification: LoadNewScreen(Apps::NotificationsPreview, DisplayApp::FullRefreshDirections::Down); @@ -449,16 +432,11 @@ void DisplayApp::Refresh() { case Messages::BleRadioEnableToggle: PushMessageToSystemTask(System::Messages::BleRadioEnableToggle); break; - case Messages::UpdateDateTime: - // Added to remove warning - // What should happen here? - break; case Messages::Chime: LoadNewScreen(Apps::Clock, DisplayApp::FullRefreshDirections::None); motorController.RunForDuration(35); break; case Messages::OnChargingEvent: - RestoreBrightness(); motorController.RunForDuration(15); break; } diff --git a/src/displayapp/Messages.h b/src/displayapp/Messages.h index 1418f6be..dcfff4c2 100644 --- a/src/displayapp/Messages.h +++ b/src/displayapp/Messages.h @@ -7,7 +7,6 @@ namespace Pinetime { enum class Messages : uint8_t { GoToSleep, GoToRunning, - UpdateDateTime, UpdateBleConnection, TouchEvent, ButtonPushed, @@ -17,7 +16,8 @@ namespace Pinetime { NewNotification, TimerDone, BleFirmwareUpdateStarted, - DimScreen, + // Resets the screen timeout timer when awake + // Does nothing when asleep NotifyDeviceActivity, ShowPairingKey, AlarmTriggered, diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index 211e19ec..848fb54c 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -194,7 +194,6 @@ void SystemTask::Work() { if (!bleController.IsFirmwareUpdating()) { doNotGoToSleep = false; } - displayApp.PushMessage(Pinetime::Applications::Display::Messages::NotifyDeviceActivity); break; case Messages::DisableSleeping: doNotGoToSleep = true; @@ -245,8 +244,6 @@ void SystemTask::Work() { heartRateApp.PushMessage(Pinetime::Applications::HeartRateTask::Messages::GoToSleep); break; case Messages::OnNewTime: - displayApp.PushMessage(Pinetime::Applications::Display::Messages::NotifyDeviceActivity); - displayApp.PushMessage(Pinetime::Applications::Display::Messages::UpdateDateTime); if (alarmController.State() == Controllers::AlarmController::AlarmState::Set) { alarmController.ScheduleAlarm(); } @@ -255,8 +252,6 @@ void SystemTask::Work() { if (settingsController.GetNotificationStatus() == Pinetime::Controllers::Settings::Notification::On) { if (state == SystemTaskState::Sleeping) { GoToRunning(); - } else { - displayApp.PushMessage(Pinetime::Applications::Display::Messages::NotifyDeviceActivity); } displayApp.PushMessage(Pinetime::Applications::Display::Messages::NewNotification); }