diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 430679b49..85a03f04e 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -4112,6 +4112,20 @@ void process_commands() // M24 - Start SD print enquecommand_P(MSG_M24); } + else if (eeprom_read_byte((uint8_t*)EEPROM_UVLO_PRINT_TYPE) == PowerPanic::PRINT_TYPE_USB) + { + // For Host prints we need to start the timer so that the pause has any effect + // this will allow g-codes to be processed while in the paused state + // For SD prints, M24 starts the timer + print_job_timer.start(); + + // 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); @@ -5972,6 +5986,18 @@ Sigma_Exit: SetHostStatusScreenName(str.GetUnquotedString()); } } + + if (GetPrinterState() == PrinterState::PowerPanicWaitingForHost && 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/messages.cpp b/Firmware/messages.cpp index 39e5c1081..d264887e1 100644 --- a/Firmware/messages.cpp +++ b/Firmware/messages.cpp @@ -233,6 +233,7 @@ const char MSG_OCTOPRINT_CANCEL[] PROGMEM_N1 = "// action:cancel"; //// const char MSG_OCTOPRINT_READY[] PROGMEM_N1 = "// action:ready"; //// const char MSG_OCTOPRINT_NOT_READY[] PROGMEM_N1 = "// action:not_ready"; //// const char MSG_OCTOPRINT_START[] PROGMEM_N1 = "// action:start"; //// +const char MSG_OCTOPRINT_UVLO_RECOVERY_READY[] PROGMEM_N1 = "// action:uvlo_recovery_ready"; //// const char MSG_FANCHECK_HOTEND[] PROGMEM_N1 = "Err:HOTEND FAN ERROR"; ////c=20 const char MSG_FANCHECK_PRINT[] PROGMEM_N1 = "Err:PRINT FAN ERROR"; ////c=20 const char MSG_M112_KILL[] PROGMEM_N1 = "M112 called. Emergency Stop."; ////c=20 diff --git a/Firmware/messages.h b/Firmware/messages.h index 9d8423fdc..c04672ddf 100644 --- a/Firmware/messages.h +++ b/Firmware/messages.h @@ -237,6 +237,7 @@ extern const char MSG_OCTOPRINT_CANCEL[]; extern const char MSG_OCTOPRINT_READY[]; extern const char MSG_OCTOPRINT_NOT_READY[]; extern const char MSG_OCTOPRINT_START[]; +extern const char MSG_OCTOPRINT_UVLO_RECOVERY_READY[]; extern const char MSG_FANCHECK_HOTEND[]; extern const char MSG_FANCHECK_PRINT[]; extern const char MSG_M112_KILL[]; diff --git a/Firmware/printer_state.h b/Firmware/printer_state.h index 22b9fe5bd..a88d36f4a 100644 --- a/Firmware/printer_state.h +++ b/Firmware/printer_state.h @@ -23,6 +23,7 @@ enum class PrinterState : uint8_t HostPrintingFinished = 4, IsSDPrinting = 5, IsHostPrinting = 6, + PowerPanicWaitingForHost = 7, }; PrinterState GetPrinterState();