Browse Source

Save Power Loss Recovery only on move commands

Scott Lahteine 5 years ago
parent
commit
2e5a3b01fd
2 changed files with 13 additions and 6 deletions
  1. 12
    1
      Marlin/src/gcode/gcode.cpp
  2. 1
    5
      Marlin/src/gcode/queue.cpp

+ 12
- 1
Marlin/src/gcode/gcode.cpp View File

@@ -40,6 +40,11 @@ GcodeSuite gcode;
40 40
   #include "../feature/host_actions.h"
41 41
 #endif
42 42
 
43
+#if ENABLED(POWER_LOSS_RECOVERY)
44
+  #include "../sd/cardreader.h"
45
+  #include "../feature/power_loss_recovery.h"
46
+#endif
47
+
43 48
 #include "../Marlin.h" // for idle() and suspend_auto_report
44 49
 
45 50
 millis_t GcodeSuite::previous_move_ms;
@@ -86,8 +91,9 @@ int8_t GcodeSuite::get_target_extruder_from_command() {
86 91
  *  - Set the feedrate, if included
87 92
  */
88 93
 void GcodeSuite::get_destination_from_command() {
94
+  bool seen[XYZE] = { false, false, false, false };
89 95
   LOOP_XYZE(i) {
90
-    if (parser.seen(axis_codes[i])) {
96
+    if ( (seen[i] = parser.seenval(axis_codes[i])) ) {
91 97
       const float v = parser.value_axis_units((AxisEnum)i);
92 98
       destination[i] = (axis_relative_modes[i] || relative_mode)
93 99
         ? current_position[i] + v
@@ -97,6 +103,11 @@ void GcodeSuite::get_destination_from_command() {
97 103
       destination[i] = current_position[i];
98 104
   }
99 105
 
106
+  #if ENABLED(POWER_LOSS_RECOVERY)
107
+    // Only update power loss recovery on moves with E
108
+    if ((seen[E_AXIS] || seen[Z_AXIS]) && IS_SD_PRINTING()) recovery.save();
109
+  #endif
110
+
100 111
   if (parser.linearval('F') > 0)
101 112
     feedrate_mm_s = MMM_TO_MMS(parser.value_feedrate());
102 113
 

+ 1
- 5
Marlin/src/gcode/queue.cpp View File

@@ -868,12 +868,8 @@ void advance_command_queue() {
868 868
           ok_to_send();
869 869
       }
870 870
     }
871
-    else {
871
+    else
872 872
       gcode.process_next_command();
873
-      #if ENABLED(POWER_LOSS_RECOVERY)
874
-        if (IS_SD_PRINTING()) recovery.save();
875
-      #endif
876
-    }
877 873
 
878 874
   #else
879 875
 

Loading…
Cancel
Save