Always disable/restore leveling on tool-change

Counterpart to #11559 and its followup.

Co-Authored-By: InsanityAutomation <insanityautomation@users.noreply.github.com>
This commit is contained in:
Scott Lahteine 2018-08-21 09:13:36 -05:00
parent b303affbb0
commit 903ccb4b60

View File

@ -2481,6 +2481,8 @@ void clean_up_after_endstop_or_probe_move() {
if (can_change && enable != planner.leveling_active) {
planner.synchronize();
#if ENABLED(MESH_BED_LEVELING)
if (!enable)
@ -12002,6 +12004,12 @@ inline void invalid_extruder_error(const uint8_t e) {
void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool no_move/*=false*/) {
planner.synchronize();
#if HAS_LEVELING
// Set current position to the physical position
const bool leveling_was_active = planner.leveling_active;
set_bed_leveling_enabled(false);
#endif
#if ENABLED(MIXING_EXTRUDER) && MIXING_VIRTUAL_TOOLS > 1
mixing_tool_change(tmp_extruder);
@ -12025,12 +12033,6 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
#endif
}
#if HAS_LEVELING
// Set current position to the physical position
const bool leveling_was_active = planner.leveling_active;
set_bed_leveling_enabled(false);
#endif
#if ENABLED(DUAL_X_CARRIAGE)
#if HAS_SOFTWARE_ENDSTOPS
@ -12087,11 +12089,6 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
current_position[Z_AXIS] -= zdiff;
#endif
#if HAS_LEVELING
// Restore leveling to re-establish the logical position
set_bed_leveling_enabled(leveling_was_active);
#endif
// Tell the planner the new "current position"
SYNC_PLAN_POSITION_KINEMATIC();
@ -12165,6 +12162,11 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
fanmux_switch(active_extruder);
#endif
#if HAS_LEVELING
// Restore leveling to re-establish the logical position
set_bed_leveling_enabled(leveling_was_active);
#endif
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR(MSG_ACTIVE_EXTRUDER, (int)active_extruder);