Skip to content

Commit

Permalink
🚸 Restore active tool after ABL G29 (MarlinFirmware#23692)
Browse files Browse the repository at this point in the history
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
  • Loading branch information
2 people authored and Jeremy Fairbanks committed Jul 18, 2022
1 parent 23a60bf commit 87b9a62
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ void unified_bed_leveling::G29() {
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) tool_change(0));
TERN_(HAS_MULTI_HOTEND, if (active_extruder != 0) tool_change(0, true));
}

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

TERN_(HAS_MULTI_HOTEND, tool_change(old_tool_index));
TERN_(HAS_MULTI_HOTEND, if (old_tool_index != 0) tool_change(old_tool_index));
return;
}

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/bedlevel/G35.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ void GcodeSuite::G35() {

// Restore the active tool after homing
#if HAS_MULTI_HOTEND
tool_change(old_tool_index, DISABLED(PARKING_EXTRUDER)); // Fetch previous toolhead if not PARKING_EXTRUDER
if (old_tool_index != 0) tool_change(old_tool_index, DISABLED(PARKING_EXTRUDER)); // Fetch previous toolhead if not PARKING_EXTRUDER
#endif

#if BOTH(HAS_LEVELING, RESTORE_LEVELING_AFTER_G35)
Expand Down
11 changes: 10 additions & 1 deletion Marlin/src/gcode/bedlevel/abl/G29.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ class G29_State {
bool dryrun,
reenable;

#if HAS_MULTI_HOTEND
uint8_t tool_index;
#endif

#if EITHER(PROBE_MANUALLY, AUTO_BED_LEVELING_LINEAR)
int abl_probe_index;
#endif
Expand Down Expand Up @@ -263,7 +267,10 @@ G29_TYPE GcodeSuite::G29() {
*/
if (!g29_in_progress) {

TERN_(HAS_MULTI_HOTEND, if (active_extruder) tool_change(0));
#if HAS_MULTI_HOTEND
abl.tool_index = active_extruder;
if (active_extruder != 0) tool_change(0, true);
#endif

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

TERN_(HAS_DWIN_E3V2_BASIC, DWIN_CompletedLeveling());

TERN_(HAS_MULTI_HOTEND, if (abl.tool_index != 0) tool_change(abl.tool_index));

report_current_position();

TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_IDLE));
Expand Down

0 comments on commit 87b9a62

Please sign in to comment.