Skip to content

Commit

Permalink
🐛 Fix status_printf alert level
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Mar 25, 2022
1 parent 6b55eec commit 4ff0634
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
39 changes: 21 additions & 18 deletions Marlin/src/lcd/marlinui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1487,9 +1487,12 @@ void MarlinUI::init() {

#include <stdarg.h>

void MarlinUI::status_printf(const uint8_t level, FSTR_P const fmt, ...) {
void MarlinUI::status_printf(int8_t level, FSTR_P const fmt, ...) {
// Alerts block lower priority messages
if (level < 0) level = alert_level = 0;
if (level < alert_level) return;
alert_level = level;

va_list args;
va_start(args, FTOP(fmt));
vsnprintf_P(status_message, MAX_MESSAGE_LENGTH, FTOP(fmt), args);
Expand Down Expand Up @@ -1551,7 +1554,22 @@ void MarlinUI::init() {

#endif

#endif
#else // !HAS_STATUS_MESSAGE

//
// Send the status line as a host notification
//
void MarlinUI::set_status(const char * const cstr, const bool) {
TERN(HOST_PROMPT_SUPPORT, hostui.notify(cstr), UNUSED(cstr));
}
void MarlinUI::set_status(FSTR_P const fstr, const int8_t) {
TERN(HOST_PROMPT_SUPPORT, hostui.notify(fstr), UNUSED(fstr));
}
void MarlinUI::status_printf(int8_t, FSTR_P const fstr, ...) {
TERN(HOST_PROMPT_SUPPORT, hostui.notify(fstr), UNUSED(fstr));
}

#endif // !HAS_STATUS_MESSAGE

#if HAS_DISPLAY

Expand Down Expand Up @@ -1663,22 +1681,7 @@ void MarlinUI::init() {

#endif

#elif !HAS_STATUS_MESSAGE // && !HAS_DISPLAY

//
// Send the status line as a host notification
//
void MarlinUI::set_status(const char * const cstr, const bool) {
TERN(HOST_PROMPT_SUPPORT, hostui.notify(cstr), UNUSED(cstr));
}
void MarlinUI::set_status(FSTR_P const fstr, const int8_t) {
TERN(HOST_PROMPT_SUPPORT, hostui.notify(fstr), UNUSED(fstr));
}
void MarlinUI::status_printf(const uint8_t, FSTR_P const fstr, ...) {
TERN(HOST_PROMPT_SUPPORT, hostui.notify(fstr), UNUSED(fstr));
}

#endif // !HAS_DISPLAY && !HAS_STATUS_MESSAGE
#endif // HAS_DISPLAY

#if ENABLED(SDSUPPORT)

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/marlinui.h
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ class MarlinUI {

static void set_status(const char * const cstr, const bool persist=false);
static void set_status(FSTR_P const fstr, const int8_t level=0);
static void status_printf(const uint8_t level, FSTR_P const fmt, ...);
static void status_printf(int8_t level, FSTR_P const fmt, ...);

#if HAS_DISPLAY

Expand Down

0 comments on commit 4ff0634

Please sign in to comment.