diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp index d6cb0b762ff2..2958e8b41cbb 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp @@ -306,16 +306,13 @@ void unified_bed_leveling::G29() { const uint8_t p_val = parser.byteval('P'); const bool may_move = p_val == 1 || p_val == 2 || p_val == 4 || parser.seen_test('J'); - #if HAS_MULTI_HOTEND - const uint8_t old_tool_index = active_extruder; - #endif // Check for commands that require the printer to be homed if (may_move) { planner.synchronize(); // Send 'N' to force homing before G29 (internal only) if (axes_should_home() || parser.seen_test('N')) gcode.home_all_axes(); - TERN_(HAS_MULTI_HOTEND, if (active_extruder != 0) tool_change(0, true)); + probe.use_probing_tool(); // Position bed horizontally and Z probe vertically. #if defined(SAFE_BED_LEVELING_START_X) || defined(SAFE_BED_LEVELING_START_Y) || defined(SAFE_BED_LEVELING_START_Z) \ @@ -698,7 +695,7 @@ void unified_bed_leveling::G29() { UNUSED(probe_deployed); #endif - TERN_(HAS_MULTI_HOTEND, if (old_tool_index != 0) tool_change(old_tool_index)); + probe.use_probing_tool(false); return; } diff --git a/Marlin/src/gcode/bedlevel/mbl/G29.cpp b/Marlin/src/gcode/bedlevel/mbl/G29.cpp index e98f3d5ee3a3..b2d81d5ba6a5 100644 --- a/Marlin/src/gcode/bedlevel/mbl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/mbl/G29.cpp @@ -103,9 +103,9 @@ void GcodeSuite::G29() { bedlevel.reset(); mbl_probe_index = 0; if (!ui.wait_for_move) { - queue.inject(parser.seen_test('N') ? F("G28" TERN(CAN_SET_LEVELING_AFTER_G28, "L0", "") "\nG29S2") : F("G29S2")); - TERN_(EXTENSIBLE_UI, ExtUI::onLevelingStart()); - TERN_(DWIN_LCD_PROUI, DWIN_LevelingStart()); + probe.use_probing_tool(); + if (parser.seen_test('N')) + queue.inject(F("G28" TERN_(CAN_SET_LEVELING_AFTER_G28, "L0"))); // Position bed horizontally and Z probe vertically. #if defined(SAFE_BED_LEVELING_START_X) || defined(SAFE_BED_LEVELING_START_Y) || defined(SAFE_BED_LEVELING_START_Z) \ @@ -143,6 +143,11 @@ void GcodeSuite::G29() { do_blocking_move_to(safe_position); #endif + queue.inject(F("G29S2")); + + TERN_(EXTENSIBLE_UI, ExtUI::onLevelingStart()); + TERN_(DWIN_LCD_PROUI, DWIN_LevelingStart()); + return; } state = MeshNext; @@ -198,6 +203,7 @@ void GcodeSuite::G29() { home_all_axes(); set_bed_leveling_enabled(true); + probe.use_probing_tool(false); #if ENABLED(MESH_G28_REST_ORIGIN) current_position.z = 0; diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index 23033f98d19e..d9be074370c2 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -856,7 +856,8 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) { static uint8_t old_tool; static bool old_state = false; if (probing == old_state) return; - if ((old_state = probing)) old_tool = active_extruder; + old_state = probing; + if (probing) old_tool = active_extruder; const uint8_t tool = probing ? PROBING_TOOL : old_tool; if (tool != active_extruder) tool_change(tool, ENABLED(PROBE_TOOLCHANGE_NO_MOVE));