Browse Source

Merge pull request #8073 from thinkyhead/bf1_fix_M600

[1.1.x] Fix position sync in M600 pause/resume
Scott Lahteine 7 years ago
parent
commit
3235beef6d
1 changed files with 22 additions and 23 deletions
  1. 22
    23
      Marlin/Marlin_main.cpp

+ 22
- 23
Marlin/Marlin_main.cpp View File

6157
   enable_all_steppers();
6157
   enable_all_steppers();
6158
 }
6158
 }
6159
 
6159
 
6160
-#if IS_KINEMATIC
6161
-  #define RUNPLAN(RATE_MM_S) planner.buffer_line_kinematic(destination, RATE_MM_S, active_extruder)
6162
-#else
6163
-  #define RUNPLAN(RATE_MM_S) line_to_destination(RATE_MM_S)
6164
-#endif
6165
-
6166
 #if ENABLED(ADVANCED_PAUSE_FEATURE)
6160
 #if ENABLED(ADVANCED_PAUSE_FEATURE)
6167
 
6161
 
6168
   static float resume_position[XYZE];
6162
   static float resume_position[XYZE];
6206
     }
6200
     }
6207
   }
6201
   }
6208
 
6202
 
6203
+  #if IS_KINEMATIC
6204
+    #define RUNPLAN(RATE_MM_S) planner.buffer_line_kinematic(destination, RATE_MM_S, active_extruder)
6205
+  #else
6206
+    #define RUNPLAN(RATE_MM_S) line_to_destination(RATE_MM_S)
6207
+  #endif
6208
+
6209
+  void do_pause_e_move(const float &length, const float fr) {
6210
+    current_position[E_AXIS] += length;
6211
+    set_destination_from_current();
6212
+    #if IS_KINEMATIC
6213
+      planner.buffer_line_kinematic(destination, fr, active_extruder);
6214
+    #else
6215
+      line_to_destination(fr);
6216
+    #endif
6217
+    stepper.synchronize();
6218
+  }
6219
+
6209
   static bool pause_print(const float &retract, const float &z_lift, const float &x_pos, const float &y_pos,
6220
   static bool pause_print(const float &retract, const float &z_lift, const float &x_pos, const float &y_pos,
6210
                           const float &unload_length = 0 , const int8_t max_beep_count = 0, const bool show_lcd = false
6221
                           const float &unload_length = 0 , const int8_t max_beep_count = 0, const bool show_lcd = false
6211
   ) {
6222
   ) {
6247
     stepper.synchronize();
6258
     stepper.synchronize();
6248
     COPY(resume_position, current_position);
6259
     COPY(resume_position, current_position);
6249
 
6260
 
6250
-    if (retract) {
6251
-      // Initial retract before move to filament change position
6252
-      set_destination_from_current();
6253
-      destination[E_AXIS] += retract;
6254
-      RUNPLAN(PAUSE_PARK_RETRACT_FEEDRATE);
6255
-      stepper.synchronize();
6256
-    }
6261
+    // Initial retract before move to filament change position
6262
+    if (retract) do_pause_e_move(retract, PAUSE_PARK_RETRACT_FEEDRATE);
6257
 
6263
 
6258
     // Lift Z axis
6264
     // Lift Z axis
6259
     if (z_lift > 0)
6265
     if (z_lift > 0)
6271
       }
6277
       }
6272
 
6278
 
6273
       // Unload filament
6279
       // Unload filament
6274
-      set_destination_from_current();
6275
-      destination[E_AXIS] += unload_length;
6276
-      RUNPLAN(FILAMENT_CHANGE_UNLOAD_FEEDRATE);
6277
-      stepper.synchronize();
6280
+      do_pause_e_move(unload_length, FILAMENT_CHANGE_UNLOAD_FEEDRATE);
6278
     }
6281
     }
6279
 
6282
 
6280
     if (show_lcd) {
6283
     if (show_lcd) {
6400
       #endif
6403
       #endif
6401
 
6404
 
6402
       // Load filament
6405
       // Load filament
6403
-      destination[E_AXIS] += load_length;
6404
-      RUNPLAN(FILAMENT_CHANGE_LOAD_FEEDRATE);
6405
-      stepper.synchronize();
6406
+      do_pause_e_move(load_length, FILAMENT_CHANGE_LOAD_FEEDRATE);
6406
     }
6407
     }
6407
 
6408
 
6408
     #if ENABLED(ULTIPANEL) && ADVANCED_PAUSE_EXTRUDE_LENGTH > 0
6409
     #if ENABLED(ULTIPANEL) && ADVANCED_PAUSE_EXTRUDE_LENGTH > 0
6415
           lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_EXTRUDE);
6416
           lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_EXTRUDE);
6416
 
6417
 
6417
           // Extrude filament to get into hotend
6418
           // Extrude filament to get into hotend
6418
-          destination[E_AXIS] += extrude_length;
6419
-          RUNPLAN(ADVANCED_PAUSE_EXTRUDE_FEEDRATE);
6420
-          stepper.synchronize();
6419
+          do_pause_e_move(extrude_length, ADVANCED_PAUSE_EXTRUDE_FEEDRATE);
6421
         }
6420
         }
6422
 
6421
 
6423
         // Show "Extrude More" / "Resume" menu and wait for reply
6422
         // Show "Extrude More" / "Resume" menu and wait for reply

Loading…
Cancel
Save