From a0a5c31c055419f11775918f4566917bc4f223f1 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 1 Apr 2019 17:52:45 -0500 Subject: [PATCH] Power-Loss initialization fix (#13553) - Only save to PLR file on moves with E and X or Y - Save to PLR after any long-ish Z downward move --- Marlin/src/feature/power_loss_recovery.cpp | 7 +++++-- Marlin/src/gcode/gcode.cpp | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Marlin/src/feature/power_loss_recovery.cpp b/Marlin/src/feature/power_loss_recovery.cpp index 1154b941e..a16218c29 100644 --- a/Marlin/src/feature/power_loss_recovery.cpp +++ b/Marlin/src/feature/power_loss_recovery.cpp @@ -125,6 +125,9 @@ void PrintJobRecovery::save(const bool force/*=false*/, const bool save_queue/*= millis_t ms = millis(); #endif + // Did Z change since the last call? + const float zmoved = current_position[Z_AXIS] - info.current_position[Z_AXIS]; + if (force #if DISABLED(SAVE_EACH_CMD_MODE) // Always save state when enabled #if PIN_EXISTS(POWER_LOSS) // Save if power loss pin is triggered @@ -133,8 +136,8 @@ void PrintJobRecovery::save(const bool force/*=false*/, const bool save_queue/*= #if SAVE_INFO_INTERVAL_MS > 0 // Save if interval is elapsed || ELAPSED(ms, next_save_ms) #endif - // Save every time Z is higher than the last call - || current_position[Z_AXIS] > info.current_position[Z_AXIS] + || zmoved > 0 // Z moved up (including Z-hop) + || zmoved < -5 // Z moved down a lot (for some reason) #endif ) { diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index dc40a4a88..c8d813177 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -105,7 +105,7 @@ void GcodeSuite::get_destination_from_command() { #if ENABLED(POWER_LOSS_RECOVERY) // Only update power loss recovery on moves with E - if ((seen[E_AXIS] || seen[Z_AXIS]) && IS_SD_PRINTING()) recovery.save(); + if (seen[E_AXIS] && (seen[X_AXIS] || seen[Y_AXIS]) && IS_SD_PRINTING()) recovery.save(); #endif if (parser.linearval('F') > 0)