♻️ Refactor status screen timeout

This commit is contained in:
Scott Lahteine
2021-06-27 00:33:44 -05:00
parent e3ae76d76d
commit 2b37a71eba
9 changed files with 56 additions and 54 deletions

View File

@ -45,7 +45,7 @@ bool BaseScreen::buttonStyleCallback(CommandProcessor &cmd, uint8_t tag, uint8_t
return false;
}
#if LCD_TIMEOUT_TO_STATUS > 0
#if SCREENS_CAN_TIME_OUT
if (EventLoop::get_pressed_tag() != 0) {
reset_menu_timeout();
}
@ -65,7 +65,7 @@ bool BaseScreen::buttonStyleCallback(CommandProcessor &cmd, uint8_t tag, uint8_t
}
void BaseScreen::onIdle() {
#if LCD_TIMEOUT_TO_STATUS > 0
#if SCREENS_CAN_TIME_OUT
if ((millis() - last_interaction) > LCD_TIMEOUT_TO_STATUS) {
reset_menu_timeout();
#if ENABLED(TOUCH_UI_DEBUG)
@ -77,12 +77,10 @@ void BaseScreen::onIdle() {
}
void BaseScreen::reset_menu_timeout() {
#if LCD_TIMEOUT_TO_STATUS > 0
last_interaction = millis();
#endif
TERN_(SCREENS_CAN_TIME_OUT, last_interaction = millis());
}
#if LCD_TIMEOUT_TO_STATUS > 0
#if SCREENS_CAN_TIME_OUT
uint32_t BaseScreen::last_interaction;
#endif

View File

@ -27,7 +27,7 @@
class BaseScreen : public UIScreen {
protected:
#if LCD_TIMEOUT_TO_STATUS > 0
#if SCREENS_CAN_TIME_OUT
static uint32_t last_interaction;
#endif