Clean unused DisplayApp messages

This commit is contained in:
mark9064 2024-08-22 16:49:18 +01:00 committed by JF
parent fd019c7aad
commit 5040733a97
3 changed files with 7 additions and 34 deletions

View file

@ -209,21 +209,6 @@ void DisplayApp::Refresh() {
LoadScreen(returnAppStack.Pop(), returnDirection); 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 { auto IsPastDimTime = [this]() -> bool {
return lv_disp_get_inactive_time(nullptr) >= pdMS_TO_TICKS(settingsController.GetScreenTimeOut() - 2000); 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 (!systemTask->IsSleepDisabled() && IsPastDimTime()) {
if (!isDimmed) { if (!isDimmed) {
DimScreen(); isDimmed = true;
brightnessController.Set(Controllers::BrightnessController::Levels::Low);
} }
if (IsPastSleepTime()) { if (IsPastSleepTime()) {
systemTask->PushMessage(System::Messages::GoToSleep); systemTask->PushMessage(System::Messages::GoToSleep);
state = States::Idle; state = States::Idle;
} }
} else if (isDimmed) { } else if (isDimmed) {
RestoreBrightness(); isDimmed = false;
ApplyBrightness();
} }
break; break;
default: default:
@ -285,9 +272,6 @@ void DisplayApp::Refresh() {
Messages msg; Messages msg;
if (xQueueReceive(msgQueue, &msg, queueTimeout) == pdTRUE) { if (xQueueReceive(msgQueue, &msg, queueTimeout) == pdTRUE) {
switch (msg) { switch (msg) {
case Messages::DimScreen:
DimScreen();
break;
case Messages::GoToSleep: case Messages::GoToSleep:
while (brightnessController.Level() != Controllers::BrightnessController::Levels::Low) { while (brightnessController.Level() != Controllers::BrightnessController::Levels::Low) {
brightnessController.Lower(); brightnessController.Lower();
@ -333,8 +317,7 @@ void DisplayApp::Refresh() {
state = States::Running; state = States::Running;
break; break;
case Messages::UpdateBleConnection: case Messages::UpdateBleConnection:
// clockScreen.SetBleConnectionState(bleController.IsConnected() ? Screens::Clock::BleConnectionStates::Connected : // Only used for recovery firmware
// Screens::Clock::BleConnectionStates::NotConnected);
break; break;
case Messages::NewNotification: case Messages::NewNotification:
LoadNewScreen(Apps::NotificationsPreview, DisplayApp::FullRefreshDirections::Down); LoadNewScreen(Apps::NotificationsPreview, DisplayApp::FullRefreshDirections::Down);
@ -449,16 +432,11 @@ void DisplayApp::Refresh() {
case Messages::BleRadioEnableToggle: case Messages::BleRadioEnableToggle:
PushMessageToSystemTask(System::Messages::BleRadioEnableToggle); PushMessageToSystemTask(System::Messages::BleRadioEnableToggle);
break; break;
case Messages::UpdateDateTime:
// Added to remove warning
// What should happen here?
break;
case Messages::Chime: case Messages::Chime:
LoadNewScreen(Apps::Clock, DisplayApp::FullRefreshDirections::None); LoadNewScreen(Apps::Clock, DisplayApp::FullRefreshDirections::None);
motorController.RunForDuration(35); motorController.RunForDuration(35);
break; break;
case Messages::OnChargingEvent: case Messages::OnChargingEvent:
RestoreBrightness();
motorController.RunForDuration(15); motorController.RunForDuration(15);
break; break;
} }

View file

@ -7,7 +7,6 @@ namespace Pinetime {
enum class Messages : uint8_t { enum class Messages : uint8_t {
GoToSleep, GoToSleep,
GoToRunning, GoToRunning,
UpdateDateTime,
UpdateBleConnection, UpdateBleConnection,
TouchEvent, TouchEvent,
ButtonPushed, ButtonPushed,
@ -17,7 +16,8 @@ namespace Pinetime {
NewNotification, NewNotification,
TimerDone, TimerDone,
BleFirmwareUpdateStarted, BleFirmwareUpdateStarted,
DimScreen, // Resets the screen timeout timer when awake
// Does nothing when asleep
NotifyDeviceActivity, NotifyDeviceActivity,
ShowPairingKey, ShowPairingKey,
AlarmTriggered, AlarmTriggered,

View file

@ -194,7 +194,6 @@ void SystemTask::Work() {
if (!bleController.IsFirmwareUpdating()) { if (!bleController.IsFirmwareUpdating()) {
doNotGoToSleep = false; doNotGoToSleep = false;
} }
displayApp.PushMessage(Pinetime::Applications::Display::Messages::NotifyDeviceActivity);
break; break;
case Messages::DisableSleeping: case Messages::DisableSleeping:
doNotGoToSleep = true; doNotGoToSleep = true;
@ -245,8 +244,6 @@ void SystemTask::Work() {
heartRateApp.PushMessage(Pinetime::Applications::HeartRateTask::Messages::GoToSleep); heartRateApp.PushMessage(Pinetime::Applications::HeartRateTask::Messages::GoToSleep);
break; break;
case Messages::OnNewTime: case Messages::OnNewTime:
displayApp.PushMessage(Pinetime::Applications::Display::Messages::NotifyDeviceActivity);
displayApp.PushMessage(Pinetime::Applications::Display::Messages::UpdateDateTime);
if (alarmController.State() == Controllers::AlarmController::AlarmState::Set) { if (alarmController.State() == Controllers::AlarmController::AlarmState::Set) {
alarmController.ScheduleAlarm(); alarmController.ScheduleAlarm();
} }
@ -255,8 +252,6 @@ void SystemTask::Work() {
if (settingsController.GetNotificationStatus() == Pinetime::Controllers::Settings::Notification::On) { if (settingsController.GetNotificationStatus() == Pinetime::Controllers::Settings::Notification::On) {
if (state == SystemTaskState::Sleeping) { if (state == SystemTaskState::Sleeping) {
GoToRunning(); GoToRunning();
} else {
displayApp.PushMessage(Pinetime::Applications::Display::Messages::NotifyDeviceActivity);
} }
displayApp.PushMessage(Pinetime::Applications::Display::Messages::NewNotification); displayApp.PushMessage(Pinetime::Applications::Display::Messages::NewNotification);
} }