Power-Loss cleanup

This commit is contained in:
Scott Lahteine
2020-11-20 21:25:51 -06:00
parent f8e83f79c5
commit 7e902b7e29
2 changed files with 24 additions and 43 deletions

View File

@@ -180,10 +180,10 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=0*/
// Machine state
info.current_position = current_position;
info.feedrate = uint16_t(feedrate_mm_s * 60.0f);
info.zraise = zraise;
TERN_(HAS_HOME_OFFSET, info.home_offset = home_offset);
TERN_(HAS_POSITION_SHIFT, info.position_shift = position_shift);
info.feedrate = uint16_t(feedrate_mm_s * 60.0f);
#if HAS_MULTI_EXTRUDER
info.active_extruder = active_extruder;
@@ -209,7 +209,7 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=0*/
#endif
#if HAS_LEVELING
info.leveling = planner.leveling_active;
info.flag.leveling = planner.leveling_active;
info.fade = TERN0(ENABLE_LEVELING_FADE_HEIGHT, planner.z_fade_height);
#endif
@@ -220,12 +220,12 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=0*/
info.retract_hop = fwretract.current_hop;
#endif
// Relative axis modes
info.axis_relative = gcode.axis_relative;
// Elapsed print job time
info.print_job_elapsed = print_job_timer.duration();
// Relative axis modes
info.axis_relative = gcode.axis_relative;
// Misc. Marlin flags
info.flag.dryrun = !!(marlin_debug_flags & MARLIN_DEBUG_DRYRUN);
info.flag.allow_cold_extrusion = TERN0(PREVENT_COLD_EXTRUSION, thermalManager.allow_cold_extrude);
@@ -457,8 +457,8 @@ void PrintJobRecovery::resume() {
#if HAS_LEVELING
// Restore leveling state before 'G92 Z' to ensure
// the Z stepper count corresponds to the native Z.
if (info.fade || info.leveling) {
sprintf_P(cmd, PSTR("M420 S%i Z%s"), int(info.leveling), dtostrf(info.fade, 1, 1, str_1));
if (info.fade || info.flag.leveling) {
sprintf_P(cmd, PSTR("M420 S%i Z%s"), int(info.flag.leveling), dtostrf(info.fade, 1, 1, str_1));
gcode.process_subcommands_now(cmd);
}
#endif
@@ -507,15 +507,15 @@ void PrintJobRecovery::resume() {
sprintf_P(cmd, PSTR("G92.9 E%s"), dtostrf(info.current_position.e, 1, 3, str_1));
gcode.process_subcommands_now(cmd);
// Relative axis modes
gcode.axis_relative = info.axis_relative;
TERN_(HAS_HOME_OFFSET, home_offset = info.home_offset);
TERN_(HAS_POSITION_SHIFT, position_shift = info.position_shift);
#if HAS_HOME_OFFSET || HAS_POSITION_SHIFT
LOOP_XYZ(i) update_workspace_offset((AxisEnum)i);
#endif
// Relative axis modes
gcode.axis_relative = info.axis_relative;
#if ENABLED(DEBUG_POWER_LOSS_RECOVERY)
const uint8_t old_flags = marlin_debug_flags;
marlin_debug_flags |= MARLIN_DEBUG_ECHO;
@@ -598,7 +598,7 @@ void PrintJobRecovery::resume() {
#endif
#if HAS_LEVELING
DEBUG_ECHOLNPAIR("leveling: ", int(info.leveling), " fade: ", info.fade);
DEBUG_ECHOLNPAIR("leveling: ", int(info.flag.leveling), " fade: ", info.fade);
#endif
#if ENABLED(FWRETRACT)
DEBUG_ECHOPGM("retract: ");