From 4bc6bc3f900c6a57c06f199efd94788b56ea0655 Mon Sep 17 00:00:00 2001 From: 3d-gussner <3d.gussner@gmail.com> Date: Wed, 29 Nov 2023 17:44:00 +0100 Subject: [PATCH 1/3] Improve USb power panic --- Firmware/Marlin_main.cpp | 14 ++++---------- Firmware/cmdqueue.cpp | 2 ++ Firmware/printer_state.h | 1 - 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 845bd6117..6a1c82b20 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -4105,6 +4105,9 @@ void process_commands() { // M24 - Start SD print enquecommand_P(MSG_M24); + + // Print is recovered, clear the recovery flag + eeprom_update_byte((uint8_t*)EEPROM_UVLO, PowerPanic::NO_PENDING_RECOVERY); } else if (eeprom_read_byte((uint8_t*)EEPROM_UVLO_PRINT_TYPE) == PowerPanic::PRINT_TYPE_USB) { @@ -4116,13 +4119,7 @@ void process_commands() // Park the extruder to the side and don't resume the print // we must assume that the host as not fully booted up at this point lcd_pause_print(); - - // Used by M79 to differentiate from a normal pause - SetPrinterState(PrinterState::PowerPanicWaitingForHost); } - - // Print is recovered, clear the recovery flag - eeprom_update_byte((uint8_t*)EEPROM_UVLO, PowerPanic::NO_PENDING_RECOVERY); } else if (code_seen_P(PSTR("MMURES"))) // PRUSA MMURES { @@ -5981,15 +5978,12 @@ Sigma_Exit: } } - if (GetPrinterState() == PrinterState::PowerPanicWaitingForHost && print_job_timer.isPaused()) { + if (eeprom_read_byte((uint8_t*)EEPROM_UVLO_PRINT_TYPE) == PowerPanic::PRINT_TYPE_USB && print_job_timer.isPaused()) { // 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 // Send action to the host, so the host can resume the print. It is up to the host // to resume the print correctly. SERIAL_ECHOLNRPGM(MSG_OCTOPRINT_UVLO_RECOVERY_READY); - - // Update the state so the action is not repeated again - SetPrinterState(PrinterState::IsHostPrinting); } break; diff --git a/Firmware/cmdqueue.cpp b/Firmware/cmdqueue.cpp index 73e2b830c..b9f460f4e 100755 --- a/Firmware/cmdqueue.cpp +++ b/Firmware/cmdqueue.cpp @@ -8,6 +8,7 @@ #include "messages.h" #include "language.h" #include "stopwatch.h" +#include "power_panic.h" // Reserve BUFSIZE lines of length MAX_CMD_SIZE plus CMDBUFFER_RESERVE_FRONT. char cmdbuffer[BUFSIZE * (MAX_CMD_SIZE + 1) + CMDBUFFER_RESERVE_FRONT]; @@ -483,6 +484,7 @@ void get_command() if ((*cmd_start == 'G') && (GetPrinterState() != PrinterState::IsSDPrinting)) { usb_timer.start(); SetPrinterState(PrinterState::IsHostPrinting); //set printer state busy printing to hide LCD menu while USB printing + eeprom_update_byte((uint8_t*)EEPROM_UVLO, PowerPanic::NO_PENDING_RECOVERY); } if (allow_when_stopped == false && Stopped == true) { // Stopped can be set either during error states (thermal error: cannot continue), or diff --git a/Firmware/printer_state.h b/Firmware/printer_state.h index a88d36f4a..22b9fe5bd 100644 --- a/Firmware/printer_state.h +++ b/Firmware/printer_state.h @@ -23,7 +23,6 @@ enum class PrinterState : uint8_t HostPrintingFinished = 4, IsSDPrinting = 5, IsHostPrinting = 6, - PowerPanicWaitingForHost = 7, }; PrinterState GetPrinterState(); From d36ea24c025634848b8589c87d6009ae07a5469d Mon Sep 17 00:00:00 2001 From: 3d-gussner <3d.gussner@gmail.com> Date: Wed, 29 Nov 2023 20:03:07 +0100 Subject: [PATCH 2/3] After reset or low bed temp recover HOST print as the HOST has to decide what to do Only during SD print and a Reset + Low Bed temp the user has to confirm on LCD --- Firmware/Marlin_main.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 6a1c82b20..1847b8e62 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -1589,11 +1589,15 @@ void setup() #ifdef DEBUG_UVLO_AUTOMATIC_RECOVER puts_P(_N("Normal recovery!")); #endif - const uint8_t btn = lcd_show_fullscreen_message_yes_no_and_wait_P(_T(MSG_RECOVER_PRINT), false); - if ( btn == LCD_LEFT_BUTTON_CHOICE) { - recover_print(0); - } else { // LCD_MIDDLE_BUTTON_CHOICE - eeprom_update_byte((uint8_t*)EEPROM_UVLO, PowerPanic::NO_PENDING_RECOVERY); + if (eeprom_read_byte((uint8_t*)EEPROM_UVLO) == PowerPanic::PRINT_TYPE_USB) { + recover_print(0); + } else { + const uint8_t btn = lcd_show_fullscreen_message_yes_no_and_wait_P(_T(MSG_RECOVER_PRINT), false); + if ( btn == LCD_LEFT_BUTTON_CHOICE) { + recover_print(0); + } else { // LCD_MIDDLE_BUTTON_CHOICE + eeprom_update_byte((uint8_t*)EEPROM_UVLO, PowerPanic::NO_PENDING_RECOVERY); + } } } } From 47b298782f30b87bd48e4a3c1a3efebd5b523e3a Mon Sep 17 00:00:00 2001 From: 3d-gussner <3d.gussner@gmail.com> Date: Thu, 30 Nov 2023 10:39:43 +0100 Subject: [PATCH 3/3] Set YES as default in Crash Resume message --- Firmware/Marlin_main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 1847b8e62..126b2054f 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -617,7 +617,7 @@ void crashdet_detected(uint8_t mask) // ask whether to resume printing lcd_puts_at_P(0, 1, _T(MSG_RESUME_PRINT)); lcd_putc('?'); - uint8_t yesno = lcd_show_yes_no_and_wait(false); + uint8_t yesno = lcd_show_yes_no_and_wait(false, LCD_LEFT_BUTTON_CHOICE); if (yesno == LCD_LEFT_BUTTON_CHOICE) { enquecommand_P(PSTR("CRASH_RECOVER"));