Skip to content

Commit

Permalink
Improve USb power panic
Browse files Browse the repository at this point in the history
  • Loading branch information
3d-gussner authored and D.R.racer committed Dec 1, 2023
1 parent 4d9dc11 commit d7ed160
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
14 changes: 4 additions & 10 deletions Firmware/Marlin_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4111,6 +4111,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)
{
Expand All @@ -4122,13 +4125,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
{
Expand Down Expand Up @@ -5987,15 +5984,12 @@ SERIAL_PROTOCOLPGM("\n\n");
}
}

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;
Expand Down
2 changes: 2 additions & 0 deletions Firmware/cmdqueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion Firmware/printer_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ enum class PrinterState : uint8_t
HostPrintingFinished = 4,
IsSDPrinting = 5,
IsHostPrinting = 6,
PowerPanicWaitingForHost = 7,
};

PrinterState GetPrinterState();
Expand Down

0 comments on commit d7ed160

Please sign in to comment.