Skip to content

Commit

Permalink
✨ STATUS_MESSAGE_TIMEOUT_SEC (MarlinFirmware#23135)
Browse files Browse the repository at this point in the history
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
  • Loading branch information
robbycandra and thinkyhead authored Mar 25, 2022
1 parent fd74261 commit b7ffcd6
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1352,6 +1352,9 @@
// Scroll a longer status message into view
//#define STATUS_MESSAGE_SCROLLING

// Apply a timeout to low-priority status messages
//#define STATUS_MESSAGE_TIMEOUT_SEC 30 // (seconds)

// On the Info Screen, display XY with one decimal place when possible
//#define LCD_DECIMAL_SMALL_XY

Expand Down
4 changes: 4 additions & 0 deletions Marlin/src/inc/Conditionals_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,10 @@
#define HAS_PRINT_PROGRESS 1
#endif

#if STATUS_MESSAGE_TIMEOUT_SEC > 0
#define HAS_STATUS_MESSAGE_TIMEOUT 1
#endif

#if ENABLED(SDSUPPORT) && SD_PROCEDURE_DEPTH
#define HAS_MEDIA_SUBCALLS 1
#endif
Expand Down
4 changes: 4 additions & 0 deletions Marlin/src/inc/Warnings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,10 @@
#warning "Contrast cannot be changed when LCD_CONTRAST_MIN >= LCD_CONTRAST_MAX."
#endif

#if PROGRESS_MSG_EXPIRE > 0 && HAS_STATUS_MESSAGE_TIMEOUT
#warning "It is recommended not to combine PROGRESS_MSG_EXPIRE with STATUS_MESSAGE_TIMEOUT_SEC."
#endif

/**
* FYSETC backlighting
*/
Expand Down
18 changes: 16 additions & 2 deletions Marlin/src/lcd/marlinui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
#endif
char MarlinUI::status_message[MAX_MESSAGE_LENGTH + 1];
uint8_t MarlinUI::alert_level; // = 0
#if HAS_STATUS_MESSAGE_TIMEOUT
millis_t MarlinUI::status_message_expire_ms; // = 0
#endif
statusResetFunc_t MarlinUI::status_reset_callback; // = nullptr
#endif

Expand Down Expand Up @@ -628,8 +631,17 @@ void MarlinUI::init() {

#endif // BASIC_PROGRESS_BAR

if (status_reset_callback && (*status_reset_callback)())
reset_status();
bool did_expire = status_reset_callback && (*status_reset_callback)();

#if HAS_STATUS_MESSAGE_TIMEOUT
#ifndef GOT_MS
#define GOT_MS
const millis_t ms = millis();
#endif
did_expire |= status_message_expire_ms && ELAPSED(ms, status_message_expire_ms);
#endif

if (did_expire) reset_status();

#if HAS_MARLINUI_MENU
if (use_click()) {
Expand Down Expand Up @@ -1521,6 +1533,8 @@ void MarlinUI::init() {

set_status_reset_fn();

TERN_(HAS_STATUS_MESSAGE_TIMEOUT, status_message_expire_ms = persist ? 0 : millis() + (STATUS_MESSAGE_TIMEOUT_SEC) * 1000UL);

#if HAS_WIRED_LCD

#if BASIC_PROGRESS_BAR || BOTH(FILAMENT_LCD_DISPLAY, SDSUPPORT)
Expand Down
4 changes: 4 additions & 0 deletions Marlin/src/lcd/marlinui.h
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,10 @@ class MarlinUI {
static char status_message[];
static uint8_t alert_level; // Higher levels block lower levels

#if HAS_STATUS_MESSAGE_TIMEOUT
static millis_t status_message_expire_ms; // Reset some status messages after a timeout
#endif

#if ENABLED(STATUS_MESSAGE_SCROLLING)
static uint8_t status_scroll_offset;
static void advance_status_scroll();
Expand Down

0 comments on commit b7ffcd6

Please sign in to comment.