From 88b77ecce28bbaebe6596c4898257f18c88e581f Mon Sep 17 00:00:00 2001 From: 3d-gussner <3d.gussner@gmail.com> Date: Thu, 15 Feb 2024 15:26:13 +0100 Subject: [PATCH] Add bool printer_recovering --- Firmware/Marlin.h | 2 ++ Firmware/Marlin_main.cpp | 12 ++++++++---- Firmware/power_panic.cpp | 2 +- Firmware/ultralcd.cpp | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index 760339220..7ae27ca3f 100755 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -318,6 +318,8 @@ bool printingIsPaused(); bool printer_active(); +bool printer_recovering(); + //! Beware - mcode_in_progress is set as soon as the command gets really processed, //! which is not the same as posting the M600 command into the command queue //! There can be a considerable lag between posting M600 and its real processing which might result diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index f688dcd65..4e8a9e380 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -523,8 +523,7 @@ bool __attribute__((noinline)) printer_active() { || (lcd_commands_type != LcdCommands::Idle) || MMU2::mmu2.MMU_PRINT_SAVED() || homing_flag - || mesh_bed_leveling_flag - || (eeprom_read_byte((uint8_t*)EEPROM_UVLO) != PowerPanic::NO_PENDING_RECOVERY); + || mesh_bed_leveling_flag; } #ifdef DEBUG_PRINTER_STATES @@ -577,6 +576,11 @@ void debug_printer_states() } #endif //End DEBUG_PRINTER_STATES +// Block LCD menus when +bool __attribute__((noinline)) printer_recovering() { + return (eeprom_read_byte((uint8_t*)EEPROM_UVLO) != PowerPanic::NO_PENDING_RECOVERY); +} + // Currently only used in one place, allowed to be inlined bool check_fsensor() { return printJobOngoing() @@ -1631,7 +1635,7 @@ void setup() fw_crash_init(); #ifdef UVLO_SUPPORT - if (eeprom_read_byte((uint8_t*)EEPROM_UVLO) != PowerPanic::NO_PENDING_RECOVERY) { //previous print was terminated by UVLO + if (printer_recovering()) { //previous print was terminated by UVLO manage_heater(); // Update temperatures #ifdef DEBUG_UVLO_AUTOMATIC_RECOVER printf_P(_N("Power panic detected!\nCurrent bed temp:%d\nSaved bed temp:%d\n"), (int)degBed(), eeprom_read_byte((uint8_t*)EEPROM_UVLO_TARGET_BED)); @@ -6051,7 +6055,7 @@ Sigma_Exit: } if (eeprom_read_byte((uint8_t*)EEPROM_UVLO_PRINT_TYPE) == PowerPanic::PRINT_TYPE_HOST - && eeprom_read_byte((uint8_t*)EEPROM_UVLO) != PowerPanic::NO_PENDING_RECOVERY + && printer_recovering() && printingIsPaused()) { // The print is in a paused state. The print was recovered following a power panic // but up to this point the printer has been waiting for the M79 from the host diff --git a/Firmware/power_panic.cpp b/Firmware/power_panic.cpp index 749fafd83..8cc5ada43 100644 --- a/Firmware/power_panic.cpp +++ b/Firmware/power_panic.cpp @@ -286,7 +286,7 @@ void setup_uvlo_interrupt() { EIMSK |= (1 << 4); // check if power was lost before we armed the interrupt - if(!(PINE & (1 << 4)) && eeprom_read_byte((uint8_t*)EEPROM_UVLO) != PowerPanic::NO_PENDING_RECOVERY) + if(!(PINE & (1 << 4)) && printer_recovering()) { SERIAL_ECHOLNRPGM(MSG_INT4); uvlo_drain_reset(); diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index f6ca2dc51..649e4c476 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -5289,7 +5289,7 @@ static void lcd_main_menu() } if((printJobOngoing() || printingIsPaused() - || (eeprom_read_byte((uint8_t*)EEPROM_UVLO) != PowerPanic::NO_PENDING_RECOVERY)) + || (printer_recovering())) && (custom_message_type != CustomMsg::MeshBedLeveling) && !processing_tcode) { MENU_ITEM_SUBMENU_P(_T(MSG_STOP_PRINT), lcd_sdcard_stop);