Sfoglia il codice sorgente

Merge pull request #3577 from thinkyhead/rc_fix_G92_set_e_twice

Fix G92 setting E twice
Scott Lahteine 9 anni fa
parent
commit
cfd10fcba1
1 ha cambiato i file con 13 aggiunte e 11 eliminazioni
  1. 13
    11
      Marlin/Marlin_main.cpp

+ 13
- 11
Marlin/Marlin_main.cpp Vedi File

@@ -1427,6 +1427,7 @@ inline void sync_plan_position() {
1427 1427
   #endif
1428 1428
   plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1429 1429
 }
1430
+inline void sync_plan_position_e() { plan_set_e_position(current_position[E_AXIS]); }
1430 1431
 inline void set_current_to_destination() { memcpy(current_position, destination, sizeof(current_position)); }
1431 1432
 inline void set_destination_to_current() { memcpy(destination, current_position, sizeof(destination)); }
1432 1433
 
@@ -2320,7 +2321,7 @@ static void homeaxis(AxisEnum axis) {
2320 2321
 
2321 2322
       feedrate = retract_feedrate * 60;
2322 2323
       current_position[E_AXIS] += (swapping ? retract_length_swap : retract_length) / volumetric_multiplier[active_extruder];
2323
-      plan_set_e_position(current_position[E_AXIS]);
2324
+      sync_plan_position_e();
2324 2325
       prepare_move();
2325 2326
 
2326 2327
       if (retract_zlift > 0.01) {
@@ -2348,7 +2349,7 @@ static void homeaxis(AxisEnum axis) {
2348 2349
       feedrate = retract_recover_feedrate * 60;
2349 2350
       float move_e = swapping ? retract_length_swap + retract_recover_length_swap : retract_length + retract_recover_length;
2350 2351
       current_position[E_AXIS] -= move_e / volumetric_multiplier[active_extruder];
2351
-      plan_set_e_position(current_position[E_AXIS]);
2352
+      sync_plan_position_e();
2352 2353
       prepare_move();
2353 2354
     }
2354 2355
 
@@ -2439,7 +2440,7 @@ inline void gcode_G0_G1() {
2439 2440
         // Is this move an attempt to retract or recover?
2440 2441
         if ((echange < -MIN_RETRACT && !retracted[active_extruder]) || (echange > MIN_RETRACT && retracted[active_extruder])) {
2441 2442
           current_position[E_AXIS] = destination[E_AXIS]; // hide the slicer-generated retract/recover from calculations
2442
-          plan_set_e_position(current_position[E_AXIS]);  // AND from the planner
2443
+          sync_plan_position_e();  // AND from the planner
2443 2444
           retract(!retracted[active_extruder]);
2444 2445
           return;
2445 2446
         }
@@ -3642,8 +3643,9 @@ inline void gcode_G28() {
3642 3643
  * G92: Set current position to given X Y Z E
3643 3644
  */
3644 3645
 inline void gcode_G92() {
3645
-  if (!code_seen(axis_codes[E_AXIS]))
3646
-    st_synchronize();
3646
+  bool didE = code_seen(axis_codes[E_AXIS]);
3647
+
3648
+  if (!didE) st_synchronize();
3647 3649
 
3648 3650
   bool didXYZ = false;
3649 3651
   for (int i = 0; i < NUM_AXIS; i++) {
@@ -3653,14 +3655,11 @@ inline void gcode_G92() {
3653 3655
 
3654 3656
       current_position[i] = v;
3655 3657
 
3656
-      if (i == E_AXIS)
3657
-        plan_set_e_position(v);
3658
-      else {
3658
+      if (i != E_AXIS) {
3659 3659
         position_shift[i] += v - p; // Offset the coordinate space
3660 3660
         update_software_endstops((AxisEnum)i);
3661
-		  
3662 3661
         didXYZ = true;
3663
-	  }
3662
+      }
3664 3663
     }
3665 3664
   }
3666 3665
   if (didXYZ) {
@@ -3670,6 +3669,9 @@ inline void gcode_G92() {
3670 3669
       sync_plan_position();
3671 3670
     #endif
3672 3671
   }
3672
+  else if (didE) {
3673
+    sync_plan_position_e();
3674
+  }
3673 3675
 }
3674 3676
 
3675 3677
 #if ENABLED(ULTIPANEL)
@@ -6106,7 +6108,7 @@ inline void gcode_M503() {
6106 6108
     #endif
6107 6109
 
6108 6110
     current_position[E_AXIS] = destination[E_AXIS]; //the long retract of L is compensated by manual filament feeding
6109
-    plan_set_e_position(current_position[E_AXIS]);
6111
+    sync_plan_position_e();
6110 6112
 
6111 6113
     RUNPLAN; //should do nothing
6112 6114
 

Loading…
Annulla
Salva