Browse Source

Fix G92 so it only sets the plan position once

Scott Lahteine 9 years ago
parent
commit
c7df961144
1 changed files with 9 additions and 7 deletions
  1. 9
    7
      Marlin/Marlin_main.cpp

+ 9
- 7
Marlin/Marlin_main.cpp View 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
 
@@ -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)

Loading…
Cancel
Save