From 9934d0e88cab77728aeafb5411422fb8cafbfd83 Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Sun, 23 Jun 2019 16:45:12 -0400 Subject: [PATCH] Bump --- Marlin/src/gcode/calibrate/G28.cpp | 4 +- Marlin/src/gcode/calibrate/G33.cpp | 4 +- Marlin/src/gcode/calibrate/G34_M422.cpp | 4 +- Marlin/src/gcode/control/T.cpp | 1 - Marlin/src/gcode/feature/pause/M600.cpp | 4 +- Marlin/src/gcode/feature/pause/M701_M702.cpp | 10 ++-- Marlin/src/lcd/extensible_ui/ui_api.cpp | 2 +- Marlin/src/module/tool_change.cpp | 62 ++++++++++++-------- Marlin/src/module/tool_change.h | 2 +- 9 files changed, 54 insertions(+), 39 deletions(-) diff --git a/Marlin/src/gcode/calibrate/G28.cpp b/Marlin/src/gcode/calibrate/G28.cpp index 3656dc0999..c451f975cc 100644 --- a/Marlin/src/gcode/calibrate/G28.cpp +++ b/Marlin/src/gcode/calibrate/G28.cpp @@ -242,7 +242,7 @@ void GcodeSuite::G28(const bool always_home_all) { #if DISABLED(DELTA) || ENABLED(DELTA_HOME_TO_SAFE_ZONE) const uint8_t old_tool_index = active_extruder; #endif - tool_change(0, 0, true); + tool_change(0, true); #endif #if HAS_DUPLICATION_MODE @@ -428,7 +428,7 @@ void GcodeSuite::G28(const bool always_home_all) { #else #define NO_FETCH true #endif - tool_change(old_tool_index, 0, NO_FETCH); + tool_change(old_tool_index, NO_FETCH); #endif ui.refresh(); diff --git a/Marlin/src/gcode/calibrate/G33.cpp b/Marlin/src/gcode/calibrate/G33.cpp index b3488766b6..78816903fd 100644 --- a/Marlin/src/gcode/calibrate/G33.cpp +++ b/Marlin/src/gcode/calibrate/G33.cpp @@ -80,7 +80,7 @@ void ac_home() { void ac_setup(const bool reset_bed) { #if HOTENDS > 1 - tool_change(0, 0, true); + tool_change(0, true); #endif planner.synchronize(); @@ -104,7 +104,7 @@ void ac_cleanup( #endif clean_up_after_endstop_or_probe_move(); #if HOTENDS > 1 - tool_change(old_tool_index, 0, true); + tool_change(old_tool_index, true); #endif } diff --git a/Marlin/src/gcode/calibrate/G34_M422.cpp b/Marlin/src/gcode/calibrate/G34_M422.cpp index e0f3b2958b..e7f9dbdadd 100644 --- a/Marlin/src/gcode/calibrate/G34_M422.cpp +++ b/Marlin/src/gcode/calibrate/G34_M422.cpp @@ -109,7 +109,7 @@ void GcodeSuite::G34() { // Always home with tool 0 active #if HOTENDS > 1 const uint8_t old_tool_index = active_extruder; - tool_change(0, 0, true); + tool_change(0, true); #endif #if HAS_DUPLICATION_MODE @@ -263,7 +263,7 @@ void GcodeSuite::G34() { // Restore the active tool after homing #if HOTENDS > 1 - tool_change(old_tool_index, 0, ( + tool_change(old_tool_index, ( #if ENABLED(PARKING_EXTRUDER) false // Fetch the previous toolhead #else diff --git a/Marlin/src/gcode/control/T.cpp b/Marlin/src/gcode/control/T.cpp index fb8f09eeeb..0916d93a86 100644 --- a/Marlin/src/gcode/control/T.cpp +++ b/Marlin/src/gcode/control/T.cpp @@ -68,7 +68,6 @@ void GcodeSuite::T(const uint8_t tool_index) { tool_change( tool_index, - MMM_TO_MMS(parser.linearval('F')), (tool_index == active_extruder) || parser.boolval('S') ); diff --git a/Marlin/src/gcode/feature/pause/M600.cpp b/Marlin/src/gcode/feature/pause/M600.cpp index fe34541700..722487b679 100644 --- a/Marlin/src/gcode/feature/pause/M600.cpp +++ b/Marlin/src/gcode/feature/pause/M600.cpp @@ -109,7 +109,7 @@ void GcodeSuite::M600() { #if ENABLED(DUAL_X_CARRIAGE) && dual_x_carriage_mode != DXC_DUPLICATION_MODE && dual_x_carriage_mode != DXC_MIRRORED_MODE #endif - ) tool_change(target_extruder, 0, false); + ) tool_change(target_extruder, false); #endif // Initial retract before move to filament change position @@ -170,7 +170,7 @@ void GcodeSuite::M600() { #if EXTRUDERS > 1 // Restore toolhead if it was changed if (active_extruder_before_filament_change != active_extruder) - tool_change(active_extruder_before_filament_change, 0, false); + tool_change(active_extruder_before_filament_change, false); #endif #if ENABLED(MIXING_EXTRUDER) diff --git a/Marlin/src/gcode/feature/pause/M701_M702.cpp b/Marlin/src/gcode/feature/pause/M701_M702.cpp index abd4f1371d..2084d6b188 100644 --- a/Marlin/src/gcode/feature/pause/M701_M702.cpp +++ b/Marlin/src/gcode/feature/pause/M701_M702.cpp @@ -92,7 +92,7 @@ void GcodeSuite::M701() { // Change toolhead if specified uint8_t active_extruder_before_filament_change = active_extruder; if (active_extruder != target_extruder) - tool_change(target_extruder, 0, false); + tool_change(target_extruder, false); #endif // Lift Z axis @@ -121,7 +121,7 @@ void GcodeSuite::M701() { #if EXTRUDERS > 1 && DISABLED(PRUSA_MMU2) // Restore toolhead if it was changed if (active_extruder_before_filament_change != active_extruder) - tool_change(active_extruder_before_filament_change, 0, false); + tool_change(active_extruder_before_filament_change, false); #endif #if ENABLED(MIXING_EXTRUDER) @@ -191,7 +191,7 @@ void GcodeSuite::M702() { // Change toolhead if specified uint8_t active_extruder_before_filament_change = active_extruder; if (active_extruder != target_extruder) - tool_change(target_extruder, 0, false); + tool_change(target_extruder, false); #endif // Lift Z axis @@ -205,7 +205,7 @@ void GcodeSuite::M702() { #if EXTRUDERS > 1 && ENABLED(FILAMENT_UNLOAD_ALL_EXTRUDERS) if (!parser.seenval('T')) { HOTEND_LOOP() { - if (e != active_extruder) tool_change(e, 0, false); + if (e != active_extruder) tool_change(e, false); unload_filament(-fc_settings[e].unload_length, true, PAUSE_MODE_UNLOAD_FILAMENT); } } @@ -231,7 +231,7 @@ void GcodeSuite::M702() { #if EXTRUDERS > 1 && DISABLED(PRUSA_MMU2) // Restore toolhead if it was changed if (active_extruder_before_filament_change != active_extruder) - tool_change(active_extruder_before_filament_change, 0, false); + tool_change(active_extruder_before_filament_change, false); #endif #if ENABLED(MIXING_EXTRUDER) diff --git a/Marlin/src/lcd/extensible_ui/ui_api.cpp b/Marlin/src/lcd/extensible_ui/ui_api.cpp index dff8108d01..8cb8c55b8f 100644 --- a/Marlin/src/lcd/extensible_ui/ui_api.cpp +++ b/Marlin/src/lcd/extensible_ui/ui_api.cpp @@ -350,7 +350,7 @@ namespace ExtUI { #if EXTRUDERS > 1 const uint8_t e = extruder - E0; #if DO_SWITCH_EXTRUDER || EITHER(SWITCHING_NOZZLE, PARKING_EXTRUDER) - if (e != active_extruder) tool_change(e, 0, no_move); + if (e != active_extruder) tool_change(e, no_move); #endif active_extruder = e; #endif diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index ceb01bfbbc..7eaec2e711 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -365,7 +365,7 @@ inline void fast_line_to_current(const AxisEnum fr_axis) { #if ENABLED(SWITCHING_TOOLHEAD) - inline void switching_toolhead_tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool no_move/*=false*/) { + inline void switching_toolhead_tool_change(const uint8_t tmp_extruder, bool no_move/*=false*/) { if (no_move) return; constexpr uint16_t angles[2] = SWITCHING_TOOLHEAD_SERVO_ANGLES; @@ -469,7 +469,7 @@ inline void fast_line_to_current(const AxisEnum fr_axis) { #if ENABLED(MAGNETIC_SWITCHING_TOOLHEAD) - inline void magnetic_switching_toolhead_tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool no_move/*=false*/) { + inline void magnetic_switching_toolhead_tool_change(const uint8_t tmp_extruder, bool no_move/*=false*/) { if (no_move) return; const float toolheadposx[] = SWITCHING_TOOLHEAD_X_POS, @@ -653,7 +653,7 @@ inline void invalid_extruder_error(const uint8_t e) { * Perform a tool-change, which may result in moving the * previous tool out of the way and the new tool into place. */ -void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool no_move/*=false*/) { +void tool_change(const uint8_t tmp_extruder, bool no_move/*=false*/) { #if ENABLED(MAGNETIC_SWITCHING_TOOLHEAD) if (tmp_extruder == active_extruder) return; @@ -661,7 +661,7 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n #if ENABLED(MIXING_EXTRUDER) - UNUSED(fr_mm_s); UNUSED(no_move); + UNUSED(no_move); if (tmp_extruder >= MIXING_VIRTUAL_TOOLS) return invalid_extruder_error(tmp_extruder); @@ -673,13 +673,13 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n #elif ENABLED(PRUSA_MMU2) - UNUSED(fr_mm_s); UNUSED(no_move); + UNUSED(no_move); mmu2.tool_change(tmp_extruder); #elif EXTRUDERS < 2 - UNUSED(fr_mm_s); UNUSED(no_move); + UNUSED(no_move); if (tmp_extruder) invalid_extruder_error(tmp_extruder); return; @@ -702,21 +702,23 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n if (tmp_extruder >= EXTRUDERS) return invalid_extruder_error(tmp_extruder); - if (!no_move && (!all_axes_homed() - #if ENABLED(DUAL_X_CARRIAGE) - || dual_x_carriage_mode == DXC_FULL_CONTROL_MODE - #endif - )) { + if (!no_move && !all_axes_homed()) { no_move = true; - if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("No move on toolchange"); + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("No move (not homed)"); } #if HAS_LCD_MENU ui.return_to_status(); #endif + #if ENABLED(DUAL_X_CARRIAGE) + const bool idex_full_control = dual_x_carriage_mode == DXC_FULL_CONTROL_MODE; + #else + constexpr bool idex_full_control = false; + #endif + #if ENABLED(TOOLCHANGE_FILAMENT_SWAP) - const bool should_swap = !no_move && toolchange_settings.swap_length; + const bool should_swap = !no_move && toolchange_settings.swap_length && !idex_full_control; #if ENABLED(PREVENT_COLD_EXTRUSION) const bool too_cold = !DEBUGGING(DRYRUN) && (thermalManager.targetTooColdToExtrude(active_extruder) || thermalManager.targetTooColdToExtrude(tmp_extruder)); #else @@ -747,8 +749,7 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n raise_nozzle(active_extruder); #endif - const float old_feedrate_mm_s = fr_mm_s > 0.0 ? fr_mm_s : feedrate_mm_s; - feedrate_mm_s = fr_mm_s > 0.0 ? fr_mm_s : XY_PROBE_FEEDRATE_MM_S; + REMEMBER(fr, feedrate_mm_s, XY_PROBE_FEEDRATE_MM_S); #if HAS_SOFTWARE_ENDSTOPS #if HAS_HOTEND_OFFSET @@ -765,7 +766,7 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n set_destination_from_current(); - if (!no_move) { + if (!no_move && !idex_full_control) { #if DISABLED(SWITCHING_NOZZLE) // Do a small lift to avoid the workpiece in the move back (below) current_position[Z_AXIS] += toolchange_settings.z_raise; @@ -801,9 +802,9 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n #elif ENABLED(MAGNETIC_PARKING_EXTRUDER) // Magnetic Parking extruder magnetic_parking_extruder_tool_change(tmp_extruder); #elif ENABLED(SWITCHING_TOOLHEAD) // Switching Toolhead - switching_toolhead_tool_change(tmp_extruder, fr_mm_s, no_move); + switching_toolhead_tool_change(tmp_extruder, no_move); #elif ENABLED(MAGNETIC_SWITCHING_TOOLHEAD) // Magnetic Switching Toolhead - magnetic_switching_toolhead_tool_change(tmp_extruder, fr_mm_s, no_move); + magnetic_switching_toolhead_tool_change(tmp_extruder, no_move); #elif ENABLED(SWITCHING_NOZZLE) && !SWITCHING_NOZZLE_TWO_SERVOS // Raise by a configured distance to avoid workpiece, except with // SWITCHING_NOZZLE_TWO_SERVOS, as both nozzles will lift instead. @@ -837,7 +838,6 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n // Return to position and lower again if (safe_to_move && !no_move && IsRunning()) { - if (DEBUGGING(LEVELING)) DEBUG_POS("Move back", destination); #if ENABLED(SINGLENOZZLE) #if FAN_COUNT > 0 @@ -884,13 +884,29 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n apply_motion_limits(destination); #endif - // Move back to the original (or tweaked) position - do_blocking_move_to(destination); - + // Should the nozzle move back to the old position? + if (!idex_full_control + #if ENABLED(TOOLCHANGE_NO_RETURN) + && false + #endif + ) { + // Move back to the original (or adjusted) position + if (DEBUGGING(LEVELING)) DEBUG_POS("Move back", destination); + do_blocking_move_to(destination); + } + else if (!idex_full_control) { + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("No return XY"); + // Move back down + do_blocking_move_to_z(destination[Z_AXIS], planner.settings.max_feedrate_mm_s[Z_AXIS]); + } + else + { + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("No return XYZ"); + } + #if ENABLED(DUAL_X_CARRIAGE) active_extruder_parked = false; #endif - feedrate_mm_s = old_feedrate_mm_s; } #if ENABLED(SWITCHING_NOZZLE) else { diff --git a/Marlin/src/module/tool_change.h b/Marlin/src/module/tool_change.h index 07f88dce88..14d076ba43 100644 --- a/Marlin/src/module/tool_change.h +++ b/Marlin/src/module/tool_change.h @@ -96,4 +96,4 @@ * Perform a tool-change, which may result in moving the * previous tool out of the way and the new tool into place. */ -void tool_change(const uint8_t tmp_extruder, const float fr_mm_s=0.0, bool no_move=false); +void tool_change(const uint8_t tmp_extruder, bool no_move=false);