Save Power Loss Recovery only on move commands

This commit is contained in:
Scott Lahteine 2019-03-05 01:47:06 -06:00
parent 15738ea506
commit 2e5a3b01fd
2 changed files with 13 additions and 6 deletions

View file

@ -40,6 +40,11 @@ GcodeSuite gcode;
#include "../feature/host_actions.h" #include "../feature/host_actions.h"
#endif #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 #include "../Marlin.h" // for idle() and suspend_auto_report
millis_t GcodeSuite::previous_move_ms; millis_t GcodeSuite::previous_move_ms;
@ -86,8 +91,9 @@ int8_t GcodeSuite::get_target_extruder_from_command() {
* - Set the feedrate, if included * - Set the feedrate, if included
*/ */
void GcodeSuite::get_destination_from_command() { void GcodeSuite::get_destination_from_command() {
bool seen[XYZE] = { false, false, false, false };
LOOP_XYZE(i) { 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); const float v = parser.value_axis_units((AxisEnum)i);
destination[i] = (axis_relative_modes[i] || relative_mode) destination[i] = (axis_relative_modes[i] || relative_mode)
? current_position[i] + v ? current_position[i] + v
@ -97,6 +103,11 @@ void GcodeSuite::get_destination_from_command() {
destination[i] = current_position[i]; 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) if (parser.linearval('F') > 0)
feedrate_mm_s = MMM_TO_MMS(parser.value_feedrate()); feedrate_mm_s = MMM_TO_MMS(parser.value_feedrate());

View file

@ -868,12 +868,8 @@ void advance_command_queue() {
ok_to_send(); ok_to_send();
} }
} }
else { else
gcode.process_next_command(); gcode.process_next_command();
#if ENABLED(POWER_LOSS_RECOVERY)
if (IS_SD_PRINTING()) recovery.save();
#endif
}
#else #else