Skip to content

Commit 5040733

Browse files
mark9064JF002
authored andcommitted
Clean unused DisplayApp messages
1 parent fd019c7 commit 5040733

File tree

3 files changed

+7
-34
lines changed

3 files changed

+7
-34
lines changed

src/displayapp/DisplayApp.cpp

+5-27
Original file line numberDiff line numberDiff line change
@@ -209,21 +209,6 @@ void DisplayApp::Refresh() {
209209
LoadScreen(returnAppStack.Pop(), returnDirection);
210210
};
211211

212-
auto DimScreen = [this]() {
213-
if (brightnessController.Level() != Controllers::BrightnessController::Levels::Off) {
214-
isDimmed = true;
215-
brightnessController.Set(Controllers::BrightnessController::Levels::Low);
216-
}
217-
};
218-
219-
auto RestoreBrightness = [this]() {
220-
if (brightnessController.Level() != Controllers::BrightnessController::Levels::Off) {
221-
isDimmed = false;
222-
lv_disp_trig_activity(nullptr);
223-
ApplyBrightness();
224-
}
225-
};
226-
227212
auto IsPastDimTime = [this]() -> bool {
228213
return lv_disp_get_inactive_time(nullptr) >= pdMS_TO_TICKS(settingsController.GetScreenTimeOut() - 2000);
229214
};
@@ -267,14 +252,16 @@ void DisplayApp::Refresh() {
267252

268253
if (!systemTask->IsSleepDisabled() && IsPastDimTime()) {
269254
if (!isDimmed) {
270-
DimScreen();
255+
isDimmed = true;
256+
brightnessController.Set(Controllers::BrightnessController::Levels::Low);
271257
}
272258
if (IsPastSleepTime()) {
273259
systemTask->PushMessage(System::Messages::GoToSleep);
274260
state = States::Idle;
275261
}
276262
} else if (isDimmed) {
277-
RestoreBrightness();
263+
isDimmed = false;
264+
ApplyBrightness();
278265
}
279266
break;
280267
default:
@@ -285,9 +272,6 @@ void DisplayApp::Refresh() {
285272
Messages msg;
286273
if (xQueueReceive(msgQueue, &msg, queueTimeout) == pdTRUE) {
287274
switch (msg) {
288-
case Messages::DimScreen:
289-
DimScreen();
290-
break;
291275
case Messages::GoToSleep:
292276
while (brightnessController.Level() != Controllers::BrightnessController::Levels::Low) {
293277
brightnessController.Lower();
@@ -333,8 +317,7 @@ void DisplayApp::Refresh() {
333317
state = States::Running;
334318
break;
335319
case Messages::UpdateBleConnection:
336-
// clockScreen.SetBleConnectionState(bleController.IsConnected() ? Screens::Clock::BleConnectionStates::Connected :
337-
// Screens::Clock::BleConnectionStates::NotConnected);
320+
// Only used for recovery firmware
338321
break;
339322
case Messages::NewNotification:
340323
LoadNewScreen(Apps::NotificationsPreview, DisplayApp::FullRefreshDirections::Down);
@@ -449,16 +432,11 @@ void DisplayApp::Refresh() {
449432
case Messages::BleRadioEnableToggle:
450433
PushMessageToSystemTask(System::Messages::BleRadioEnableToggle);
451434
break;
452-
case Messages::UpdateDateTime:
453-
// Added to remove warning
454-
// What should happen here?
455-
break;
456435
case Messages::Chime:
457436
LoadNewScreen(Apps::Clock, DisplayApp::FullRefreshDirections::None);
458437
motorController.RunForDuration(35);
459438
break;
460439
case Messages::OnChargingEvent:
461-
RestoreBrightness();
462440
motorController.RunForDuration(15);
463441
break;
464442
}

src/displayapp/Messages.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ namespace Pinetime {
77
enum class Messages : uint8_t {
88
GoToSleep,
99
GoToRunning,
10-
UpdateDateTime,
1110
UpdateBleConnection,
1211
TouchEvent,
1312
ButtonPushed,
@@ -17,7 +16,8 @@ namespace Pinetime {
1716
NewNotification,
1817
TimerDone,
1918
BleFirmwareUpdateStarted,
20-
DimScreen,
19+
// Resets the screen timeout timer when awake
20+
// Does nothing when asleep
2121
NotifyDeviceActivity,
2222
ShowPairingKey,
2323
AlarmTriggered,

src/systemtask/SystemTask.cpp

-5
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ void SystemTask::Work() {
194194
if (!bleController.IsFirmwareUpdating()) {
195195
doNotGoToSleep = false;
196196
}
197-
displayApp.PushMessage(Pinetime::Applications::Display::Messages::NotifyDeviceActivity);
198197
break;
199198
case Messages::DisableSleeping:
200199
doNotGoToSleep = true;
@@ -245,8 +244,6 @@ void SystemTask::Work() {
245244
heartRateApp.PushMessage(Pinetime::Applications::HeartRateTask::Messages::GoToSleep);
246245
break;
247246
case Messages::OnNewTime:
248-
displayApp.PushMessage(Pinetime::Applications::Display::Messages::NotifyDeviceActivity);
249-
displayApp.PushMessage(Pinetime::Applications::Display::Messages::UpdateDateTime);
250247
if (alarmController.State() == Controllers::AlarmController::AlarmState::Set) {
251248
alarmController.ScheduleAlarm();
252249
}
@@ -255,8 +252,6 @@ void SystemTask::Work() {
255252
if (settingsController.GetNotificationStatus() == Pinetime::Controllers::Settings::Notification::On) {
256253
if (state == SystemTaskState::Sleeping) {
257254
GoToRunning();
258-
} else {
259-
displayApp.PushMessage(Pinetime::Applications::Display::Messages::NotifyDeviceActivity);
260255
}
261256
displayApp.PushMessage(Pinetime::Applications::Display::Messages::NewNotification);
262257
}

0 commit comments

Comments
 (0)