Browse Source

Fix bad movement in gcode_T when switching

Scott Lahteine 8 years ago
parent
commit
d698c89971
1 changed files with 13 additions and 21 deletions
  1. 13
    21
      Marlin/Marlin_main.cpp

+ 13
- 21
Marlin/Marlin_main.cpp View File

1272
  */
1272
  */
1273
 static void update_software_endstops(AxisEnum axis) {
1273
 static void update_software_endstops(AxisEnum axis) {
1274
   float offs = home_offset[axis] + position_shift[axis];
1274
   float offs = home_offset[axis] + position_shift[axis];
1275
+
1275
   #if ENABLED(DUAL_X_CARRIAGE)
1276
   #if ENABLED(DUAL_X_CARRIAGE)
1276
     if (axis == X_AXIS) {
1277
     if (axis == X_AXIS) {
1277
       float dual_max_x = max(extruder_offset[X_AXIS][1], X2_MAX_POS);
1278
       float dual_max_x = max(extruder_offset[X_AXIS][1], X2_MAX_POS);
1292
     sw_endstop_min[axis] = base_min_pos(axis) + offs;
1293
     sw_endstop_min[axis] = base_min_pos(axis) + offs;
1293
     sw_endstop_max[axis] = base_max_pos(axis) + offs;
1294
     sw_endstop_max[axis] = base_max_pos(axis) + offs;
1294
   }
1295
   }
1296
+
1295
 }
1297
 }
1296
 
1298
 
1297
 /**
1299
 /**
6472
 
6474
 
6473
         #else // !AUTO_BED_LEVELING_FEATURE
6475
         #else // !AUTO_BED_LEVELING_FEATURE
6474
 
6476
 
6475
-          // Offset extruder (only by XY)
6476
-          for (int i=X_AXIS; i<=Y_AXIS; i++)
6477
-            current_position[i] += extruder_offset[i][tmp_extruder] - extruder_offset[i][active_extruder];
6477
+          // The newly-selected extruder is actually at...
6478
+          for (int i=X_AXIS; i<=Y_AXIS; i++) {
6479
+            float diff = extruder_offset[i][tmp_extruder] - extruder_offset[i][active_extruder];
6480
+            current_position[i] += diff;
6481
+            position_shift[i] += diff; // Offset the coordinate space
6482
+            update_software_endstops((AxisEnum)i);
6483
+          }
6478
 
6484
 
6479
         #endif // !AUTO_BED_LEVELING_FEATURE
6485
         #endif // !AUTO_BED_LEVELING_FEATURE
6480
 
6486
 
6481
-        // Set the new active extruder and position
6487
+        // Set the new active extruder
6482
         active_extruder = tmp_extruder;
6488
         active_extruder = tmp_extruder;
6483
 
6489
 
6484
       #endif // !DUAL_X_CARRIAGE
6490
       #endif // !DUAL_X_CARRIAGE
6485
 
6491
 
6492
+      // Tell the planner the new "current position"
6486
       #if ENABLED(DELTA)
6493
       #if ENABLED(DELTA)
6487
         sync_plan_position_delta();
6494
         sync_plan_position_delta();
6488
       #else
6495
       #else
6489
         sync_plan_position();
6496
         sync_plan_position();
6490
       #endif
6497
       #endif
6491
 
6498
 
6492
-      // Move to the old position
6499
+      // Move to the "old position" (move the extruder into place)
6493
       if (IsRunning()) prepare_move();
6500
       if (IsRunning()) prepare_move();
6494
 
6501
 
6495
     } // (tmp_extruder != active_extruder)
6502
     } // (tmp_extruder != active_extruder)
7187
   if (min_software_endstops) {
7194
   if (min_software_endstops) {
7188
     NOLESS(target[X_AXIS], sw_endstop_min[X_AXIS]);
7195
     NOLESS(target[X_AXIS], sw_endstop_min[X_AXIS]);
7189
     NOLESS(target[Y_AXIS], sw_endstop_min[Y_AXIS]);
7196
     NOLESS(target[Y_AXIS], sw_endstop_min[Y_AXIS]);
7190
-
7191
-    float negative_z_offset = 0;
7192
-    #if ENABLED(AUTO_BED_LEVELING_FEATURE)
7193
-      if (zprobe_zoffset < 0) negative_z_offset += zprobe_zoffset;
7194
-      if (home_offset[Z_AXIS] < 0) {
7195
-        #if ENABLED(DEBUG_LEVELING_FEATURE)
7196
-          if (DEBUGGING(LEVELING)) {
7197
-            SERIAL_ECHOPAIR("> clamp_to_software_endstops > Add home_offset[Z_AXIS]:", home_offset[Z_AXIS]);
7198
-            SERIAL_EOL;
7199
-          }
7200
-        #endif
7201
-        negative_z_offset += home_offset[Z_AXIS];
7202
-      }
7203
-    #endif
7204
-    NOLESS(target[Z_AXIS], sw_endstop_min[Z_AXIS] + negative_z_offset);
7197
+    NOLESS(target[Z_AXIS], sw_endstop_min[Z_AXIS]);
7205
   }
7198
   }
7206
-
7207
   if (max_software_endstops) {
7199
   if (max_software_endstops) {
7208
     NOMORE(target[X_AXIS], sw_endstop_max[X_AXIS]);
7200
     NOMORE(target[X_AXIS], sw_endstop_max[X_AXIS]);
7209
     NOMORE(target[Y_AXIS], sw_endstop_max[Y_AXIS]);
7201
     NOMORE(target[Y_AXIS], sw_endstop_max[Y_AXIS]);

Loading…
Cancel
Save