From 2e5a3b01fd7e6a5510f0f0251d0a9cc0f63c79fb Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 5 Mar 2019 01:47:06 -0600 Subject: [PATCH] Save Power Loss Recovery only on move commands --- Marlin/src/gcode/gcode.cpp | 13 ++++++++++++- Marlin/src/gcode/queue.cpp | 6 +----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index c9a699517..91d91df92 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -40,6 +40,11 @@ GcodeSuite gcode; #include "../feature/host_actions.h" #endif +#if ENABLED(POWER_LOSS_RECOVERY) + #include "../sd/cardreader.h" + #include "../feature/power_loss_recovery.h" +#endif + #include "../Marlin.h" // for idle() and suspend_auto_report millis_t GcodeSuite::previous_move_ms; @@ -86,8 +91,9 @@ int8_t GcodeSuite::get_target_extruder_from_command() { * - Set the feedrate, if included */ void GcodeSuite::get_destination_from_command() { + bool seen[XYZE] = { false, false, false, false }; LOOP_XYZE(i) { - if (parser.seen(axis_codes[i])) { + if ( (seen[i] = parser.seenval(axis_codes[i])) ) { const float v = parser.value_axis_units((AxisEnum)i); destination[i] = (axis_relative_modes[i] || relative_mode) ? current_position[i] + v @@ -97,6 +103,11 @@ void GcodeSuite::get_destination_from_command() { destination[i] = current_position[i]; } + #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(); + #endif + if (parser.linearval('F') > 0) feedrate_mm_s = MMM_TO_MMS(parser.value_feedrate()); diff --git a/Marlin/src/gcode/queue.cpp b/Marlin/src/gcode/queue.cpp index eb7f6a74c..161c3a4d0 100644 --- a/Marlin/src/gcode/queue.cpp +++ b/Marlin/src/gcode/queue.cpp @@ -868,12 +868,8 @@ void advance_command_queue() { ok_to_send(); } } - else { + else gcode.process_next_command(); - #if ENABLED(POWER_LOSS_RECOVERY) - if (IS_SD_PRINTING()) recovery.save(); - #endif - } #else