|
@@ -6686,6 +6686,35 @@ inline void gcode_T(uint8_t tmp_extruder) {
|
6686
|
6686
|
}
|
6687
|
6687
|
// No extra case for AUTO_BED_LEVELING_FEATURE in DUAL_X_CARRIAGE. Does that mean they don't work together?
|
6688
|
6688
|
#else // !DUAL_X_CARRIAGE
|
|
6689
|
+
|
|
6690
|
+ //
|
|
6691
|
+ // Set current_position to the position of the new nozzle.
|
|
6692
|
+ // Offsets are based on linear distance, so we need to get
|
|
6693
|
+ // the resulting position in coordinate space.
|
|
6694
|
+ //
|
|
6695
|
+ // - With grid or 3-point leveling, offset XYZ by a tilted vector
|
|
6696
|
+ // - With mesh leveling, update Z for the new position
|
|
6697
|
+ // - Otherwise, just use the raw linear distance
|
|
6698
|
+ //
|
|
6699
|
+ // Software endstops are altered here too. Consider a case where:
|
|
6700
|
+ // E0 at X=0 ... E1 at X=10
|
|
6701
|
+ // When we switch to E1 now X=10, but E1 can't move left.
|
|
6702
|
+ // To express this we apply the change in XY to the software endstops.
|
|
6703
|
+ // E1 can move farther right than E0, so the right limit is extended.
|
|
6704
|
+ //
|
|
6705
|
+ // Note that we don't adjust the Z software endstops. Why not?
|
|
6706
|
+ // Consider a case where Z=0 (here) and switching to E1 makes Z=1
|
|
6707
|
+ // because the bed is 1mm lower at the new position. As long as
|
|
6708
|
+ // the first nozzle is out of the way, the carriage should be
|
|
6709
|
+ // allowed to move 1mm lower. This technically "breaks" the
|
|
6710
|
+ // Z software endstop. But this is technically correct (and
|
|
6711
|
+ // there is no viable alternative).
|
|
6712
|
+ //
|
|
6713
|
+ float xydiff[2] = {
|
|
6714
|
+ hotend_offset[X_AXIS][tmp_extruder] - hotend_offset[X_AXIS][active_extruder],
|
|
6715
|
+ hotend_offset[Y_AXIS][tmp_extruder] - hotend_offset[Y_AXIS][active_extruder]
|
|
6716
|
+ };
|
|
6717
|
+
|
6689
|
6718
|
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
|
6690
|
6719
|
// Offset extruder, make sure to apply the bed level rotation matrix
|
6691
|
6720
|
vector_3 tmp_offset_vec = vector_3(hotend_offset[X_AXIS][tmp_extruder],
|
|
@@ -6721,17 +6750,26 @@ inline void gcode_T(uint8_t tmp_extruder) {
|
6721
|
6750
|
}
|
6722
|
6751
|
#endif
|
6723
|
6752
|
|
6724
|
|
- #else // !AUTO_BED_LEVELING_FEATURE
|
|
6753
|
+ #elif ENABLED(MESH_BED_LEVELING)
|
6725
|
6754
|
|
6726
|
|
- // The newly-selected extruder is actually at...
|
6727
|
|
- for (int i=X_AXIS; i<=Y_AXIS; i++) {
|
6728
|
|
- float diff = hotend_offset[i][tmp_extruder] - hotend_offset[i][active_extruder];
|
6729
|
|
- current_position[i] += diff;
|
6730
|
|
- position_shift[i] += diff; // Offset the coordinate space
|
6731
|
|
- update_software_endstops((AxisEnum)i);
|
|
6755
|
+ if (mbl.active()) {
|
|
6756
|
+ float xpos = current_position[X_AXIS] - home_offset[X_AXIS],
|
|
6757
|
+ ypos = current_position[Y_AXIS] - home_offset[Y_AXIS];
|
|
6758
|
+ current_position[Z_AXIS] += mbl.get_z(xpos + xydiff[X_AXIS], ypos + xydiff[Y_AXIS]) - mbl.get_z(xpos, ypos);
|
6732
|
6759
|
}
|
6733
|
6760
|
|
6734
|
|
- #endif // !AUTO_BED_LEVELING_FEATURE
|
|
6761
|
+ #else // no bed leveling
|
|
6762
|
+
|
|
6763
|
+ // The newly-selected extruder XY is actually at...
|
|
6764
|
+ current_position[X_AXIS] += xydiff[X_AXIS];
|
|
6765
|
+ current_position[Y_AXIS] += xydiff[Y_AXIS];
|
|
6766
|
+
|
|
6767
|
+ #endif // no bed leveling
|
|
6768
|
+
|
|
6769
|
+ for (uint8_t i = X_AXIS; i <= Y_AXIS; i++) {
|
|
6770
|
+ position_shift[i] += xydiff[i];
|
|
6771
|
+ update_software_endstops((AxisEnum)i);
|
|
6772
|
+ }
|
6735
|
6773
|
|
6736
|
6774
|
// Set the new active extruder
|
6737
|
6775
|
active_extruder = tmp_extruder;
|