From 051ca358bc2a7589935fd3e2e1e356681d42ed78 Mon Sep 17 00:00:00 2001 From: robbycandra Date: Mon, 15 Nov 2021 22:07:48 +0700 Subject: [PATCH 01/18] Prevent set status message for M104 --- Marlin/src/gcode/temp/M104_M109.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/gcode/temp/M104_M109.cpp b/Marlin/src/gcode/temp/M104_M109.cpp index baaac0210098..f576de7851c7 100644 --- a/Marlin/src/gcode/temp/M104_M109.cpp +++ b/Marlin/src/gcode/temp/M104_M109.cpp @@ -125,7 +125,7 @@ void GcodeSuite::M104_M109(const bool isM109) { thermalManager.auto_job_check_timer(isM109, true); #endif - if (thermalManager.isHeatingHotend(target_extruder) || !no_wait_for_cooling) + if (isM109 && (thermalManager.isHeatingHotend(target_extruder) || !no_wait_for_cooling)) thermalManager.set_heating_message(target_extruder); } From a0114d48d4fea54cea8fa9f2cdd9f34e32b3e232 Mon Sep 17 00:00:00 2001 From: robbycandra Date: Mon, 15 Nov 2021 22:14:35 +0700 Subject: [PATCH 02/18] Prevent set status message for M140 --- Marlin/src/gcode/temp/M140_M190.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Marlin/src/gcode/temp/M140_M190.cpp b/Marlin/src/gcode/temp/M140_M190.cpp index 7532defccdac..4ed733d4ffbf 100644 --- a/Marlin/src/gcode/temp/M140_M190.cpp +++ b/Marlin/src/gcode/temp/M140_M190.cpp @@ -83,7 +83,8 @@ void GcodeSuite::M140_M190(const bool isM190) { thermalManager.setTargetBed(temp); - ui.set_status(thermalManager.isHeatingBed() ? GET_TEXT_F(MSG_BED_HEATING) : GET_TEXT_F(MSG_BED_COOLING)); + if (isM190) + ui.set_status(thermalManager.isHeatingBed() ? GET_TEXT_F(MSG_BED_HEATING) : GET_TEXT_F(MSG_BED_COOLING)); // with PRINTJOB_TIMER_AUTOSTART, M190 can start the timer, and M140 can stop it TERN_(PRINTJOB_TIMER_AUTOSTART, thermalManager.auto_job_check_timer(isM190, !isM190)); From e26457d688c7662ee15b57f161fce5234c5c5eff Mon Sep 17 00:00:00 2001 From: robbycandra Date: Thu, 18 Nov 2021 08:14:01 +0700 Subject: [PATCH 03/18] Setup variable for status message reset with expired time. --- Marlin/src/lcd/marlinui.cpp | 10 ++++++++++ Marlin/src/lcd/marlinui.h | 1 + 2 files changed, 11 insertions(+) diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 57157d2c00ce..7ee64b31287e 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -75,6 +75,8 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #endif char MarlinUI::status_message[MAX_MESSAGE_LENGTH + 1]; uint8_t MarlinUI::alert_level; // = 0 + millis_t MarlinUI::status_message_reset_ms; // will reset message if the expired time reached. + #endif #if ENABLED(LCD_SET_PROGRESS_MANUALLY) @@ -622,6 +624,14 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #endif // BASIC_PROGRESS_BAR + #if HAS_STATUS_MESSAGE + #ifndef GOT_MS + const millis_t ms = millis(); + #endif + if (status_message_reset_ms && ELAPSED(ms, status_message_reset_ms)) + reset_status(); + #endif + #if HAS_LCD_MENU if (use_click()) { #if BOTH(FILAMENT_LCD_DISPLAY, SDSUPPORT) diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index ed5b539eaf8f..1a696e43c602 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -332,6 +332,7 @@ class MarlinUI { static char status_message[]; static uint8_t alert_level; // Higher levels block lower levels + static millis_t status_message_reset_ms; // will reset message if the expired time reached. #if ENABLED(STATUS_MESSAGE_SCROLLING) static uint8_t status_scroll_offset; From 7218607e6febcaf30b9db5d72e6306da4783502e Mon Sep 17 00:00:00 2001 From: robbycandra Date: Thu, 18 Nov 2021 08:16:27 +0700 Subject: [PATCH 04/18] set status_meesage_reset_ms from set_status(); --- Marlin/src/lcd/marlinui.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 7ee64b31287e..3c17883edf73 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -1398,6 +1398,8 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; strncpy(status_message, cstr, maxLen); status_message[maxLen] = '\0'; + status_message_reset_ms = (persist ? 0 : millis() + 2000); + finish_status(persist); } @@ -1415,6 +1417,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #if SERVICE_INTERVAL_3 > 0 static PGMSTR(service3, "> " SERVICE_NAME_3 "!"); #endif + FSTR_P msg; if (printingIsPaused()) msg = GET_TEXT_F(MSG_PRINT_PAUSED); @@ -1445,7 +1448,14 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; void MarlinUI::set_status(FSTR_P const fstr, int8_t level) { PGM_P const pstr = FTOP(fstr); - if (level < 0) level = alert_level = 0; + + if (level < 0) { + status_message_reset_ms = 0; + level = alert_level = 0; + } + else + status_message_reset_ms = millis() + 2000; + if (level < alert_level) return; alert_level = level; @@ -1480,13 +1490,22 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #include - void MarlinUI::status_printf(const uint8_t level, FSTR_P const fmt, ...) { + void MarlinUI::status_printf(uint8_t level, FSTR_P const fmt, ...) { + + if (level < 0) { + status_message_reset_ms = 0; + level = alert_level = 0; + } + else + status_message_reset_ms = millis() + 2000; + 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); va_end(args); + finish_status(level > 0); } From 22bdc364cffa46af11870fc9f798bc8ef6cd9dd4 Mon Sep 17 00:00:00 2001 From: robbycandra Date: Thu, 18 Nov 2021 08:34:50 +0700 Subject: [PATCH 05/18] Bed Heater status message --- Marlin/src/gcode/temp/M140_M190.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Marlin/src/gcode/temp/M140_M190.cpp b/Marlin/src/gcode/temp/M140_M190.cpp index 4ed733d4ffbf..a6ee9e669c94 100644 --- a/Marlin/src/gcode/temp/M140_M190.cpp +++ b/Marlin/src/gcode/temp/M140_M190.cpp @@ -83,8 +83,7 @@ void GcodeSuite::M140_M190(const bool isM190) { thermalManager.setTargetBed(temp); - if (isM190) - ui.set_status(thermalManager.isHeatingBed() ? GET_TEXT_F(MSG_BED_HEATING) : GET_TEXT_F(MSG_BED_COOLING)); + ui.set_status(thermalManager.isHeatingBed() ? GET_TEXT_F(MSG_BED_HEATING) : GET_TEXT_F(MSG_BED_COOLING), (isM190 ? -1 : 0)); // with PRINTJOB_TIMER_AUTOSTART, M190 can start the timer, and M140 can stop it TERN_(PRINTJOB_TIMER_AUTOSTART, thermalManager.auto_job_check_timer(isM190, !isM190)); From 3ba5b31754b3489621b2663e0c0dde10fb6f55ee Mon Sep 17 00:00:00 2001 From: robbycandra Date: Thu, 18 Nov 2021 20:40:08 +0700 Subject: [PATCH 06/18] HotEnd Status Message --- Marlin/src/gcode/temp/M104_M109.cpp | 4 ++-- Marlin/src/lcd/marlinui.cpp | 10 ++++++---- Marlin/src/lcd/marlinui.h | 2 +- Marlin/src/module/temperature.cpp | 4 ++-- Marlin/src/module/temperature.h | 4 ++-- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Marlin/src/gcode/temp/M104_M109.cpp b/Marlin/src/gcode/temp/M104_M109.cpp index f576de7851c7..1e6d3aa03a5a 100644 --- a/Marlin/src/gcode/temp/M104_M109.cpp +++ b/Marlin/src/gcode/temp/M104_M109.cpp @@ -125,8 +125,8 @@ void GcodeSuite::M104_M109(const bool isM109) { thermalManager.auto_job_check_timer(isM109, true); #endif - if (isM109 && (thermalManager.isHeatingHotend(target_extruder) || !no_wait_for_cooling)) - thermalManager.set_heating_message(target_extruder); + if (thermalManager.isHeatingHotend(target_extruder) || !no_wait_for_cooling) + thermalManager.set_heating_message(target_extruder, isM109); } TERN_(AUTOTEMP, planner.autotemp_M104_M109()); diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 3c17883edf73..27a4ab669b12 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -1453,10 +1453,11 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; status_message_reset_ms = 0; level = alert_level = 0; } + else if (level < alert_level) + return; else status_message_reset_ms = millis() + 2000; - if (level < alert_level) return; alert_level = level; TERN_(HOST_PROMPT_SUPPORT, hostui.notify(fstr)); @@ -1490,16 +1491,17 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #include - void MarlinUI::status_printf(uint8_t level, FSTR_P const fmt, ...) { + void MarlinUI::status_printf(int8_t level, FSTR_P const fmt, ...) { if (level < 0) { status_message_reset_ms = 0; level = alert_level = 0; } + else if (level < alert_level) + return; else status_message_reset_ms = millis() + 2000; - if (level < alert_level) return; alert_level = level; va_list args; va_start(args, FTOP(fmt)); @@ -1685,7 +1687,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; 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, ...) { + void MarlinUI::status_printf(const int8_t, FSTR_P const fstr, ...) { TERN(HOST_PROMPT_SUPPORT, hostui.notify(fstr), UNUSED(fstr)); } diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index 1a696e43c602..f5a4bdb9e05c 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -353,7 +353,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(const int8_t level, FSTR_P const fmt, ...); #if EITHER(HAS_DISPLAY, DWIN_CREALITY_LCD_ENHANCED) static void kill_screen(FSTR_P const lcd_error, FSTR_P const lcd_component); diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index ede8aa73acb7..e6b1ed1e2b8e 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -3620,9 +3620,9 @@ void Temperature::isr() { #endif #if HAS_HOTEND && HAS_STATUS_MESSAGE - void Temperature::set_heating_message(const uint8_t e) { + void Temperature::set_heating_message(const uint8_t e, const bool persist) { const bool heating = isHeatingHotend(e); - ui.status_printf(0, + ui.status_printf((persist ? -1 : 0), #if HAS_MULTI_HOTEND F("E%c " S_FMT), '1' + e #else diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index 050b3379e919..d6ae208c5319 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -927,9 +927,9 @@ class Temperature { #endif #if HAS_HOTEND && HAS_STATUS_MESSAGE - static void set_heating_message(const uint8_t e); + static void set_heating_message(const uint8_t e, const bool persist=false); #else - static inline void set_heating_message(const uint8_t) {} + static inline void set_heating_message(const uint8_t, const bool persist=false) {} #endif #if HAS_LCD_MENU && HAS_TEMPERATURE From 5c432c6f26da6b5e114ebb4c2ffbd85c5169e52e Mon Sep 17 00:00:00 2001 From: robbycandra Date: Thu, 18 Nov 2021 21:02:03 +0700 Subject: [PATCH 07/18] define STATUS_MESSAGE_TIMEOUT --- Marlin/Configuration_adv.h | 5 +++++ Marlin/src/lcd/marlinui.cpp | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index fc9688edb76e..d31b42f91d9c 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1304,6 +1304,11 @@ //#define LCD_SHOW_E_TOTAL #endif +#if HAS_STATUS_MESSAGE + // The timeout (in ms) to reset status message + #define STATUS_MESSAGE_TIMEOUT 15000 +#endif + // LCD Print Progress options #if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) #if CAN_SHOW_REMAINING_TIME diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 27a4ab669b12..e36bdc4a7245 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -1398,7 +1398,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; strncpy(status_message, cstr, maxLen); status_message[maxLen] = '\0'; - status_message_reset_ms = (persist ? 0 : millis() + 2000); + status_message_reset_ms = (persist ? 0 : millis() + STATUS_MESSAGE_TIMEOUT); finish_status(persist); } @@ -1456,7 +1456,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; else if (level < alert_level) return; else - status_message_reset_ms = millis() + 2000; + status_message_reset_ms = millis() + STATUS_MESSAGE_TIMEOUT; alert_level = level; @@ -1500,7 +1500,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; else if (level < alert_level) return; else - status_message_reset_ms = millis() + 2000; + status_message_reset_ms = millis() + STATUS_MESSAGE_TIMEOUT ; alert_level = level; va_list args; From 0b100ed81fd1834403deb0376788d877376520f0 Mon Sep 17 00:00:00 2001 From: robbycandra Date: Thu, 18 Nov 2021 21:04:59 +0700 Subject: [PATCH 08/18] GLOBAL_STATUS_MESSAGE is never defined --- Marlin/src/inc/Conditionals_LCD.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index 7b0c9928685c..8ad0d8b4d3f2 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -534,7 +534,7 @@ #define HAS_DISPLAY 1 #endif -#if ANY(HAS_DISPLAY, HAS_DWIN_E3V2, GLOBAL_STATUS_MESSAGE) +#if EITHER(HAS_DISPLAY, HAS_DWIN_E3V2) #define HAS_STATUS_MESSAGE 1 #endif From 72be99001f7c5887a1f7bbd16f072c6b9149033e Mon Sep 17 00:00:00 2001 From: robbycandra Date: Fri, 19 Nov 2021 18:01:46 +0700 Subject: [PATCH 09/18] move STATUS_MESSAGE_TIMEOUT to Conditionals_LCD --- Marlin/Configuration_adv.h | 5 ----- Marlin/src/inc/Conditionals_LCD.h | 7 +++++++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index d31b42f91d9c..fc9688edb76e 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1304,11 +1304,6 @@ //#define LCD_SHOW_E_TOTAL #endif -#if HAS_STATUS_MESSAGE - // The timeout (in ms) to reset status message - #define STATUS_MESSAGE_TIMEOUT 15000 -#endif - // LCD Print Progress options #if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) #if CAN_SHOW_REMAINING_TIME diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index 8ad0d8b4d3f2..7a398f9cc11f 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -538,6 +538,13 @@ #define HAS_STATUS_MESSAGE 1 #endif +#if HAS_STATUS_MESSAGE + // The timeout (in ms) to reset status message + #ifndef STATUS_MESSAGE_TIMEOUT + #define STATUS_MESSAGE_TIMEOUT 15000 + #endif +#endif + #if IS_ULTIPANEL && DISABLED(NO_LCD_MENUS) #define HAS_LCD_MENU 1 #endif From a816f1f40a032f0e33b2ba07f446094c89c2796e Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 24 Mar 2022 21:21:04 -0500 Subject: [PATCH 10/18] tweaks --- Marlin/src/inc/Conditionals_LCD.h | 7 ------- Marlin/src/lcd/marlinui.cpp | 9 +++++++-- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index d553f1028e3d..e7473420cf9d 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -528,13 +528,6 @@ #define HAS_STATUS_MESSAGE 1 #endif -#if HAS_STATUS_MESSAGE - // The timeout (in ms) to reset status message - #ifndef STATUS_MESSAGE_TIMEOUT - #define STATUS_MESSAGE_TIMEOUT 15000 - #endif -#endif - #if IS_ULTIPANEL && DISABLED(NO_LCD_MENUS) #define HAS_MARLINUI_MENU 1 #endif diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 5a1d2875a873..fe3014e67b9f 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -73,7 +73,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #endif char MarlinUI::status_message[MAX_MESSAGE_LENGTH + 1]; uint8_t MarlinUI::alert_level; // = 0 - millis_t MarlinUI::status_message_reset_ms; // will reset message if the expired time reached. + millis_t MarlinUI::status_message_reset_ms; // = 0 #endif @@ -595,7 +595,7 @@ void MarlinUI::init() { // share the same line on the display. // - #if DISABLED(PROGRESS_MSG_ONCE) || (PROGRESS_MSG_EXPIRE > 0) + #if DISABLED(PROGRESS_MSG_ONCE) || PROGRESS_MSG_EXPIRE > 0 #define GOT_MS const millis_t ms = millis(); #endif @@ -631,6 +631,7 @@ void MarlinUI::init() { #if HAS_STATUS_MESSAGE #ifndef GOT_MS + #define GOT_MS const millis_t ms = millis(); #endif if (status_message_reset_ms && ELAPSED(ms, status_message_reset_ms)) @@ -1387,6 +1388,10 @@ void MarlinUI::init() { #include "extui/ui_api.h" #endif + #ifndef STATUS_MESSAGE_TIMEOUT + #define STATUS_MESSAGE_TIMEOUT 15000 + #endif + bool MarlinUI::has_status() { return (status_message[0] != '\0'); } void MarlinUI::set_status(const char * const cstr, const bool persist) { From 16a3f54a69989c13db88c3a44023a51f8f8c8e77 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 24 Mar 2022 21:33:23 -0500 Subject: [PATCH 11/18] Interpret negative level --- Marlin/src/lcd/marlinui.cpp | 7 ++++--- Marlin/src/lcd/marlinui.h | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index fe3014e67b9f..41b2ef1010ff 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -1515,12 +1515,13 @@ void MarlinUI::init() { void MarlinUI::status_printf(int8_t level, FSTR_P const fmt, ...) { + if (ABS(level) < alert_level) + return; + if (level < 0) { status_message_reset_ms = 0; level = alert_level = 0; } - else if (level < alert_level) - return; else status_message_reset_ms = millis() + STATUS_MESSAGE_TIMEOUT ; @@ -1709,7 +1710,7 @@ void MarlinUI::init() { 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 int8_t, FSTR_P const fstr, ...) { + void MarlinUI::status_printf(int8_t, FSTR_P const fstr, ...) { TERN(HOST_PROMPT_SUPPORT, hostui.notify(fstr), UNUSED(fstr)); } diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index 4b5fa417c616..a58a7bd734c3 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -366,7 +366,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 int8_t level, FSTR_P const fmt, ...); + static void status_printf(int8_t level, FSTR_P const fmt, ...); #if HAS_DISPLAY From e6c7dfeadf2ba36dd1c7e2c78ac2545baf742e70 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 24 Mar 2022 22:11:31 -0500 Subject: [PATCH 12/18] Use seconds for config --- Marlin/Configuration_adv.h | 11 ++++--- Marlin/src/inc/Conditionals_adv.h | 4 +++ Marlin/src/inc/SanityCheck.h | 2 ++ Marlin/src/lcd/marlinui.cpp | 54 +++++++++++-------------------- Marlin/src/lcd/marlinui.h | 5 ++- 5 files changed, 36 insertions(+), 40 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 0a18e95ebcad..19a7d1958315 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1339,19 +1339,22 @@ #endif #if EITHER(HAS_DISPLAY, DWIN_LCD_PROUI) - // The timeout (in ms) to return to the status screen from sub-menus - //#define LCD_TIMEOUT_TO_STATUS 15000 + // The timeout to return to the status screen from sub-menus + //#define LCD_TIMEOUT_TO_STATUS 15000 // (ms) #if ENABLED(SHOW_BOOTSCREEN) - #define BOOTSCREEN_TIMEOUT 4000 // (ms) Total Duration to display the boot screen(s) + #define BOOTSCREEN_TIMEOUT 4000 // (ms) Total Duration to display the boot screen(s) #if EITHER(HAS_MARLINUI_U8GLIB, TFT_COLOR_UI) - #define BOOT_MARLIN_LOGO_SMALL // Show a smaller Marlin logo on the Boot Screen (saving lots of flash) + #define BOOT_MARLIN_LOGO_SMALL // Show a smaller Marlin logo on the Boot Screen (saving lots of flash) #endif #endif // 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 diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index d63395a7199f..8a85536aea48 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -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 diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 617d117415b0..fdc5d349ce35 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -849,6 +849,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "LCD_PROGRESS_BAR and FILAMENT_LCD_DISPLAY are not fully compatible. Comment out this line to use both." #elif PROGRESS_MSG_EXPIRE < 0 #error "PROGRESS_MSG_EXPIRE must be greater than or equal to 0." + #elif PROGRESS_MSG_EXPIRE > 0 && HAS_STATUS_MESSAGE_TIMEOUT + #error "PROGRESS_MSG_EXPIRE is not compatible with STATUS_MESSAGE_TIMEOUT_SEC." #endif #elif ENABLED(LCD_SET_PROGRESS_MANUALLY) && NONE(HAS_MARLINUI_U8GLIB, HAS_GRAPHICAL_TFT, HAS_MARLINUI_HD44780, EXTENSIBLE_UI, HAS_DWIN_E3V2, IS_DWIN_MARLINUI) #error "LCD_SET_PROGRESS_MANUALLY requires LCD_PROGRESS_BAR, Character LCD, Graphical LCD, TFT, DWIN_CREALITY_LCD, DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI, DWIN_MARLINUI_*, OR EXTENSIBLE_UI." diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 41b2ef1010ff..14eb7be3d9d2 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -73,8 +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 - millis_t MarlinUI::status_message_reset_ms; // = 0 - + #if HAS_STATUS_MESSAGE_TIMEOUT + millis_t MarlinUI::status_message_expire_ms; // = 0 + #endif #endif #if ENABLED(LCD_SET_PROGRESS_MANUALLY) @@ -629,12 +630,12 @@ void MarlinUI::init() { #endif // BASIC_PROGRESS_BAR - #if HAS_STATUS_MESSAGE + #if HAS_STATUS_MESSAGE_TIMEOUT #ifndef GOT_MS #define GOT_MS const millis_t ms = millis(); #endif - if (status_message_reset_ms && ELAPSED(ms, status_message_reset_ms)) + if (status_message_expire_ms && ELAPSED(ms, status_message_expire_ms)) reset_status(); #endif @@ -1388,10 +1389,6 @@ void MarlinUI::init() { #include "extui/ui_api.h" #endif - #ifndef STATUS_MESSAGE_TIMEOUT - #define STATUS_MESSAGE_TIMEOUT 15000 - #endif - bool MarlinUI::has_status() { return (status_message[0] != '\0'); } void MarlinUI::set_status(const char * const cstr, const bool persist) { @@ -1418,8 +1415,6 @@ void MarlinUI::init() { strncpy(status_message, cstr, maxLen); status_message[maxLen] = '\0'; - status_message_reset_ms = (persist ? 0 : millis() + STATUS_MESSAGE_TIMEOUT); - finish_status(persist); } @@ -1469,20 +1464,10 @@ void MarlinUI::init() { } void MarlinUI::set_status(FSTR_P const fstr, int8_t level) { - PGM_P const pstr = FTOP(fstr); - if (level < 0) { - status_message_reset_ms = 0; - level = alert_level = 0; - } - else if (level < alert_level) - return; - else - status_message_reset_ms = millis() + STATUS_MESSAGE_TIMEOUT; + if (ABS(level) < alert_level) return; - alert_level = level; - - TERN_(HOST_STATUS_NOTIFICATIONS, hostui.notify(fstr)); + PGM_P const pstr = FTOP(fstr); // Since the message is encoded in UTF8 it must // only be cut on a character boundary. @@ -1502,7 +1487,12 @@ void MarlinUI::init() { strncpy_P(status_message, pstr, maxLen); status_message[maxLen] = '\0'; - finish_status(level > 0); + TERN_(HOST_STATUS_NOTIFICATIONS, hostui.notify(fstr)); + + const bool persist = level < 0; + if (persist) level = 0; + alert_level = level; + finish_status(persist); } void MarlinUI::set_alert_status(FSTR_P const fstr) { @@ -1515,17 +1505,8 @@ void MarlinUI::init() { void MarlinUI::status_printf(int8_t level, FSTR_P const fmt, ...) { - if (ABS(level) < alert_level) - return; - - if (level < 0) { - status_message_reset_ms = 0; - level = alert_level = 0; - } - else - status_message_reset_ms = millis() + STATUS_MESSAGE_TIMEOUT ; + if (ABS(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); @@ -1533,12 +1514,15 @@ void MarlinUI::init() { TERN_(HOST_STATUS_NOTIFICATIONS, hostui.notify(status_message)); - finish_status(level > 0); + const bool persist = level < 0; + if (persist) level = 0; + alert_level = level; + finish_status(persist); } void MarlinUI::finish_status(const bool persist) { - UNUSED(persist); + TERN_(HAS_STATUS_MESSAGE_TIMEOUT, status_message_expire_ms = persist ? 0 : millis() + (STATUS_MESSAGE_TIMEOUT_SEC) * 1000UL); #if HAS_WIRED_LCD diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index a58a7bd734c3..7f14ddc375dc 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -345,7 +345,10 @@ class MarlinUI { static char status_message[]; static uint8_t alert_level; // Higher levels block lower levels - static millis_t status_message_reset_ms; // will reset message if the expired time reached. + + #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; From 04c2f816f9d51dc77d06056c963edc9f2087394f Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 24 Mar 2022 23:09:10 -0500 Subject: [PATCH 13/18] message tweaks --- Marlin/src/gcode/lcd/M117.cpp | 2 +- Marlin/src/gcode/temp/M140_M190.cpp | 3 +-- Marlin/src/gcode/temp/M192.cpp | 2 +- Marlin/src/lcd/e3v2/proui/dwin.cpp | 4 ++-- Marlin/src/lcd/marlinui.cpp | 29 +++++++++++++++++------------ Marlin/src/module/motion.cpp | 9 ++------- Marlin/src/module/probe.cpp | 6 +++--- Marlin/src/module/temperature.cpp | 2 +- Marlin/src/sd/cardreader.cpp | 2 +- 9 files changed, 29 insertions(+), 30 deletions(-) diff --git a/Marlin/src/gcode/lcd/M117.cpp b/Marlin/src/gcode/lcd/M117.cpp index f26694bd6463..86023e12e3b4 100644 --- a/Marlin/src/gcode/lcd/M117.cpp +++ b/Marlin/src/gcode/lcd/M117.cpp @@ -33,7 +33,7 @@ void GcodeSuite::M117() { if (parser.string_arg && parser.string_arg[0]) - ui.set_status(parser.string_arg); + ui.set_status(parser.string_arg, true); else ui.reset_status(); diff --git a/Marlin/src/gcode/temp/M140_M190.cpp b/Marlin/src/gcode/temp/M140_M190.cpp index a6ee9e669c94..9e8280567c4d 100644 --- a/Marlin/src/gcode/temp/M140_M190.cpp +++ b/Marlin/src/gcode/temp/M140_M190.cpp @@ -82,8 +82,7 @@ void GcodeSuite::M140_M190(const bool isM190) { if (!got_temp) return; thermalManager.setTargetBed(temp); - - ui.set_status(thermalManager.isHeatingBed() ? GET_TEXT_F(MSG_BED_HEATING) : GET_TEXT_F(MSG_BED_COOLING), (isM190 ? -1 : 0)); + thermalManager.isHeatingBed() ? LCD_MESSAGE(MSG_BED_HEATING) : LCD_MESSAGE(MSG_BED_COOLING); // with PRINTJOB_TIMER_AUTOSTART, M190 can start the timer, and M140 can stop it TERN_(PRINTJOB_TIMER_AUTOSTART, thermalManager.auto_job_check_timer(isM190, !isM190)); diff --git a/Marlin/src/gcode/temp/M192.cpp b/Marlin/src/gcode/temp/M192.cpp index a96e2d34a4bf..04b36a548c3c 100644 --- a/Marlin/src/gcode/temp/M192.cpp +++ b/Marlin/src/gcode/temp/M192.cpp @@ -49,7 +49,7 @@ void GcodeSuite::M192() { } const celsius_t target_temp = parser.value_celsius(); - ui.set_status(thermalManager.isProbeBelowTemp(target_temp) ? GET_TEXT_F(MSG_PROBE_HEATING) : GET_TEXT_F(MSG_PROBE_COOLING)); + thermalManager.isProbeBelowTemp(target_temp) ? LCD_MESSAGE(MSG_PROBE_HEATING) : LCD_MESSAGE(MSG_PROBE_COOLING); thermalManager.wait_for_probe(target_temp, no_wait_for_cooling); } diff --git a/Marlin/src/lcd/e3v2/proui/dwin.cpp b/Marlin/src/lcd/e3v2/proui/dwin.cpp index 66e90740fdfb..7b5f6955afb4 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwin.cpp @@ -2304,7 +2304,7 @@ TERN(HAS_ONESTEP_LEVELING, float, void) Tram(uint8_t point) { inLev = true; zval = probe.probe_at_point(xpos, ypos, PROBE_PT_STOW); if (isnan(zval)) - ui.set_status(F("Position Not Reachable, check offsets")); + LCD_MESSAGE_F("Position Not Reachable, check offsets"); else { sprintf_P(cmd, PSTR("X:%s, Y:%s, Z:%s"), dtostrf(xpos, 1, 1, str_1), @@ -2336,7 +2336,7 @@ void TramC () { Tram(4); } void Trammingwizard() { bed_mesh_t zval = {0}; if (HMI_data.FullManualTramming) { - ui.set_status(F("Disable manual tramming")); + LCD_MESSAGE_F("Disable manual tramming"); return; } zval[0][0] = Tram(0); diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 14eb7be3d9d2..75ba62bb2e17 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -1463,9 +1463,16 @@ void MarlinUI::init() { set_status(msg, -1); } + /** + * Set Status with a fixed string and alert level. + * @param fstr A constant F-string to set as the status. + * @param level Alert level. Negative to ignore and reset the level. Non-zero never expires. + */ void MarlinUI::set_status(FSTR_P const fstr, int8_t level) { - - if (ABS(level) < alert_level) return; + // Alerts block lower priority messages + if (level < 0) level = alert_level = 0; + if (level < alert_level) return; + alert_level = level; PGM_P const pstr = FTOP(fstr); @@ -1489,10 +1496,7 @@ void MarlinUI::init() { TERN_(HOST_STATUS_NOTIFICATIONS, hostui.notify(fstr)); - const bool persist = level < 0; - if (persist) level = 0; - alert_level = level; - finish_status(persist); + finish_status(level > 0); } void MarlinUI::set_alert_status(FSTR_P const fstr) { @@ -1504,8 +1508,10 @@ void MarlinUI::init() { #include void MarlinUI::status_printf(int8_t level, FSTR_P const fmt, ...) { - - if (ABS(level) < alert_level) return; + // 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)); @@ -1514,14 +1520,13 @@ void MarlinUI::init() { TERN_(HOST_STATUS_NOTIFICATIONS, hostui.notify(status_message)); - const bool persist = level < 0; - if (persist) level = 0; - alert_level = level; - finish_status(persist); + finish_status(level > 0); } void MarlinUI::finish_status(const bool persist) { + UNUSED(persist); + TERN_(HAS_STATUS_MESSAGE_TIMEOUT, status_message_expire_ms = persist ? 0 : millis() + (STATUS_MESSAGE_TIMEOUT_SEC) * 1000UL); #if HAS_WIRED_LCD diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 7b1e0a3fb9b9..d8df8e12e1ed 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -29,9 +29,8 @@ #include "stepper.h" #include "planner.h" #include "temperature.h" - #include "../gcode/gcode.h" - +#include "../lcd/marlinui.h" #include "../inc/MarlinConfig.h" #if IS_SCARA @@ -51,10 +50,6 @@ #include "../feature/bltouch.h" #endif -#if HAS_STATUS_MESSAGE - #include "../lcd/marlinui.h" -#endif - #if HAS_FILAMENT_SENSOR #include "../feature/runout.h" #endif @@ -1325,7 +1320,7 @@ void prepare_line_to_destination() { ); SERIAL_ECHO_START(); SERIAL_ECHOLN(msg); - TERN_(HAS_STATUS_MESSAGE, ui.set_status(msg)); + ui.set_status(msg); return true; } return false; diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index ee6323518a2f..8f138aa7a8ef 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -313,9 +313,9 @@ FORCE_INLINE void probe_specific_action(const bool deploy) { ui.set_status(ds_str, 99); SERIAL_ECHOLNF(ds_str); - TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_do(PROMPT_USER_CONTINUE, F("Stow Probe"), FPSTR(CONTINUE_STR))); - TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(F("Stow Probe"))); - TERN_(DWIN_LCD_PROUI, DWIN_Popup_Confirm(ICON_BLTouch, F("Stow Probe"), FPSTR(CONTINUE_STR))); + TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_do(PROMPT_USER_CONTINUE, ds_str, FPSTR(CONTINUE_STR))); + TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(ds_str)); + TERN_(DWIN_LCD_PROUI, DWIN_Popup_Confirm(ICON_BLTouch, ds_str, FPSTR(CONTINUE_STR))); TERN_(HAS_RESUME_CONTINUE, wait_for_user_response()); ui.reset_status(); diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 266ac47a168d..72f77c53684e 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -651,7 +651,7 @@ volatile bool Temperature::raw_temps_ready = false; // PID Tuning loop wait_for_heatup = true; // Can be interrupted with M108 - TERN_(HAS_STATUS_MESSAGE, ui.set_status(F("Wait for heat up..."))); + LCD_MESSAGE(MSG_HEATING); while (wait_for_heatup) { const millis_t ms = millis(); diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index 724de8f82a2f..652a44e52651 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -458,7 +458,7 @@ void CardReader::mount() { cdroot(); #if ENABLED(USB_FLASH_DRIVE_SUPPORT) || PIN_EXISTS(SD_DETECT) else if (marlin_state != MF_INITIALIZING) - ui.set_status(GET_TEXT_F(MSG_MEDIA_INIT_FAIL), -1); + LCD_ALERTMESSAGE(MSG_MEDIA_INIT_FAIL); #endif ui.refresh(); From 3b543af4a70f913f8f513bd997965477a1f887d5 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 25 Mar 2022 00:03:41 -0500 Subject: [PATCH 14/18] message reset callback --- Marlin/src/gcode/temp/M104_M109.cpp | 2 +- Marlin/src/gcode/temp/M140_M190.cpp | 4 +++- Marlin/src/lcd/marlinui.cpp | 10 ++++++++-- Marlin/src/lcd/marlinui.h | 10 ++++++---- Marlin/src/module/temperature.cpp | 9 +++++++-- Marlin/src/module/temperature.h | 2 +- 6 files changed, 26 insertions(+), 11 deletions(-) diff --git a/Marlin/src/gcode/temp/M104_M109.cpp b/Marlin/src/gcode/temp/M104_M109.cpp index 1e6d3aa03a5a..1a342a983625 100644 --- a/Marlin/src/gcode/temp/M104_M109.cpp +++ b/Marlin/src/gcode/temp/M104_M109.cpp @@ -126,7 +126,7 @@ void GcodeSuite::M104_M109(const bool isM109) { #endif if (thermalManager.isHeatingHotend(target_extruder) || !no_wait_for_cooling) - thermalManager.set_heating_message(target_extruder, isM109); + thermalManager.set_heating_message(target_extruder, !isM109); } TERN_(AUTOTEMP, planner.autotemp_M104_M109()); diff --git a/Marlin/src/gcode/temp/M140_M190.cpp b/Marlin/src/gcode/temp/M140_M190.cpp index 9e8280567c4d..d6137468b3a7 100644 --- a/Marlin/src/gcode/temp/M140_M190.cpp +++ b/Marlin/src/gcode/temp/M140_M190.cpp @@ -84,11 +84,13 @@ void GcodeSuite::M140_M190(const bool isM190) { thermalManager.setTargetBed(temp); thermalManager.isHeatingBed() ? LCD_MESSAGE(MSG_BED_HEATING) : LCD_MESSAGE(MSG_BED_COOLING); - // with PRINTJOB_TIMER_AUTOSTART, M190 can start the timer, and M140 can stop it + // With PRINTJOB_TIMER_AUTOSTART, M190 can start the timer, and M140 can stop it TERN_(PRINTJOB_TIMER_AUTOSTART, thermalManager.auto_job_check_timer(isM190, !isM190)); if (isM190) thermalManager.wait_for_bed(no_wait_for_cooling); + else + ui.set_status_reset_fn([]{ return thermalManager.degBedNear(thermalManager.degTargetBed()); }); } #endif // HAS_HEATED_BED diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 75ba62bb2e17..1203b27ad425 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -76,6 +76,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #if HAS_STATUS_MESSAGE_TIMEOUT millis_t MarlinUI::status_message_expire_ms; // = 0 #endif + statusResetFunc_t MarlinUI::reset_status_callback; // = nullptr #endif #if ENABLED(LCD_SET_PROGRESS_MANUALLY) @@ -630,15 +631,18 @@ void MarlinUI::init() { #endif // BASIC_PROGRESS_BAR + bool did_expire = reset_status_callback && (*reset_status_callback)(); + #if HAS_STATUS_MESSAGE_TIMEOUT #ifndef GOT_MS #define GOT_MS const millis_t ms = millis(); #endif - if (status_message_expire_ms && ELAPSED(ms, status_message_expire_ms)) - reset_status(); + 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()) { #if BOTH(FILAMENT_LCD_DISPLAY, SDSUPPORT) @@ -1527,6 +1531,8 @@ void MarlinUI::init() { UNUSED(persist); + 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 diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index 7f14ddc375dc..685e661028b4 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -39,10 +39,6 @@ #define HAS_ENCODER_ACTION 1 #endif -#if HAS_STATUS_MESSAGE - #define START_OF_UTF8_CHAR(C) (((C) & 0xC0u) != 0x80U) -#endif - #if E_MANUAL > 1 #define MULTI_E_MANUAL 1 #endif @@ -63,6 +59,8 @@ #define START_OF_UTF8_CHAR(C) (((C) & 0xC0u) != 0x80U) +typedef bool (*statusResetFunc_t)(); + #if HAS_WIRED_LCD enum LCDViewAction : uint8_t { @@ -360,11 +358,15 @@ class MarlinUI { static void reset_status(const bool no_welcome=false); static void set_alert_status(FSTR_P const fstr); static void reset_alert_level() { alert_level = 0; } + + static statusResetFunc_t reset_status_callback; + static void set_status_reset_fn(const statusResetFunc_t fn=nullptr) { reset_status_callback = fn; } #else static constexpr bool has_status() { return false; } static void reset_status(const bool=false) {} static void set_alert_status(FSTR_P const) {} static void reset_alert_level() {} + static void set_status_reset_fn(const statusResetFunc_t=nullptr) {} #endif static void set_status(const char * const cstr, const bool persist=false); diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 72f77c53684e..bbeddcbf816f 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -3631,9 +3631,9 @@ void Temperature::isr() { #endif #if HAS_HOTEND && HAS_STATUS_MESSAGE - void Temperature::set_heating_message(const uint8_t e, const bool persist) { + void Temperature::set_heating_message(const uint8_t e, const bool isM104/*=false*/) { const bool heating = isHeatingHotend(e); - ui.status_printf((persist ? -1 : 0), + ui.status_printf(0, #if HAS_MULTI_HOTEND F("E%c " S_FMT), '1' + e #else @@ -3641,6 +3641,11 @@ void Temperature::isr() { #endif , heating ? GET_TEXT(MSG_HEATING) : GET_TEXT(MSG_COOLING) ); + + if (isM104) { + static uint8_t wait_e; wait_e = e; + ui.set_status_reset_fn([]{ return degHotendNear(wait_e, degTargetHotend(wait_e)); }); + } } #endif diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index 321f5bdcf327..a4681ba02ba9 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -961,7 +961,7 @@ class Temperature { #endif #if HAS_HOTEND && HAS_STATUS_MESSAGE - static void set_heating_message(const uint8_t e, const bool persist=false); + static void set_heating_message(const uint8_t e, const bool isM104=false); #else static void set_heating_message(const uint8_t, const bool=false) {} #endif From 4590ba8b479902b6e58829f658edb7dbda18f0cd Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 25 Mar 2022 00:34:12 -0500 Subject: [PATCH 15/18] No "cooling" message for low temps --- Marlin/src/gcode/temp/M104_M109.cpp | 2 +- Marlin/src/gcode/temp/M140_M190.cpp | 5 ++++- Marlin/src/module/temperature.cpp | 5 ++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Marlin/src/gcode/temp/M104_M109.cpp b/Marlin/src/gcode/temp/M104_M109.cpp index 1a342a983625..331ceeb61db1 100644 --- a/Marlin/src/gcode/temp/M104_M109.cpp +++ b/Marlin/src/gcode/temp/M104_M109.cpp @@ -126,7 +126,7 @@ void GcodeSuite::M104_M109(const bool isM109) { #endif if (thermalManager.isHeatingHotend(target_extruder) || !no_wait_for_cooling) - thermalManager.set_heating_message(target_extruder, !isM109); + thermalManager.set_heating_message(target_extruder, !isM109 && got_temp); } TERN_(AUTOTEMP, planner.autotemp_M104_M109()); diff --git a/Marlin/src/gcode/temp/M140_M190.cpp b/Marlin/src/gcode/temp/M140_M190.cpp index d6137468b3a7..c5e3c000290c 100644 --- a/Marlin/src/gcode/temp/M140_M190.cpp +++ b/Marlin/src/gcode/temp/M140_M190.cpp @@ -90,7 +90,10 @@ void GcodeSuite::M140_M190(const bool isM190) { if (isM190) thermalManager.wait_for_bed(no_wait_for_cooling); else - ui.set_status_reset_fn([]{ return thermalManager.degBedNear(thermalManager.degTargetBed()); }); + ui.set_status_reset_fn([]{ + const celsius_t c = thermalManager.degTargetBed(); + return c < 30 || thermalManager.degBedNear(c); + }); } #endif // HAS_HEATED_BED diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index bbeddcbf816f..6660d9a8f81c 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -3644,7 +3644,10 @@ void Temperature::isr() { if (isM104) { static uint8_t wait_e; wait_e = e; - ui.set_status_reset_fn([]{ return degHotendNear(wait_e, degTargetHotend(wait_e)); }); + ui.set_status_reset_fn([]{ + const celsius_t c = degTargetHotend(wait_e); + return c < 30 || degHotendNear(wait_e, c); + }); } } #endif From 2f31b31ce6186c708eceb45e94c7cb570e6cb0ca Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 25 Mar 2022 00:48:14 -0500 Subject: [PATCH 16/18] serial text in english only --- Marlin/src/core/multi_language.h | 3 +++ Marlin/src/module/probe.cpp | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Marlin/src/core/multi_language.h b/Marlin/src/core/multi_language.h index 2106f946ac73..a605a6f02441 100644 --- a/Marlin/src/core/multi_language.h +++ b/Marlin/src/core/multi_language.h @@ -80,6 +80,9 @@ typedef const char Language_Str[]; #endif #define GET_TEXT_F(MSG) FPSTR(GET_TEXT(MSG)) +#define GET_EN_TEXT(MSG) GET_LANG(en)::MSG +#define GET_EN_TEXT_F(MSG) FPSTR(GET_EN_TEXT(MSG)) + #define GET_LANGUAGE_NAME(INDEX) GET_LANG(LCD_LANGUAGE_##INDEX)::LANGUAGE #define LANG_CHARSIZE GET_TEXT(CHARSIZE) #define USE_WIDE_GLYPH (LANG_CHARSIZE > 2) diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index 8f138aa7a8ef..5b0bd77d0de7 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -311,7 +311,7 @@ FORCE_INLINE void probe_specific_action(const bool deploy) { FSTR_P const ds_str = deploy ? GET_TEXT_F(MSG_MANUAL_DEPLOY) : GET_TEXT_F(MSG_MANUAL_STOW); ui.return_to_status(); // To display the new status message ui.set_status(ds_str, 99); - SERIAL_ECHOLNF(ds_str); + SERIAL_ECHOLNF(deploy ? GET_EN_TEXT_F(MSG_MANUAL_DEPLOY) : GET_EN_TEXT_F(MSG_MANUAL_STOW)); TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_do(PROMPT_USER_CONTINUE, ds_str, FPSTR(CONTINUE_STR))); TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(ds_str)); From 5c7dd35bffca728ee19e7326221b6bf30555892b Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 25 Mar 2022 18:06:57 -0500 Subject: [PATCH 17/18] rename cb --- Marlin/src/lcd/marlinui.cpp | 4 ++-- Marlin/src/lcd/marlinui.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 1203b27ad425..c10dd46f7234 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -76,7 +76,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #if HAS_STATUS_MESSAGE_TIMEOUT millis_t MarlinUI::status_message_expire_ms; // = 0 #endif - statusResetFunc_t MarlinUI::reset_status_callback; // = nullptr + statusResetFunc_t MarlinUI::status_reset_callback; // = nullptr #endif #if ENABLED(LCD_SET_PROGRESS_MANUALLY) @@ -631,7 +631,7 @@ void MarlinUI::init() { #endif // BASIC_PROGRESS_BAR - bool did_expire = reset_status_callback && (*reset_status_callback)(); + bool did_expire = status_reset_callback && (*status_reset_callback)(); #if HAS_STATUS_MESSAGE_TIMEOUT #ifndef GOT_MS diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index 685e661028b4..d9404541d268 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -359,8 +359,8 @@ class MarlinUI { static void set_alert_status(FSTR_P const fstr); static void reset_alert_level() { alert_level = 0; } - static statusResetFunc_t reset_status_callback; - static void set_status_reset_fn(const statusResetFunc_t fn=nullptr) { reset_status_callback = fn; } + static statusResetFunc_t status_reset_callback; + static void set_status_reset_fn(const statusResetFunc_t fn=nullptr) { status_reset_callback = fn; } #else static constexpr bool has_status() { return false; } static void reset_status(const bool=false) {} From 17a0c2411dc00a8ee64f019481223efbb8f04e66 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 25 Mar 2022 18:19:49 -0500 Subject: [PATCH 18/18] use #warning --- Marlin/src/inc/SanityCheck.h | 2 -- Marlin/src/inc/Warnings.cpp | 4 ++++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index fdc5d349ce35..617d117415b0 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -849,8 +849,6 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "LCD_PROGRESS_BAR and FILAMENT_LCD_DISPLAY are not fully compatible. Comment out this line to use both." #elif PROGRESS_MSG_EXPIRE < 0 #error "PROGRESS_MSG_EXPIRE must be greater than or equal to 0." - #elif PROGRESS_MSG_EXPIRE > 0 && HAS_STATUS_MESSAGE_TIMEOUT - #error "PROGRESS_MSG_EXPIRE is not compatible with STATUS_MESSAGE_TIMEOUT_SEC." #endif #elif ENABLED(LCD_SET_PROGRESS_MANUALLY) && NONE(HAS_MARLINUI_U8GLIB, HAS_GRAPHICAL_TFT, HAS_MARLINUI_HD44780, EXTENSIBLE_UI, HAS_DWIN_E3V2, IS_DWIN_MARLINUI) #error "LCD_SET_PROGRESS_MANUALLY requires LCD_PROGRESS_BAR, Character LCD, Graphical LCD, TFT, DWIN_CREALITY_LCD, DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI, DWIN_MARLINUI_*, OR EXTENSIBLE_UI." diff --git a/Marlin/src/inc/Warnings.cpp b/Marlin/src/inc/Warnings.cpp index 9d7b14d763ac..97e8e76b38d8 100644 --- a/Marlin/src/inc/Warnings.cpp +++ b/Marlin/src/inc/Warnings.cpp @@ -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 */