Browse Source

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
Scott Lahteine 6 years ago
parent
commit
a0a5c31c05
No account linked to committer's email address
2 changed files with 6 additions and 3 deletions
  1. 5
    2
      Marlin/src/feature/power_loss_recovery.cpp
  2. 1
    1
      Marlin/src/gcode/gcode.cpp

+ 5
- 2
Marlin/src/feature/power_loss_recovery.cpp View File

125
     millis_t ms = millis();
125
     millis_t ms = millis();
126
   #endif
126
   #endif
127
 
127
 
128
+  // Did Z change since the last call?
129
+  const float zmoved = current_position[Z_AXIS] - info.current_position[Z_AXIS];
130
+
128
   if (force
131
   if (force
129
     #if DISABLED(SAVE_EACH_CMD_MODE)      // Always save state when enabled
132
     #if DISABLED(SAVE_EACH_CMD_MODE)      // Always save state when enabled
130
       #if PIN_EXISTS(POWER_LOSS)          // Save if power loss pin is triggered
133
       #if PIN_EXISTS(POWER_LOSS)          // Save if power loss pin is triggered
133
       #if SAVE_INFO_INTERVAL_MS > 0       // Save if interval is elapsed
136
       #if SAVE_INFO_INTERVAL_MS > 0       // Save if interval is elapsed
134
         || ELAPSED(ms, next_save_ms)
137
         || ELAPSED(ms, next_save_ms)
135
       #endif
138
       #endif
136
-      // Save every time Z is higher than the last call
137
-      || current_position[Z_AXIS] > info.current_position[Z_AXIS]
139
+      || zmoved > 0                       // Z moved up (including Z-hop)
140
+      || zmoved < -5                      // Z moved down a lot (for some reason)
138
     #endif
141
     #endif
139
   ) {
142
   ) {
140
 
143
 

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

105
 
105
 
106
   #if ENABLED(POWER_LOSS_RECOVERY)
106
   #if ENABLED(POWER_LOSS_RECOVERY)
107
     // Only update power loss recovery on moves with E
107
     // Only update power loss recovery on moves with E
108
-    if ((seen[E_AXIS] || seen[Z_AXIS]) && IS_SD_PRINTING()) recovery.save();
108
+    if (seen[E_AXIS] && (seen[X_AXIS] || seen[Y_AXIS]) && IS_SD_PRINTING()) recovery.save();
109
   #endif
109
   #endif
110
 
110
 
111
   if (parser.linearval('F') > 0)
111
   if (parser.linearval('F') > 0)

Loading…
Cancel
Save