Browse Source

Apply fix for M600 filament change

- Patch from #1453 for delta movement plan
- Fix: Set X with code X instead of adding to X
Scott Lahteine 9 years ago
parent
commit
b97a950f53
1 changed files with 29 additions and 19 deletions
  1. 29
    19
      Marlin/Marlin_main.cpp

+ 29
- 19
Marlin/Marlin_main.cpp View File

@@ -3598,16 +3598,17 @@ case 404:  //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
3598 3598
     #ifdef FILAMENTCHANGEENABLE
3599 3599
     case 600: //Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal]
3600 3600
     {
3601
-        float target[4];
3602
-        float lastpos[4];
3603
-        target[X_AXIS]=current_position[X_AXIS];
3604
-        target[Y_AXIS]=current_position[Y_AXIS];
3605
-        target[Z_AXIS]=current_position[Z_AXIS];
3606
-        target[E_AXIS]=current_position[E_AXIS];
3607
-        lastpos[X_AXIS]=current_position[X_AXIS];
3608
-        lastpos[Y_AXIS]=current_position[Y_AXIS];
3609
-        lastpos[Z_AXIS]=current_position[Z_AXIS];
3610
-        lastpos[E_AXIS]=current_position[E_AXIS];
3601
+        float target[NUM_AXIS], lastpos[NUM_AXIS], fr60 = feedrate/60;
3602
+        for (int i=0; i<NUM_AXIS; i++)
3603
+          target[i] = lastpos[i] = current_position[i];
3604
+
3605
+        #define BASICPLAN plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], fr60, active_extruder);
3606
+        #ifdef DELTA
3607
+          #define RUNPLAN calculate_delta(target); BASICPLAN
3608
+        #else
3609
+          #define RUNPLAN BASICPLAN
3610
+        #endif
3611
+
3611 3612
         //retract by E
3612 3613
         if(code_seen('E'))
3613 3614
         {
@@ -3619,7 +3620,7 @@ case 404:  //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
3619 3620
             target[E_AXIS]+= FILAMENTCHANGE_FIRSTRETRACT ;
3620 3621
           #endif
3621 3622
         }
3622
-        plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder);
3623
+        RUNPLAN;
3623 3624
 
3624 3625
         //lift Z
3625 3626
         if(code_seen('Z'))
@@ -3632,12 +3633,12 @@ case 404:  //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
3632 3633
             target[Z_AXIS]+= FILAMENTCHANGE_ZADD ;
3633 3634
           #endif
3634 3635
         }
3635
-        plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder);
3636
+        RUNPLAN;
3636 3637
 
3637 3638
         //move xy
3638 3639
         if(code_seen('X'))
3639 3640
         {
3640
-          target[X_AXIS]+= code_value();
3641
+          target[X_AXIS]= code_value();
3641 3642
         }
3642 3643
         else
3643 3644
         {
@@ -3656,7 +3657,7 @@ case 404:  //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
3656 3657
           #endif
3657 3658
         }
3658 3659
 
3659
-        plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder);
3660
+        RUNPLAN;
3660 3661
 
3661 3662
         if(code_seen('L'))
3662 3663
         {
@@ -3669,7 +3670,7 @@ case 404:  //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
3669 3670
           #endif
3670 3671
         }
3671 3672
 
3672
-        plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder);
3673
+        RUNPLAN;
3673 3674
 
3674 3675
         //finish moves
3675 3676
         st_synchronize();
@@ -3717,10 +3718,19 @@ case 404:  //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
3717 3718
         }
3718 3719
         current_position[E_AXIS]=target[E_AXIS]; //the long retract of L is compensated by manual filament feeding
3719 3720
         plan_set_e_position(current_position[E_AXIS]);
3720
-        plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder); //should do nothing
3721
-        plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], target[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder); //move xy back
3722
-        plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], lastpos[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder); //move z back
3723
-        plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], lastpos[Z_AXIS], lastpos[E_AXIS], feedrate/60, active_extruder); //final untretract
3721
+
3722
+        RUNPLAN; //should do nothing
3723
+
3724
+        #ifdef DELTA
3725
+          calculate_delta(lastpos);
3726
+          plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], target[E_AXIS], fr60, active_extruder); //move xyz back
3727
+          plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], lastpos[E_AXIS], fr60, active_extruder); //final untretract
3728
+        #else
3729
+          plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], fr60, active_extruder); //should do nothing
3730
+          plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], target[Z_AXIS], target[E_AXIS], fr60, active_extruder); //move xy back
3731
+          plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], lastpos[Z_AXIS], target[E_AXIS], fr60, active_extruder); //move z back
3732
+          plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], lastpos[Z_AXIS], lastpos[E_AXIS], fr60, active_extruder); //final untretract
3733
+        #endif
3724 3734
     }
3725 3735
     break;
3726 3736
     #endif //FILAMENTCHANGEENABLE

Loading…
Cancel
Save