Skip to content

Commit

Permalink
Fix, clarify LCD_TIMEOUT_TO_STATUS
Browse files Browse the repository at this point in the history
Replaces MarlinFirmware#17887

Co-Authored-By: Daniel Callander <[email protected]>
  • Loading branch information
2 people authored and HairingX committed Jun 16, 2021
1 parent b519c4b commit d1e4234
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ bool BaseScreen::buttonStyleCallback(CommandProcessor &cmd, uint8_t tag, uint8_t
return false;
}

#if LCD_TIMEOUT_TO_STATUS
#if LCD_TIMEOUT_TO_STATUS > 0
if (EventLoop::get_pressed_tag() != 0) {
reset_menu_timeout();
}
Expand All @@ -66,7 +66,7 @@ bool BaseScreen::buttonStyleCallback(CommandProcessor &cmd, uint8_t tag, uint8_t
}

void BaseScreen::onIdle() {
#if LCD_TIMEOUT_TO_STATUS
#if LCD_TIMEOUT_TO_STATUS > 0
if ((millis() - last_interaction) > LCD_TIMEOUT_TO_STATUS) {
reset_menu_timeout();
#if ENABLED(TOUCH_UI_DEBUG)
Expand All @@ -78,12 +78,12 @@ void BaseScreen::onIdle() {
}

void BaseScreen::reset_menu_timeout() {
#if LCD_TIMEOUT_TO_STATUS
#if LCD_TIMEOUT_TO_STATUS > 0
last_interaction = millis();
#endif
}

#if LCD_TIMEOUT_TO_STATUS
#if LCD_TIMEOUT_TO_STATUS > 0
uint32_t BaseScreen::last_interaction;
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ enum {

class BaseScreen : public UIScreen {
protected:
#if LCD_TIMEOUT_TO_STATUS
#if LCD_TIMEOUT_TO_STATUS > 0
static uint32_t last_interaction;
#endif

Expand Down
6 changes: 3 additions & 3 deletions Marlin/src/lcd/ultralcd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ MarlinUI ui;
#endif
#endif

#if HAS_LCD_MENU && LCD_TIMEOUT_TO_STATUS
#if HAS_LCD_MENU && LCD_TIMEOUT_TO_STATUS > 0
bool MarlinUI::defer_return_to_status;
#endif

Expand Down Expand Up @@ -732,7 +732,7 @@ void MarlinUI::update() {
static uint16_t max_display_update_time = 0;
millis_t ms = millis();

#if HAS_LCD_MENU && LCD_TIMEOUT_TO_STATUS
#if HAS_LCD_MENU && LCD_TIMEOUT_TO_STATUS > 0
static millis_t return_to_status_ms = 0;
#define RESET_STATUS_TIMEOUT() (return_to_status_ms = ms + LCD_TIMEOUT_TO_STATUS)
#else
Expand Down Expand Up @@ -967,7 +967,7 @@ void MarlinUI::update() {
NOLESS(max_display_update_time, millis() - ms);
}

#if HAS_LCD_MENU && LCD_TIMEOUT_TO_STATUS
#if HAS_LCD_MENU && LCD_TIMEOUT_TO_STATUS > 0
// Return to Status Screen after a timeout
if (on_status_screen() || defer_return_to_status)
RESET_STATUS_TIMEOUT();
Expand Down
8 changes: 6 additions & 2 deletions Marlin/src/lcd/ultralcd.h
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,11 @@ class MarlinUI {
#endif

FORCE_INLINE static void defer_status_screen(const bool defer=true) {
TERN(LCD_TIMEOUT_TO_STATUS, defer_return_to_status = defer, UNUSED(defer));
#if LCD_TIMEOUT_TO_STATUS > 0
defer_return_to_status = defer;
#else
UNUSED(defer);
#endif
}

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

#if HAS_SPI_LCD
#if HAS_LCD_MENU
#if LCD_TIMEOUT_TO_STATUS
#if LCD_TIMEOUT_TO_STATUS > 0
static bool defer_return_to_status;
#else
static constexpr bool defer_return_to_status = false;
Expand Down

0 comments on commit d1e4234

Please sign in to comment.