power panic: improve file position recovery

- Only queue M26 for SD prints
- Add M110 to set gcode_LastN for host prints
- Remove one debug log to save resource (52 bytes)

Change in memory:
Flash: -14 bytes
SRAM: 0 bytes
This commit is contained in:
gudnimg 2023-11-25 15:32:11 +00:00 committed by DRracer
parent 665c01804c
commit 67c7ad1c99
1 changed files with 13 additions and 8 deletions

View File

@ -462,17 +462,11 @@ void restore_print_from_eeprom(bool mbl_was_active) {
SERIAL_ECHOPGM(", feedmultiply:");
MYSERIAL.println(feedmultiply_rec);
if (eeprom_read_byte((uint8_t*)EEPROM_UVLO_PRINT_TYPE) == PowerPanic::PRINT_TYPE_SD)
{ // M23
restore_file_from_sd();
}
// SD: Position in file, USB: g-code line number
uint32_t position = eeprom_read_dword((uint32_t*)(EEPROM_FILE_POSITION));
SERIAL_ECHOPGM("Position read from eeprom:");
MYSERIAL.println(position);
// Move to the XY print position in logical coordinates, where the print has been killed, but
// without shifting Z along the way. This requires performing the move without mbl.
float pos_x = eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION + 0));
@ -508,8 +502,19 @@ void restore_print_from_eeprom(bool mbl_was_active) {
// Set the fan speed saved at the power panic.
enquecommandf_P(PSTR("M106 S%u"), fan_speed_rec);
// Set a position in the file.
enquecommandf_P(PSTR("M26 S%lu"), position);
// SD: Position in file, USB: g-code line number
uint32_t position = eeprom_read_dword((uint32_t*)(EEPROM_FILE_POSITION));
if (eeprom_read_byte((uint8_t*)EEPROM_UVLO_PRINT_TYPE) == PowerPanic::PRINT_TYPE_SD)
{
// Set a position in the file.
enquecommandf_P(PSTR("M26 S%lu"), position);
}
else if (eeprom_read_byte((uint8_t*)EEPROM_UVLO_PRINT_TYPE) == PowerPanic::PRINT_TYPE_USB)
{
// Set line number
enquecommandf_P(PSTR("M110 N%lu"), position);
}
enquecommand_P(PSTR("G4 S0"));
enquecommand_P(PSTR("PRUSA uvlo"));
}