|
@@ -929,11 +929,20 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) {
|
929
|
929
|
#elif ENABLED(SWITCHING_NOZZLE) && !SWITCHING_NOZZLE_TWO_SERVOS // Switching Nozzle (single servo)
|
930
|
930
|
// Raise by a configured distance to avoid workpiece, except with
|
931
|
931
|
// SWITCHING_NOZZLE_TWO_SERVOS, as both nozzles will lift instead.
|
932
|
|
- current_position.z += _MAX(-diff.z, 0.0) + toolchange_settings.z_raise;
|
933
|
|
- #if HAS_SOFTWARE_ENDSTOPS
|
934
|
|
- NOMORE(current_position.z, soft_endstop.max.z);
|
935
|
|
- #endif
|
936
|
|
- if (!no_move) fast_line_to_current(Z_AXIS);
|
|
932
|
+ if (!no_move) {
|
|
933
|
+ #if HAS_SOFTWARE_ENDSTOPS
|
|
934
|
+ const float maxz = _MIN(soft_endstop.max.z, Z_MAX_POS);
|
|
935
|
+ #else
|
|
936
|
+ constexpr float maxz = Z_MAX_POS;
|
|
937
|
+ #endif
|
|
938
|
+
|
|
939
|
+ // Check if Z has space to compensate at least z_offset, and if not, just abort now
|
|
940
|
+ const float newz = current_position.z + _MAX(-diff.z, 0.0);
|
|
941
|
+ if (newz > maxz) return;
|
|
942
|
+
|
|
943
|
+ current_position.z = _MIN(newz + toolchange_settings.z_raise, maxz);
|
|
944
|
+ fast_line_to_current(Z_AXIS);
|
|
945
|
+ }
|
937
|
946
|
move_nozzle_servo(new_tool);
|
938
|
947
|
#endif
|
939
|
948
|
|
|
@@ -942,7 +951,7 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) {
|
942
|
951
|
#endif
|
943
|
952
|
|
944
|
953
|
// The newly-selected extruder XYZ is actually at...
|
945
|
|
- if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Offset Tool XY by { ", diff.x, ", ", diff.y, ", ", diff.z, " }");
|
|
954
|
+ if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Offset Tool XYZ by { ", diff.x, ", ", diff.y, ", ", diff.z, " }");
|
946
|
955
|
current_position += diff;
|
947
|
956
|
|
948
|
957
|
// Tell the planner the new "current position"
|