Skip to content

Commit

Permalink
use the conditional
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Oct 20, 2022
1 parent d01d1f8 commit fb927f4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Marlin/src/inc/Conditionals_post.h
Original file line number Diff line number Diff line change
Expand Up @@ -3605,7 +3605,7 @@
#endif
#endif

#if HAS_MARLINUI_MENU
#if EITHER(HAS_MARLINUI_MENU, TOUCH_UI_FTDI_EVE)
// LCD timeout to status screen default is 15s
#ifndef LCD_TIMEOUT_TO_STATUS
#define LCD_TIMEOUT_TO_STATUS 15000
Expand Down
22 changes: 10 additions & 12 deletions Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/base_screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,16 @@ 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) {
SERIAL_ECHO_MSG("buttonStyleCallback, resetting timeout");
#if ENABLED(TOUCH_UI_DEBUG)
SERIAL_ECHO_MSG("buttonStyleCallback, resetting timeout");
#endif
reset_menu_timeout();
}
#endif

if (buttonIsPressed(tag)) {
options = OPT_FLAT;
}
if (buttonIsPressed(tag)) options = OPT_FLAT;

if (style & cmd.STYLE_DISABLED) {
cmd.tag(0);
Expand All @@ -66,10 +66,10 @@ bool BaseScreen::buttonStyleCallback(CommandProcessor &cmd, uint8_t tag, uint8_t
}

void BaseScreen::onIdle() {
#if LCD_TIMEOUT_TO_STATUS > 0
if (EventLoop::get_pressed_tag() != 0) {
#if SCREENS_CAN_TIME_OUT
if (EventLoop::get_pressed_tag() != 0)
reset_menu_timeout();
}

if ((millis() - last_interaction) > LCD_TIMEOUT_TO_STATUS) {
reset_menu_timeout();
#if ENABLED(TOUCH_UI_DEBUG)
Expand All @@ -81,12 +81,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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit fb927f4

Please sign in to comment.