From 3c1c2fd2caf44dae28c02874b59a72d0311d9e1a Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Sat, 17 Dec 2022 16:36:28 +0100 Subject: [PATCH] Use menu_set_block() in ThermalStop() Set a menu block for fatal thermal errors instead of abusing lcd_return_to_status() to kick the user out of the menus. This now allows a thermal model error to be recoverable through menu access. --- Firmware/Marlin_main.cpp | 22 ++++++++++++---------- Firmware/temperature.cpp | 1 - 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index f2c4a75c9..1590e2311 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -9717,14 +9717,14 @@ void UnconditionalStop() // WARNING: This function is called *continuously* during a thermal failure. // // This either pauses (for thermal model errors) or stops *without recovery* depending on -// "allow_pause". If pause is allowed, this forces a printer-initiated instantanenous pause (just -// like an LCD pause) that bypasses the host pausing functionality. In this state the printer is -// kept in busy state and *must* be recovered from the LCD. -void ThermalStop(bool allow_pause) +// "allow_recovery". If recovery is allowed, this forces a printer-initiated instantanenous pause +// (just like an LCD pause) that bypasses the host pausing functionality. In this state the printer +// is kept in busy state and *must* be recovered from the LCD. +void ThermalStop(bool allow_recovery) { if(Stopped == false) { Stopped = true; - if(allow_pause && (IS_SD_PRINTING || usb_timer.running())) { + if(allow_recovery && (IS_SD_PRINTING || usb_timer.running())) { if (!isPrintPaused) { lcd_setalertstatuspgm(_T(MSG_PAUSED_THERMAL_ERROR), LCD_STATUS_CRITICAL); @@ -9757,13 +9757,15 @@ void ThermalStop(bool allow_pause) // Make a warning sound! We cannot use Sound_MakeCustom as this would stop further moves. // Turn on the speaker here (if not already), and turn it off when back in the main loop. WRITE(BEEPER, HIGH); - } - // Return to the status screen to stop any pending menu action which could have been - // started by the user while stuck in the Stopped state. This also ensures the NEW - // error is immediately shown. - if (menu_menu != lcd_status_screen) + // Always return to the status screen to ensure the NEW error is immediately shown. lcd_return_to_status(); + + if(!allow_recovery) { + // prevent menu access for all fatal errors + menu_set_block(MENU_BLOCK_THERMAL_ERROR); + } + } } bool IsStopped() { return Stopped; }; diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index bb9fa8f12..04144b71e 100755 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -1766,7 +1766,6 @@ void handle_temp_error() } else { temp_error_state.v = 0; WRITE(BEEPER, LOW); - menu_unset_block(MENU_BLOCK_THERMAL_ERROR); // hotend error was transitory and disappeared, re-enable bed if (!target_temperature_bed)