Skip to content

Commit f5c78fa

Browse files
committed
feat(UI): wake screensaver on various events
1 parent 656cc89 commit f5c78fa

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

src/UI/Components/LVGL/LvObj.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -972,6 +972,7 @@ namespace UI
972972

973973
setFlag(LV_OBJ_FLAG_HIDDEN, false);
974974
showInner();
975+
lv_display_trigger_activity(NULL); // Reset screensaver timer
975976
}
976977

977978
void LvObj::showInner()

src/main.cpp

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,9 +274,24 @@ int main(int argc, char** argv)
274274
first_run = false;
275275
}
276276
#endif
277-
uint32_t inactive_time = lv_display_get_inactive_time(NULL);
278-
uint32_t timeout = StorageHelper::getData(ID_SCREENSAVER_TIMEOUT).count() * 1000;
279-
if (timeout > 0 && inactive_time > timeout)
277+
std::chrono::milliseconds inactive_time(lv_display_get_inactive_time(NULL));
278+
const auto timeout = StorageHelper::getData(ID_SCREENSAVER_TIMEOUT);
279+
const OM::PrinterStatus printerStatus = OM::GetStatus();
280+
281+
/**
282+
* Screen saver will not activate while the printer is `busy` since this is likely when the user will be
283+
* interacting with the screen or DWC.
284+
*
285+
* The status will also be `busy` when a `M291` modal is open.
286+
*
287+
* It is currently intentional that the screen saver can activate while the status is one of the printing
288+
* states since the printer may be in a location where having the screen on full brightness is undesirable,
289+
* and the user can easily disable the screen saver in settings if this isn't desired behaviour. This may be
290+
* revisited in the future if it is found that users want the screen saver to be disabled during printing as
291+
* well.
292+
*/
293+
if (timeout > std::chrono::seconds(0) && inactive_time > timeout &&
294+
(printerStatus != OM::PrinterStatus::busy))
280295
{
281296
if (!screensaver_enabled)
282297
{
@@ -447,6 +462,15 @@ static lv_display_t* hal_init(int32_t w, int32_t h)
447462
},
448463
LV_EVENT_DELETE,
449464
nullptr);
465+
lv_obj_add_event_cb(
466+
cursor_obj,
467+
[](lv_event_t* e)
468+
{
469+
ZoneScopedN("Mouse Activity Callback");
470+
lv_display_trigger_activity(NULL); // Reset screensaver timer on mouse activity
471+
},
472+
LV_EVENT_STYLE_CHANGED, /* XY pos counts as a style change */
473+
nullptr);
450474
}
451475
lv_indev_set_display(indev, disp);
452476
lv_indev_set_group(indev, lv_group_get_default());

0 commit comments

Comments
 (0)