Skip to content

Commit 77186e1

Browse files
ellenspthinkyhead
authored andcommitted
🚸 Restore active tool after ABL G29 (MarlinFirmware#23692)
Co-authored-by: Scott Lahteine <[email protected]>
1 parent ab8bb3e commit 77186e1

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ void unified_bed_leveling::G29() {
316316
planner.synchronize();
317317
// Send 'N' to force homing before G29 (internal only)
318318
if (axes_should_home() || parser.seen_test('N')) gcode.home_all_axes();
319-
TERN_(HAS_MULTI_HOTEND, if (active_extruder) tool_change(0));
319+
TERN_(HAS_MULTI_HOTEND, if (active_extruder != 0) tool_change(0, true));
320320
}
321321

322322
// Invalidate one or more nearby mesh points, possibly all.
@@ -663,7 +663,7 @@ void unified_bed_leveling::G29() {
663663
UNUSED(probe_deployed);
664664
#endif
665665

666-
TERN_(HAS_MULTI_HOTEND, tool_change(old_tool_index));
666+
TERN_(HAS_MULTI_HOTEND, if (old_tool_index != 0) tool_change(old_tool_index));
667667
return;
668668
}
669669

Marlin/src/gcode/bedlevel/G35.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ void GcodeSuite::G35() {
155155

156156
// Restore the active tool after homing
157157
#if HAS_MULTI_HOTEND
158-
tool_change(old_tool_index, DISABLED(PARKING_EXTRUDER)); // Fetch previous toolhead if not PARKING_EXTRUDER
158+
if (old_tool_index != 0) tool_change(old_tool_index, DISABLED(PARKING_EXTRUDER)); // Fetch previous toolhead if not PARKING_EXTRUDER
159159
#endif
160160

161161
#if BOTH(HAS_LEVELING, RESTORE_LEVELING_AFTER_G35)

Marlin/src/gcode/bedlevel/abl/G29.cpp

+10-1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ class G29_State {
9393
bool dryrun,
9494
reenable;
9595

96+
#if HAS_MULTI_HOTEND
97+
uint8_t tool_index;
98+
#endif
99+
96100
#if EITHER(PROBE_MANUALLY, AUTO_BED_LEVELING_LINEAR)
97101
int abl_probe_index;
98102
#endif
@@ -263,7 +267,10 @@ G29_TYPE GcodeSuite::G29() {
263267
*/
264268
if (!g29_in_progress) {
265269

266-
TERN_(HAS_MULTI_HOTEND, if (active_extruder) tool_change(0));
270+
#if HAS_MULTI_HOTEND
271+
abl.tool_index = active_extruder;
272+
if (active_extruder != 0) tool_change(0, true);
273+
#endif
267274

268275
#if EITHER(PROBE_MANUALLY, AUTO_BED_LEVELING_LINEAR)
269276
abl.abl_probe_index = -1;
@@ -891,6 +898,8 @@ G29_TYPE GcodeSuite::G29() {
891898

892899
TERN_(HAS_DWIN_E3V2_BASIC, DWIN_CompletedLeveling());
893900

901+
TERN_(HAS_MULTI_HOTEND, if (abl.tool_index != 0) tool_change(abl.tool_index));
902+
894903
report_current_position();
895904

896905
TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_IDLE));

0 commit comments

Comments
 (0)