Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix FTDUI Status Screen Timeout #24899

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Marlin/src/inc/Conditionals_post.h
Original file line number Diff line number Diff line change
Expand Up @@ -3605,13 +3605,13 @@
#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
#endif
#if LCD_TIMEOUT_TO_STATUS
#define SCREENS_CAN_TIME_OUT 1
#define HAS_SCREEN_TIMEOUT 1
#endif
#endif

Expand Down
18 changes: 11 additions & 7 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,15 +45,16 @@ bool BaseScreen::buttonStyleCallback(CommandProcessor &cmd, uint8_t tag, uint8_t
return false;
}

#if SCREENS_CAN_TIME_OUT
#if HAS_SCREEN_TIMEOUT
if (EventLoop::get_pressed_tag() != 0) {
#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 @@ -65,7 +66,10 @@ bool BaseScreen::buttonStyleCallback(CommandProcessor &cmd, uint8_t tag, uint8_t
}

void BaseScreen::onIdle() {
#if SCREENS_CAN_TIME_OUT
#if HAS_SCREEN_TIMEOUT
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 @@ -77,10 +81,10 @@ void BaseScreen::onIdle() {
}

void BaseScreen::reset_menu_timeout() {
TERN_(SCREENS_CAN_TIME_OUT, last_interaction = millis());
TERN_(HAS_SCREEN_TIMEOUT, last_interaction = millis());
}

#if SCREENS_CAN_TIME_OUT
#if HAS_SCREEN_TIMEOUT
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 SCREENS_CAN_TIME_OUT
#if HAS_SCREEN_TIMEOUT
static uint32_t last_interaction;
#endif

Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/lcd/marlinui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ void MarlinUI::init() {
#endif
#endif

#if SCREENS_CAN_TIME_OUT
#if HAS_SCREEN_TIMEOUT
bool MarlinUI::defer_return_to_status;
millis_t MarlinUI::return_to_status_ms = 0;
#endif
Expand Down Expand Up @@ -1171,7 +1171,7 @@ void MarlinUI::init() {
NOLESS(max_display_update_time, millis() - ms);
}

#if SCREENS_CAN_TIME_OUT
#if HAS_SCREEN_TIMEOUT
// Return to Status Screen after a timeout
if (on_status_screen() || defer_return_to_status)
reset_status_timeout(ms);
Expand Down
8 changes: 4 additions & 4 deletions Marlin/src/lcd/marlinui.h
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ class MarlinUI {
#endif

static void reset_status_timeout(const millis_t ms) {
TERN(SCREENS_CAN_TIME_OUT, return_to_status_ms = ms + LCD_TIMEOUT_TO_STATUS, UNUSED(ms));
TERN(HAS_SCREEN_TIMEOUT, return_to_status_ms = ms + LCD_TIMEOUT_TO_STATUS, UNUSED(ms));
}

#if HAS_MARLINUI_MENU
Expand Down Expand Up @@ -596,11 +596,11 @@ class MarlinUI {
#endif

FORCE_INLINE static bool screen_is_sticky() {
return TERN1(SCREENS_CAN_TIME_OUT, defer_return_to_status);
return TERN1(HAS_SCREEN_TIMEOUT, defer_return_to_status);
}

FORCE_INLINE static void defer_status_screen(const bool defer=true) {
TERN(SCREENS_CAN_TIME_OUT, defer_return_to_status = defer, UNUSED(defer));
TERN(HAS_SCREEN_TIMEOUT, defer_return_to_status = defer, UNUSED(defer));
}

static void goto_previous_screen_no_defer() {
Expand Down Expand Up @@ -778,7 +778,7 @@ class MarlinUI {

private:

#if SCREENS_CAN_TIME_OUT
#if HAS_SCREEN_TIMEOUT
static millis_t return_to_status_ms;
static bool defer_return_to_status;
#else
Expand Down
6 changes: 3 additions & 3 deletions Marlin/src/lcd/menu/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ typedef struct {
screenFunc_t menu_function; // The screen's function
uint32_t encoder_position; // The position of the encoder
int8_t top_line, items; // The amount of scroll, and the number of items
#if SCREENS_CAN_TIME_OUT
#if HAS_SCREEN_TIMEOUT
bool sticky; // The screen is sticky
#endif
} menuPosition;
Expand Down Expand Up @@ -89,7 +89,7 @@ void MarlinUI::return_to_status() { goto_screen(status_screen); }

void MarlinUI::push_current_screen() {
if (screen_history_depth < COUNT(screen_history))
screen_history[screen_history_depth++] = { currentScreen, encoderPosition, encoderTopLine, screen_items OPTARG(SCREENS_CAN_TIME_OUT, screen_is_sticky()) };
screen_history[screen_history_depth++] = { currentScreen, encoderPosition, encoderTopLine, screen_items OPTARG(HAS_SCREEN_TIMEOUT, screen_is_sticky()) };
}

void MarlinUI::_goto_previous_screen(TERN_(TURBO_BACK_MENU_ITEM, const bool is_back/*=false*/)) {
Expand All @@ -102,7 +102,7 @@ void MarlinUI::_goto_previous_screen(TERN_(TURBO_BACK_MENU_ITEM, const bool is_b
is_back ? 0 : sh.top_line,
sh.items
);
defer_status_screen(TERN_(SCREENS_CAN_TIME_OUT, sh.sticky));
defer_status_screen(TERN_(HAS_SCREEN_TIMEOUT, sh.sticky));
}
else
return_to_status();
Expand Down