Skip to content

Commit

Permalink
Preheat before Power Loss Recovery homing (MarlinFirmware#20697)
Browse files Browse the repository at this point in the history
  • Loading branch information
Java authored and kpishere committed Feb 19, 2021
1 parent 2ec2d0c commit 4a09ceb
Showing 1 changed file with 27 additions and 36 deletions.
63 changes: 27 additions & 36 deletions Marlin/src/feature/powerloss.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,30 @@ void PrintJobRecovery::resume() {
gcode.process_subcommands_now_P(PSTR("M420 S0 Z0"));
#endif

#if HAS_HEATED_BED
const int16_t bt = info.target_temperature_bed;
if (bt) {
// Restore the bed temperature
sprintf_P(cmd, PSTR("M190 S%i"), bt);
gcode.process_subcommands_now(cmd);
}
#endif

// Restore all hotend temperatures
#if HAS_HOTEND
HOTEND_LOOP() {
const int16_t et = info.target_temperature[e];
if (et) {
#if HAS_MULTI_HOTEND
sprintf_P(cmd, PSTR("T%i S"), e);
gcode.process_subcommands_now(cmd);
#endif
sprintf_P(cmd, PSTR("M109 S%i"), et);
gcode.process_subcommands_now(cmd);
}
}
#endif

// Reset E, raise Z, home XY...
#if Z_HOME_DIR > 0

Expand All @@ -353,20 +377,11 @@ void PrintJobRecovery::resume() {

#else // "G92.9 E0 ..."

// Set Z to 0, raise Z by info.zraise, and Home (XY only for Cartesian)
// with no raise. (Only do simulated homing in Marlin Dev Mode.)

sprintf_P(cmd, PSTR("G92.9 E0 "
#if ENABLED(BACKUP_POWER_SUPPLY)
"Z%s" // Z was already raised at outage
#else
"Z0\nG1Z%s" // Set Z=0 and Raise Z now
#endif
),
dtostrf(info.zraise, 1, 3, str_1)
);
// If a Z raise occurred at outage restore Z, otherwise raise Z now
sprintf_P(cmd, PSTR("G92.9 E0 " TERN(BACKUP_POWER_SUPPLY, "Z%s", "Z0\nG1Z%s")), dtostrf(info.zraise, 1, 3, str_1));
gcode.process_subcommands_now(cmd);

// Home safely with no Z raise
gcode.process_subcommands_now_P(PSTR(
"G28R0" // No raise during G28
#if IS_CARTESIAN && DISABLED(POWER_LOSS_RECOVER_ZHOME)
Expand Down Expand Up @@ -404,30 +419,6 @@ void PrintJobRecovery::resume() {
#endif
#endif

#if HAS_HEATED_BED
const int16_t bt = info.target_temperature_bed;
if (bt) {
// Restore the bed temperature
sprintf_P(cmd, PSTR("M190 S%i"), bt);
gcode.process_subcommands_now(cmd);
}
#endif

// Restore all hotend temperatures
#if HAS_HOTEND
HOTEND_LOOP() {
const int16_t et = info.target_temperature[e];
if (et) {
#if HAS_MULTI_HOTEND
sprintf_P(cmd, PSTR("T%i S"), e);
gcode.process_subcommands_now(cmd);
#endif
sprintf_P(cmd, PSTR("M109 S%i"), et);
gcode.process_subcommands_now(cmd);
}
}
#endif

// Select the previously active tool (with no_move)
#if HAS_MULTI_EXTRUDER
sprintf_P(cmd, PSTR("T%i S"), info.active_extruder);
Expand Down

0 comments on commit 4a09ceb

Please sign in to comment.