Browse Source

Fix position sync in M600 pause/resume

studiodyne 6 years ago
parent
commit
8181220bfd
1 changed files with 20 additions and 31 deletions
  1. 20
    31
      Marlin/src/feature/pause.cpp

+ 20
- 31
Marlin/src/feature/pause.cpp View File

93
   }
93
   }
94
 }
94
 }
95
 
95
 
96
+void do_pause_e_move(const float &length, const float fr) {
97
+  current_position[E_AXIS] += length;
98
+  set_destination_from_current();
99
+  #if IS_KINEMATIC
100
+    planner.buffer_line_kinematic(destination, fr, active_extruder);
101
+  #else
102
+    line_to_destination(fr);
103
+  #endif
104
+  stepper.synchronize();
105
+}
106
+
96
 // public:
107
 // public:
97
 
108
 
98
 bool move_away_flag = false;
109
 bool move_away_flag = false;
99
 
110
 
100
-#if IS_KINEMATIC
101
-  #define RUNPLAN(RATE_MM_S) planner.buffer_line_kinematic(destination, RATE_MM_S, active_extruder)
102
-#else
103
-  #define RUNPLAN(RATE_MM_S) line_to_destination(RATE_MM_S)
104
-#endif
105
-
106
 bool pause_print(const float &retract, const float &z_lift, const float &x_pos, const float &y_pos,
111
 bool pause_print(const float &retract, const float &z_lift, const float &x_pos, const float &y_pos,
107
                         const float &unload_length/*=0*/ , const int8_t max_beep_count/*=0*/, const bool show_lcd/*=false*/
112
                         const float &unload_length/*=0*/ , const int8_t max_beep_count/*=0*/, const bool show_lcd/*=false*/
108
 ) {
113
 ) {
140
     #endif
145
     #endif
141
   }
146
   }
142
 
147
 
143
-  // Save current position
144
   stepper.synchronize();
148
   stepper.synchronize();
145
-  COPY(resume_position, current_position);
146
-
147
-  if (retract) {
148
-    // Initial retract before move to filament change position
149
-    set_destination_from_current();
150
-    destination[E_AXIS] += retract;
151
-    RUNPLAN(PAUSE_PARK_RETRACT_FEEDRATE);
152
-    stepper.synchronize();
153
-  }
149
+  COPY(resume_position, current_position); // Save current position for later
150
+
151
+  // Initial retract before move to filament change position
152
+  if (retract) do_pause_e_move(retract, PAUSE_PARK_RETRACT_FEEDRATE);
154
 
153
 
155
   // Lift Z axis
154
   // Lift Z axis
156
   if (z_lift > 0)
155
   if (z_lift > 0)
168
     }
167
     }
169
 
168
 
170
     // Unload filament
169
     // Unload filament
171
-    set_destination_from_current();
172
-    destination[E_AXIS] += unload_length;
173
-    RUNPLAN(FILAMENT_CHANGE_UNLOAD_FEEDRATE);
174
-    stepper.synchronize();
170
+    do_pause_e_move(unload_length, FILAMENT_CHANGE_UNLOAD_FEEDRATE);
175
   }
171
   }
176
 
172
 
177
   if (show_lcd) {
173
   if (show_lcd) {
272
     filament_change_beep(max_beep_count, true);
268
     filament_change_beep(max_beep_count, true);
273
   #endif
269
   #endif
274
 
270
 
275
-  set_destination_from_current();
276
-
277
   if (load_length != 0) {
271
   if (load_length != 0) {
278
     #if ENABLED(ULTIPANEL)
272
     #if ENABLED(ULTIPANEL)
279
       // Show "insert filament"
273
       // Show "insert filament"
297
     #endif
291
     #endif
298
 
292
 
299
     // Load filament
293
     // Load filament
300
-    destination[E_AXIS] += load_length;
301
-    RUNPLAN(FILAMENT_CHANGE_LOAD_FEEDRATE);
302
-    stepper.synchronize();
294
+    do_pause_e_move(load_length, FILAMENT_CHANGE_LOAD_FEEDRATE);
303
   }
295
   }
304
 
296
 
305
   #if ENABLED(ULTIPANEL) && ADVANCED_PAUSE_EXTRUDE_LENGTH > 0
297
   #if ENABLED(ULTIPANEL) && ADVANCED_PAUSE_EXTRUDE_LENGTH > 0
312
         lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_EXTRUDE);
304
         lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_EXTRUDE);
313
 
305
 
314
         // Extrude filament to get into hotend
306
         // Extrude filament to get into hotend
315
-        destination[E_AXIS] += extrude_length;
316
-        RUNPLAN(ADVANCED_PAUSE_EXTRUDE_FEEDRATE);
317
-        stepper.synchronize();
307
+        do_pause_e_move(extrude_length, ADVANCED_PAUSE_EXTRUDE_FEEDRATE);
318
       }
308
       }
319
 
309
 
320
       // Show "Extrude More" / "Resume" menu and wait for reply
310
       // Show "Extrude More" / "Resume" menu and wait for reply
337
   #endif
327
   #endif
338
 
328
 
339
   // Set extruder to saved position
329
   // Set extruder to saved position
340
-  destination[E_AXIS] = current_position[E_AXIS] = resume_position[E_AXIS];
341
-  planner.set_e_position_mm(current_position[E_AXIS]);
330
+  planner.set_e_position_mm((current_position[E_AXIS] = resume_position[E_AXIS]));
342
 
331
 
343
   // Move XY to starting position, then Z
332
   // Move XY to starting position, then Z
344
   do_blocking_move_to_xy(resume_position[X_AXIS], resume_position[Y_AXIS], PAUSE_PARK_XY_FEEDRATE);
333
   do_blocking_move_to_xy(resume_position[X_AXIS], resume_position[Y_AXIS], PAUSE_PARK_XY_FEEDRATE);
349
   #endif
338
   #endif
350
 
339
 
351
   #if ENABLED(ULTIPANEL)
340
   #if ENABLED(ULTIPANEL)
352
-    // Show status screen
341
+    // Show pause status screen
353
     lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_STATUS);
342
     lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_STATUS);
354
   #endif
343
   #endif
355
 
344
 

Loading…
Cancel
Save