2017-09-06 11:28:31 +00:00
|
|
|
/**
|
|
|
|
* Marlin 3D Printer Firmware
|
|
|
|
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
|
|
|
*
|
|
|
|
* Based on Sprinter and grbl.
|
|
|
|
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2018-10-17 16:11:41 +00:00
|
|
|
#include "../inc/MarlinConfigPre.h"
|
|
|
|
|
2017-09-06 11:28:31 +00:00
|
|
|
#include "tool_change.h"
|
|
|
|
|
2018-09-24 14:40:48 +00:00
|
|
|
#include "probe.h"
|
2017-09-06 11:28:31 +00:00
|
|
|
#include "motion.h"
|
|
|
|
#include "planner.h"
|
2018-10-07 22:06:14 +00:00
|
|
|
#include "temperature.h"
|
2017-09-06 11:28:31 +00:00
|
|
|
|
|
|
|
#include "../Marlin.h"
|
|
|
|
|
2018-10-17 16:11:41 +00:00
|
|
|
#if EXTRUDERS > 1
|
|
|
|
toolchange_settings_t toolchange_settings; // Initialized by settings.load()
|
|
|
|
#endif
|
|
|
|
|
2018-10-07 22:06:14 +00:00
|
|
|
#if ENABLED(SINGLENOZZLE)
|
|
|
|
uint16_t singlenozzle_temp[EXTRUDERS];
|
|
|
|
#if FAN_COUNT > 0
|
|
|
|
uint8_t singlenozzle_fan_speed[EXTRUDERS];
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2017-09-16 01:44:40 +00:00
|
|
|
#if ENABLED(PARKING_EXTRUDER) && PARKING_EXTRUDER_SOLENOIDS_DELAY > 0
|
|
|
|
#include "../gcode/gcode.h" // for dwell()
|
|
|
|
#endif
|
|
|
|
|
2018-09-08 06:43:24 +00:00
|
|
|
#if ENABLED(SWITCHING_EXTRUDER) || ENABLED(SWITCHING_NOZZLE) || ENABLED(SWITCHING_TOOLHEAD)
|
2017-11-19 19:39:46 +00:00
|
|
|
#include "../module/servo.h"
|
|
|
|
#endif
|
|
|
|
|
2018-08-24 21:35:55 +00:00
|
|
|
#if ENABLED(EXT_SOLENOID) && DISABLED(PARKING_EXTRUDER)
|
2017-09-17 08:43:45 +00:00
|
|
|
#include "../feature/solenoid.h"
|
|
|
|
#endif
|
|
|
|
|
2017-09-17 21:58:16 +00:00
|
|
|
#if ENABLED(MK2_MULTIPLEXER)
|
|
|
|
#include "../feature/snmm.h"
|
|
|
|
#endif
|
|
|
|
|
2017-09-18 05:06:16 +00:00
|
|
|
#if ENABLED(MIXING_EXTRUDER)
|
|
|
|
#include "../feature/mixing.h"
|
2017-09-25 21:18:26 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if HAS_LEVELING
|
|
|
|
#include "../feature/bedlevel/bedlevel.h"
|
2017-09-18 05:06:16 +00:00
|
|
|
#endif
|
|
|
|
|
2017-11-05 02:01:41 +00:00
|
|
|
#if HAS_FANMUX
|
|
|
|
#include "../feature/fanmux.h"
|
|
|
|
#endif
|
|
|
|
|
2018-10-30 21:34:45 +00:00
|
|
|
#if HAS_LCD_MENU
|
2018-09-24 14:40:48 +00:00
|
|
|
#include "../lcd/ultralcd.h"
|
|
|
|
#endif
|
|
|
|
|
2018-05-18 18:16:59 +00:00
|
|
|
#if DO_SWITCH_EXTRUDER
|
2017-09-06 11:28:31 +00:00
|
|
|
|
|
|
|
#if EXTRUDERS > 3
|
2018-08-25 02:53:42 +00:00
|
|
|
#define _SERVO_NR(E) ((E) < 2 ? SWITCHING_EXTRUDER_SERVO_NR : SWITCHING_EXTRUDER_E23_SERVO_NR)
|
2017-09-06 11:28:31 +00:00
|
|
|
#else
|
2018-08-25 02:53:42 +00:00
|
|
|
#define _SERVO_NR(E) SWITCHING_EXTRUDER_SERVO_NR
|
2017-09-06 11:28:31 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
void move_extruder_servo(const uint8_t e) {
|
2018-05-12 06:38:02 +00:00
|
|
|
planner.synchronize();
|
2017-09-06 11:28:31 +00:00
|
|
|
#if EXTRUDERS & 1
|
|
|
|
if (e < EXTRUDERS - 1)
|
|
|
|
#endif
|
|
|
|
{
|
2018-08-25 02:53:42 +00:00
|
|
|
MOVE_SERVO(_SERVO_NR(e), servo_angles[_SERVO_NR(e)][e]);
|
2017-09-06 11:28:31 +00:00
|
|
|
safe_delay(500);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-12 02:29:31 +00:00
|
|
|
#endif // DO_SWITCH_EXTRUDER
|
2017-09-06 11:28:31 +00:00
|
|
|
|
|
|
|
#if ENABLED(SWITCHING_NOZZLE)
|
|
|
|
|
|
|
|
void move_nozzle_servo(const uint8_t e) {
|
2018-05-12 06:38:02 +00:00
|
|
|
planner.synchronize();
|
2018-08-25 02:53:42 +00:00
|
|
|
MOVE_SERVO(SWITCHING_NOZZLE_SERVO_NR, servo_angles[SWITCHING_NOZZLE_SERVO_NR][e]);
|
2017-09-06 11:28:31 +00:00
|
|
|
safe_delay(500);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // SWITCHING_NOZZLE
|
|
|
|
|
|
|
|
#if ENABLED(PARKING_EXTRUDER)
|
|
|
|
|
2017-09-18 06:05:44 +00:00
|
|
|
void pe_magnet_init() {
|
|
|
|
for (uint8_t n = 0; n <= 1; ++n)
|
|
|
|
#if ENABLED(PARKING_EXTRUDER_SOLENOIDS_INVERT)
|
|
|
|
pe_activate_magnet(n);
|
|
|
|
#else
|
|
|
|
pe_deactivate_magnet(n);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2017-09-06 11:28:31 +00:00
|
|
|
void pe_set_magnet(const uint8_t extruder_num, const uint8_t state) {
|
|
|
|
switch (extruder_num) {
|
|
|
|
case 1: OUT_WRITE(SOL1_PIN, state); break;
|
|
|
|
default: OUT_WRITE(SOL0_PIN, state); break;
|
|
|
|
}
|
|
|
|
#if PARKING_EXTRUDER_SOLENOIDS_DELAY > 0
|
2017-09-16 01:44:40 +00:00
|
|
|
gcode.dwell(PARKING_EXTRUDER_SOLENOIDS_DELAY);
|
2017-09-06 11:28:31 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2018-09-19 08:01:55 +00:00
|
|
|
inline void parking_extruder_tool_change(const uint8_t tmp_extruder, bool no_move) {
|
2018-03-29 23:11:02 +00:00
|
|
|
if (!no_move) {
|
|
|
|
|
2018-11-07 00:03:10 +00:00
|
|
|
constexpr float parkingposx[] = PARKING_EXTRUDER_PARKING_X;
|
|
|
|
|
|
|
|
#if HAS_HOTEND_OFFSET
|
|
|
|
const float x_offset = hotend_offset[X_AXIS][active_extruder];
|
|
|
|
#else
|
|
|
|
constexpr float x_offset = 0;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
const float midpos = (parkingposx[0] + parkingposx[1]) * 0.5 + x_offset,
|
|
|
|
grabpos = parkingposx[tmp_extruder] + (tmp_extruder ? PARKING_EXTRUDER_GRAB_DISTANCE : -(PARKING_EXTRUDER_GRAB_DISTANCE)) + x_offset;
|
|
|
|
|
2018-03-29 23:11:02 +00:00
|
|
|
/**
|
2018-08-25 02:03:21 +00:00
|
|
|
* 1. Raise Z-Axis to give enough clearance
|
|
|
|
* 2. Move to park position of old extruder
|
|
|
|
* 3. Disengage magnetic field, wait for delay
|
|
|
|
* 4. Move near new extruder
|
|
|
|
* 5. Engage magnetic field for new extruder
|
|
|
|
* 6. Move to parking incl. offset of new extruder
|
|
|
|
* 7. Lower Z-Axis
|
2018-03-29 23:11:02 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
// STEP 1
|
2018-11-07 00:03:10 +00:00
|
|
|
|
2018-03-29 23:11:02 +00:00
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
2018-08-25 02:03:21 +00:00
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_POS("Start Autopark", current_position);
|
2018-03-29 23:11:02 +00:00
|
|
|
#endif
|
2018-11-07 00:03:10 +00:00
|
|
|
|
2018-10-17 16:11:41 +00:00
|
|
|
current_position[Z_AXIS] += toolchange_settings.z_raise;
|
2018-11-07 00:03:10 +00:00
|
|
|
|
2018-03-29 23:11:02 +00:00
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
2018-08-25 02:03:21 +00:00
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_POS("(1) Raise Z-Axis", current_position);
|
2018-03-29 23:11:02 +00:00
|
|
|
#endif
|
2018-11-07 00:03:10 +00:00
|
|
|
|
2018-10-10 14:45:20 +00:00
|
|
|
planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Z_AXIS], active_extruder);
|
2018-05-12 06:38:02 +00:00
|
|
|
planner.synchronize();
|
2018-03-29 23:11:02 +00:00
|
|
|
|
|
|
|
// STEP 2
|
2018-11-07 00:03:10 +00:00
|
|
|
|
|
|
|
current_position[X_AXIS] = parkingposx[active_extruder] + x_offset;
|
|
|
|
|
2018-03-29 23:11:02 +00:00
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
2018-08-25 02:03:21 +00:00
|
|
|
if (DEBUGGING(LEVELING)) {
|
|
|
|
SERIAL_ECHOLNPAIR("(2) Park extruder ", int(active_extruder));
|
|
|
|
DEBUG_POS("Moving ParkPos", current_position);
|
|
|
|
}
|
2018-03-29 23:11:02 +00:00
|
|
|
#endif
|
2018-11-07 00:03:10 +00:00
|
|
|
|
2018-10-10 14:45:20 +00:00
|
|
|
planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS], active_extruder);
|
2018-05-12 06:38:02 +00:00
|
|
|
planner.synchronize();
|
2018-03-29 23:11:02 +00:00
|
|
|
|
|
|
|
// STEP 3
|
2018-11-07 00:03:10 +00:00
|
|
|
|
2018-03-29 23:11:02 +00:00
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
2018-08-25 02:03:21 +00:00
|
|
|
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("(3) Disengage magnet ");
|
2018-03-29 23:11:02 +00:00
|
|
|
#endif
|
2018-11-07 00:03:10 +00:00
|
|
|
|
2018-03-29 23:11:02 +00:00
|
|
|
pe_deactivate_magnet(active_extruder);
|
2017-09-06 11:28:31 +00:00
|
|
|
|
2018-03-29 23:11:02 +00:00
|
|
|
// STEP 4
|
2018-11-07 00:03:10 +00:00
|
|
|
|
2018-03-29 23:11:02 +00:00
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
2018-08-25 02:03:21 +00:00
|
|
|
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("(4) Move to position near new extruder");
|
2018-03-29 23:11:02 +00:00
|
|
|
#endif
|
2018-11-07 00:03:10 +00:00
|
|
|
|
2018-09-11 04:09:26 +00:00
|
|
|
current_position[X_AXIS] += active_extruder ? -10 : 10; // move 10mm away from parked extruder
|
2018-03-29 23:11:02 +00:00
|
|
|
|
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
2018-08-25 02:03:21 +00:00
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_POS("Move away from parked extruder", current_position);
|
2018-03-29 23:11:02 +00:00
|
|
|
#endif
|
2018-11-07 00:03:10 +00:00
|
|
|
|
2018-10-10 14:45:20 +00:00
|
|
|
planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS], active_extruder);
|
2018-05-12 06:38:02 +00:00
|
|
|
planner.synchronize();
|
2018-03-29 23:11:02 +00:00
|
|
|
|
|
|
|
// STEP 5
|
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
2018-08-25 02:03:21 +00:00
|
|
|
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("(5) Engage magnetic field");
|
2018-03-29 23:11:02 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if ENABLED(PARKING_EXTRUDER_SOLENOIDS_INVERT)
|
|
|
|
pe_activate_magnet(active_extruder); //just save power for inverted magnets
|
|
|
|
#endif
|
2018-11-07 00:03:10 +00:00
|
|
|
|
2018-03-29 23:11:02 +00:00
|
|
|
pe_activate_magnet(tmp_extruder);
|
|
|
|
|
|
|
|
// STEP 6
|
2018-11-07 00:03:10 +00:00
|
|
|
|
2018-09-11 04:09:26 +00:00
|
|
|
current_position[X_AXIS] = grabpos + (tmp_extruder ? -10 : 10);
|
2018-10-10 14:45:20 +00:00
|
|
|
planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS], active_extruder);
|
2018-03-29 23:11:02 +00:00
|
|
|
current_position[X_AXIS] = grabpos;
|
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
2018-08-25 02:03:21 +00:00
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_POS("(6) Unpark extruder", current_position);
|
2018-03-29 23:11:02 +00:00
|
|
|
#endif
|
2018-10-10 14:45:20 +00:00
|
|
|
planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS]/2, active_extruder);
|
2018-05-12 06:38:02 +00:00
|
|
|
planner.synchronize();
|
2018-03-29 23:11:02 +00:00
|
|
|
|
2018-11-07 00:03:10 +00:00
|
|
|
// STEP 7
|
|
|
|
|
|
|
|
current_position[X_AXIS] = midpos
|
|
|
|
#if HAS_HOTEND_OFFSET
|
|
|
|
- hotend_offset[X_AXIS][tmp_extruder]
|
|
|
|
#endif
|
|
|
|
;
|
|
|
|
|
2018-03-29 23:11:02 +00:00
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
2018-08-25 02:03:21 +00:00
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_POS("(7) Move midway between hotends", current_position);
|
2018-03-29 23:11:02 +00:00
|
|
|
#endif
|
2018-11-07 00:03:10 +00:00
|
|
|
|
2018-10-10 14:45:20 +00:00
|
|
|
planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS], active_extruder);
|
2018-05-12 06:38:02 +00:00
|
|
|
planner.synchronize();
|
2018-11-07 00:03:10 +00:00
|
|
|
|
2018-03-29 23:11:02 +00:00
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
SERIAL_ECHOLNPGM("Autopark done.");
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
else { // nomove == true
|
|
|
|
// Only engage magnetic field for new extruder
|
|
|
|
pe_activate_magnet(tmp_extruder);
|
|
|
|
#if ENABLED(PARKING_EXTRUDER_SOLENOIDS_INVERT)
|
|
|
|
pe_activate_magnet(active_extruder); // Just save power for inverted magnets
|
|
|
|
#endif
|
|
|
|
}
|
2018-11-07 00:03:10 +00:00
|
|
|
|
|
|
|
#if HAS_HOTEND_OFFSET
|
|
|
|
current_position[Z_AXIS] += hotend_offset[Z_AXIS][active_extruder] - hotend_offset[Z_AXIS][tmp_extruder];
|
|
|
|
#endif
|
2018-03-29 23:11:02 +00:00
|
|
|
|
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_POS("Applying Z-offset", current_position);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // PARKING_EXTRUDER
|
2017-09-06 11:28:31 +00:00
|
|
|
|
2018-09-08 06:43:24 +00:00
|
|
|
#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*/) {
|
|
|
|
if (no_move) return;
|
|
|
|
|
|
|
|
constexpr uint16_t angles[2] = SWITCHING_TOOLHEAD_SERVO_ANGLES;
|
|
|
|
|
|
|
|
const float toolheadposx[] = SWITCHING_TOOLHEAD_X_POS,
|
|
|
|
placexpos = toolheadposx[active_extruder],
|
|
|
|
grabxpos = toolheadposx[tmp_extruder];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 1. Raise Z to give enough clearance
|
|
|
|
* 2. Move to switch position of current toolhead
|
|
|
|
* 3. Unlock tool and drop it in the dock
|
|
|
|
* 4. Move to the new toolhead
|
|
|
|
* 5. Grab and lock the new toolhead
|
|
|
|
* 6. Apply the z-offset of the new toolhead
|
|
|
|
*/
|
|
|
|
|
|
|
|
// STEP 1
|
2018-11-07 00:03:10 +00:00
|
|
|
|
2018-09-08 06:43:24 +00:00
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_POS("Starting Toolhead change", current_position);
|
|
|
|
#endif
|
2018-11-07 00:03:10 +00:00
|
|
|
|
2018-10-17 16:11:41 +00:00
|
|
|
current_position[Z_AXIS] += toolchange_settings.z_raise;
|
2018-11-07 00:03:10 +00:00
|
|
|
|
2018-09-08 06:43:24 +00:00
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_POS("(1) Raise Z-Axis", current_position);
|
|
|
|
#endif
|
2018-11-07 00:03:10 +00:00
|
|
|
|
2018-10-10 14:45:20 +00:00
|
|
|
planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Z_AXIS], active_extruder);
|
2018-09-08 06:43:24 +00:00
|
|
|
planner.synchronize();
|
|
|
|
|
|
|
|
// STEP 2
|
2018-11-07 00:03:10 +00:00
|
|
|
|
2018-09-08 06:43:24 +00:00
|
|
|
current_position[X_AXIS] = placexpos;
|
2018-11-07 00:03:10 +00:00
|
|
|
|
2018-09-08 06:43:24 +00:00
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
if (DEBUGGING(LEVELING)) {
|
|
|
|
SERIAL_ECHOLNPAIR("(2) Place old tool ", int(active_extruder));
|
|
|
|
DEBUG_POS("Move X SwitchPos", current_position);
|
|
|
|
}
|
|
|
|
#endif
|
2018-11-07 00:03:10 +00:00
|
|
|
|
2018-10-10 14:45:20 +00:00
|
|
|
planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS], active_extruder);
|
2018-09-08 06:43:24 +00:00
|
|
|
planner.synchronize();
|
|
|
|
|
|
|
|
current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS - SWITCHING_TOOLHEAD_Y_SECURITY;
|
2018-11-07 00:03:10 +00:00
|
|
|
|
2018-09-08 06:43:24 +00:00
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos + Security", current_position);
|
|
|
|
#endif
|
2018-11-07 00:03:10 +00:00
|
|
|
|
2018-10-10 14:45:20 +00:00
|
|
|
planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Y_AXIS], active_extruder);
|
2018-09-08 06:43:24 +00:00
|
|
|
planner.synchronize();
|
|
|
|
|
|
|
|
// STEP 3
|
2018-11-07 00:03:10 +00:00
|
|
|
|
2018-09-08 06:43:24 +00:00
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("(3) Unlock and Place Toolhead");
|
|
|
|
#endif
|
2018-11-07 00:03:10 +00:00
|
|
|
|
2018-09-08 06:43:24 +00:00
|
|
|
MOVE_SERVO(SWITCHING_TOOLHEAD_SERVO_NR, angles[1]);
|
|
|
|
safe_delay(500);
|
|
|
|
|
|
|
|
current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS;
|
2018-11-07 00:03:10 +00:00
|
|
|
|
2018-09-08 06:43:24 +00:00
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos", current_position);
|
|
|
|
#endif
|
2018-11-07 00:03:10 +00:00
|
|
|
|
2018-10-10 14:45:20 +00:00
|
|
|
planner.buffer_line(current_position,(planner.settings.max_feedrate_mm_s[Y_AXIS] * 0.5), active_extruder);
|
2018-09-08 06:43:24 +00:00
|
|
|
planner.synchronize();
|
|
|
|
safe_delay(200);
|
|
|
|
current_position[Y_AXIS] -= SWITCHING_TOOLHEAD_Y_CLEAR;
|
2018-11-07 00:03:10 +00:00
|
|
|
|
2018-09-08 06:43:24 +00:00
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_POS("Move back Y clear", current_position);
|
|
|
|
#endif
|
2018-11-07 00:03:10 +00:00
|
|
|
|
2018-10-10 14:45:20 +00:00
|
|
|
planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Y_AXIS], active_extruder); // move away from docked toolhead
|
2018-09-08 06:43:24 +00:00
|
|
|
planner.synchronize();
|
|
|
|
|
|
|
|
// STEP 4
|
2018-11-07 00:03:10 +00:00
|
|
|
|
2018-09-08 06:43:24 +00:00
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("(4) Move to new toolhead position");
|
|
|
|
#endif
|
2018-11-07 00:03:10 +00:00
|
|
|
|
2018-09-08 06:43:24 +00:00
|
|
|
current_position[X_AXIS] = grabxpos;
|
2018-11-07 00:03:10 +00:00
|
|
|
|
2018-09-08 06:43:24 +00:00
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_POS("Move to new toolhead X", current_position);
|
|
|
|
#endif
|
2018-11-07 00:03:10 +00:00
|
|
|
|
2018-10-10 14:45:20 +00:00
|
|
|
planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS], active_extruder);
|
2018-09-08 06:43:24 +00:00
|
|
|
planner.synchronize();
|
|
|
|
current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS - SWITCHING_TOOLHEAD_Y_SECURITY;
|
2018-11-07 00:03:10 +00:00
|
|
|
|
2018-09-08 06:43:24 +00:00
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos + Security", current_position);
|
|
|
|
#endif
|
2018-11-07 00:03:10 +00:00
|
|
|
|
2018-10-10 14:45:20 +00:00
|
|
|
planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Y_AXIS], active_extruder);
|
2018-09-08 06:43:24 +00:00
|
|
|
planner.synchronize();
|
|
|
|
|
|
|
|
// STEP 5
|
2018-11-07 00:03:10 +00:00
|
|
|
|
2018-09-08 06:43:24 +00:00
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("(5) Grab and lock new toolhead ");
|
|
|
|
#endif
|
2018-11-07 00:03:10 +00:00
|
|
|
|
2018-09-08 06:43:24 +00:00
|
|
|
current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS;
|
2018-11-07 00:03:10 +00:00
|
|
|
|
2018-09-08 06:43:24 +00:00
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos", current_position);
|
|
|
|
#endif
|
2018-11-07 00:03:10 +00:00
|
|
|
|
2018-10-10 14:45:20 +00:00
|
|
|
planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Y_AXIS] * 0.5, active_extruder);
|
2018-09-08 06:43:24 +00:00
|
|
|
planner.synchronize();
|
|
|
|
|
|
|
|
safe_delay(200);
|
|
|
|
MOVE_SERVO(SWITCHING_TOOLHEAD_SERVO_NR, angles[0]);
|
|
|
|
safe_delay(500);
|
|
|
|
|
|
|
|
current_position[Y_AXIS] -= SWITCHING_TOOLHEAD_Y_CLEAR;
|
2018-11-07 00:03:10 +00:00
|
|
|
|
2018-09-08 06:43:24 +00:00
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_POS("Move back Y clear", current_position);
|
|
|
|
#endif
|
2018-11-07 00:03:10 +00:00
|
|
|
|
2018-10-10 14:45:20 +00:00
|
|
|
planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Y_AXIS], active_extruder); // move away from docked toolhead
|
2018-09-08 06:43:24 +00:00
|
|
|
planner.synchronize();
|
|
|
|
|
|
|
|
// STEP 6
|
2018-11-07 00:03:10 +00:00
|
|
|
|
|
|
|
#if HAS_HOTEND_OFFSET
|
|
|
|
current_position[Z_AXIS] += hotend_offset[Z_AXIS][active_extruder] - hotend_offset[Z_AXIS][tmp_extruder];
|
|
|
|
#endif
|
2018-09-08 06:43:24 +00:00
|
|
|
|
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_POS("(6) Apply Z offset", current_position);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("Toolhead change done.");
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // SWITCHING_TOOLHEAD
|
|
|
|
|
2017-09-06 11:28:31 +00:00
|
|
|
inline void invalid_extruder_error(const uint8_t e) {
|
|
|
|
SERIAL_ECHO_START();
|
|
|
|
SERIAL_CHAR('T');
|
|
|
|
SERIAL_ECHO_F(e, DEC);
|
|
|
|
SERIAL_CHAR(' ');
|
2018-01-24 03:17:33 +00:00
|
|
|
SERIAL_ECHOLNPGM(MSG_INVALID_EXTRUDER);
|
2017-09-06 11:28:31 +00:00
|
|
|
}
|
|
|
|
|
2018-03-29 23:11:02 +00:00
|
|
|
#if ENABLED(DUAL_X_CARRIAGE)
|
|
|
|
|
|
|
|
inline void dualx_tool_change(const uint8_t tmp_extruder, bool &no_move) {
|
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
if (DEBUGGING(LEVELING)) {
|
|
|
|
SERIAL_ECHOPGM("Dual X Carriage Mode ");
|
|
|
|
switch (dual_x_carriage_mode) {
|
|
|
|
case DXC_FULL_CONTROL_MODE: SERIAL_ECHOLNPGM("DXC_FULL_CONTROL_MODE"); break;
|
|
|
|
case DXC_AUTO_PARK_MODE: SERIAL_ECHOLNPGM("DXC_AUTO_PARK_MODE"); break;
|
2018-09-17 06:06:22 +00:00
|
|
|
case DXC_DUPLICATION_MODE: SERIAL_ECHOLNPGM("DXC_DUPLICATION_MODE"); break;
|
|
|
|
case DXC_SCALED_DUPLICATION_MODE: SERIAL_ECHOLNPGM("DXC_SCALED_DUPLICATION_MODE"); break;
|
2018-03-29 23:11:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
const float xhome = x_home_pos(active_extruder);
|
|
|
|
if (dual_x_carriage_mode == DXC_AUTO_PARK_MODE
|
|
|
|
&& IsRunning()
|
2018-11-07 03:52:20 +00:00
|
|
|
&& (delayed_move_time || current_position[X_AXIS] != xhome) && ! no_move
|
2018-03-29 23:11:02 +00:00
|
|
|
) {
|
2018-11-07 03:52:20 +00:00
|
|
|
|
2018-03-29 23:11:02 +00:00
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
if (DEBUGGING(LEVELING)) {
|
|
|
|
SERIAL_ECHOLNPAIR("MoveX to ", xhome);
|
|
|
|
}
|
|
|
|
#endif
|
2018-11-07 03:52:20 +00:00
|
|
|
// Park old head
|
|
|
|
planner.buffer_line(xhome, current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], planner.settings.max_feedrate_mm_s[X_AXIS], active_extruder);
|
2018-05-12 06:38:02 +00:00
|
|
|
planner.synchronize();
|
2018-03-29 23:11:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Apply Y & Z extruder offset (X offset is used as home pos with Dual X)
|
|
|
|
current_position[Y_AXIS] -= hotend_offset[Y_AXIS][active_extruder] - hotend_offset[Y_AXIS][tmp_extruder];
|
|
|
|
current_position[Z_AXIS] -= hotend_offset[Z_AXIS][active_extruder] - hotend_offset[Z_AXIS][tmp_extruder];
|
|
|
|
|
|
|
|
// Activate the new extruder ahead of calling set_axis_is_at_home!
|
|
|
|
active_extruder = tmp_extruder;
|
|
|
|
|
|
|
|
// This function resets the max/min values - the current position may be overwritten below.
|
|
|
|
set_axis_is_at_home(X_AXIS);
|
|
|
|
|
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_POS("New Extruder", current_position);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
switch (dual_x_carriage_mode) {
|
|
|
|
case DXC_FULL_CONTROL_MODE:
|
|
|
|
// New current position is the position of the activated extruder
|
|
|
|
current_position[X_AXIS] = inactive_extruder_x_pos;
|
|
|
|
// Save the inactive extruder's position (from the old current_position)
|
|
|
|
inactive_extruder_x_pos = destination[X_AXIS];
|
|
|
|
break;
|
|
|
|
case DXC_AUTO_PARK_MODE:
|
2018-11-07 03:52:20 +00:00
|
|
|
// record current raised toolhead position for use by unpark
|
2018-03-29 23:11:02 +00:00
|
|
|
COPY(raised_parked_position, current_position);
|
|
|
|
active_extruder_parked = true;
|
|
|
|
delayed_move_time = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
if (DEBUGGING(LEVELING)) {
|
|
|
|
SERIAL_ECHOLNPAIR("Active extruder parked: ", active_extruder_parked ? "yes" : "no");
|
|
|
|
DEBUG_POS("New extruder (parked)", current_position);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // DUAL_X_CARRIAGE
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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*/) {
|
2018-11-07 03:52:20 +00:00
|
|
|
#if EXTRUDERS < 2
|
2018-07-19 01:10:50 +00:00
|
|
|
|
2018-11-07 03:52:20 +00:00
|
|
|
return invalid_extruder_error(tmp_extruder);
|
2018-09-02 15:18:59 +00:00
|
|
|
|
2018-11-07 03:52:20 +00:00
|
|
|
#elif ENABLED(MIXING_EXTRUDER) && MIXING_VIRTUAL_TOOLS > 1
|
2018-08-21 14:06:10 +00:00
|
|
|
|
2018-11-07 03:52:20 +00:00
|
|
|
if (tmp_extruder >= MIXING_VIRTUAL_TOOLS)
|
|
|
|
return invalid_extruder_error(tmp_extruder);
|
|
|
|
// T0-Tnnn: Switch virtual tool by changing the index to the mix
|
|
|
|
mixer.T(uint_fast8_t(tmp_extruder));
|
|
|
|
UNUSED(fr_mm_s);
|
|
|
|
UNUSED(no_move);
|
2017-09-06 11:28:31 +00:00
|
|
|
|
2018-11-07 03:52:20 +00:00
|
|
|
#else
|
|
|
|
|
|
|
|
#if DISABLED(MIXING_EXTRUDER)
|
|
|
|
planner.synchronize();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if ENABLED(DUAL_X_CARRIAGE) // Only T0 allowed if the Printer is in DXC_DUPLICATION_MODE or DXC_SCALED_DUPLICATION_MODE
|
|
|
|
if (tmp_extruder != 0 && dxc_is_duplicating())
|
|
|
|
return invalid_extruder_error(tmp_extruder);
|
|
|
|
#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
|
2017-09-06 11:28:31 +00:00
|
|
|
|
|
|
|
if (tmp_extruder >= EXTRUDERS)
|
|
|
|
return invalid_extruder_error(tmp_extruder);
|
|
|
|
|
2018-10-10 21:49:59 +00:00
|
|
|
if (!no_move && !all_axes_homed()) {
|
|
|
|
no_move = true;
|
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("No move on toolchange");
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2018-11-07 03:52:20 +00:00
|
|
|
#if ENABLED(ULTIPANEL)
|
|
|
|
lcd_return_to_status();
|
|
|
|
#endif
|
2018-07-29 04:14:46 +00:00
|
|
|
|
2018-11-07 03:52:20 +00:00
|
|
|
#if ENABLED(TOOLCHANGE_FILAMENT_SWAP)
|
|
|
|
const bool should_swap = !no_move && toolchange_settings.swap_length;
|
|
|
|
#if ENABLED(PREVENT_COLD_EXTRUSION)
|
|
|
|
const bool too_cold = !DEBUGGING(DRYRUN) && (thermalManager.targetTooColdToExtrude(active_extruder) || thermalManager.targetTooColdToExtrude(tmp_extruder));
|
|
|
|
#else
|
|
|
|
constexpr bool too_cold = false;
|
|
|
|
#endif
|
|
|
|
if (should_swap) {
|
|
|
|
if (too_cold) {
|
|
|
|
SERIAL_ERROR_START();
|
|
|
|
SERIAL_ERRORLNPGM(MSG_ERR_HOTEND_TOO_COLD);
|
|
|
|
#if ENABLED(SINGLENOZZLE)
|
2018-08-04 01:47:29 +00:00
|
|
|
active_extruder = tmp_extruder;
|
2018-11-07 03:52:20 +00:00
|
|
|
return;
|
2018-09-24 14:40:48 +00:00
|
|
|
#endif
|
2018-11-07 03:52:20 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
#if ENABLED(ADVANCED_PAUSE_FEATURE)
|
|
|
|
do_pause_e_move(-toolchange_settings.swap_length, MMM_TO_MMS(toolchange_settings.retract_speed));
|
2018-09-08 06:43:24 +00:00
|
|
|
#else
|
2018-11-07 03:52:20 +00:00
|
|
|
current_position[E_AXIS] -= toolchange_settings.swap_length / planner.e_factor[active_extruder];
|
|
|
|
planner.buffer_line(current_position, MMM_TO_MMS(toolchange_settings.retract_speed), active_extruder);
|
2017-09-06 11:28:31 +00:00
|
|
|
#endif
|
2018-11-07 03:52:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // TOOLCHANGE_FILAMENT_SWAP
|
2017-09-06 11:28:31 +00:00
|
|
|
|
2018-11-07 03:52:20 +00:00
|
|
|
if (tmp_extruder != active_extruder) {
|
|
|
|
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;
|
2017-09-06 11:28:31 +00:00
|
|
|
|
2018-11-07 03:52:20 +00:00
|
|
|
#if ENABLED(DUAL_X_CARRIAGE)
|
2017-09-06 11:28:31 +00:00
|
|
|
|
2018-11-07 03:52:20 +00:00
|
|
|
#if HAS_SOFTWARE_ENDSTOPS
|
|
|
|
// Update the X software endstops early
|
2017-09-06 11:28:31 +00:00
|
|
|
active_extruder = tmp_extruder;
|
2018-11-07 03:52:20 +00:00
|
|
|
update_software_endstops(X_AXIS);
|
|
|
|
active_extruder = !tmp_extruder;
|
|
|
|
const float minx = soft_endstop_min[X_AXIS], maxx = soft_endstop_max[X_AXIS];
|
2018-03-16 05:46:42 +00:00
|
|
|
#else
|
2018-11-07 03:52:20 +00:00
|
|
|
// No software endstops? Use the configured limits
|
|
|
|
const float minx = tmp_extruder ? X2_MIN_POS : X1_MIN_POS,
|
|
|
|
maxx = tmp_extruder ? X2_MAX_POS : X1_MAX_POS;
|
2018-03-16 05:46:42 +00:00
|
|
|
#endif
|
2018-03-17 21:49:08 +00:00
|
|
|
|
2018-11-07 03:52:20 +00:00
|
|
|
// Don't move the new extruder out of bounds
|
|
|
|
if (!WITHIN(current_position[X_AXIS], minx, maxx)) no_move = true;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!no_move) {
|
|
|
|
set_destination_from_current();
|
|
|
|
#if DISABLED(SWITCHING_NOZZLE)
|
|
|
|
// Do a small lift to avoid the workpiece in the move back (below)
|
|
|
|
#if ENABLED(TOOLCHANGE_PARK)
|
|
|
|
current_position[X_AXIS] = toolchange_settings.change_point.x;
|
|
|
|
current_position[Y_AXIS] = toolchange_settings.change_point.y;
|
2018-09-24 14:40:48 +00:00
|
|
|
#endif
|
2018-11-07 03:52:20 +00:00
|
|
|
current_position[Z_AXIS] += toolchange_settings.z_raise;
|
|
|
|
#if HAS_SOFTWARE_ENDSTOPS
|
|
|
|
NOMORE(current_position[Z_AXIS], soft_endstop_max[Z_AXIS]);
|
2018-05-22 05:53:00 +00:00
|
|
|
#endif
|
2018-11-07 03:52:20 +00:00
|
|
|
planner.buffer_line(current_position, feedrate_mm_s, active_extruder);
|
2017-09-06 11:28:31 +00:00
|
|
|
#endif
|
2018-11-07 03:52:20 +00:00
|
|
|
planner.synchronize();
|
|
|
|
}
|
2017-09-06 11:28:31 +00:00
|
|
|
|
2018-11-07 03:52:20 +00:00
|
|
|
#if HOTENDS > 1
|
|
|
|
const float xdiff = hotend_offset[X_AXIS][tmp_extruder] - hotend_offset[X_AXIS][active_extruder],
|
|
|
|
ydiff = hotend_offset[Y_AXIS][tmp_extruder] - hotend_offset[Y_AXIS][active_extruder],
|
|
|
|
zdiff = hotend_offset[Z_AXIS][tmp_extruder] - hotend_offset[Z_AXIS][active_extruder];
|
|
|
|
#else
|
|
|
|
const float xdiff = 0, ydiff = 0, zdiff = 0;
|
2018-03-29 23:29:52 +00:00
|
|
|
#endif
|
2017-09-06 11:28:31 +00:00
|
|
|
|
2018-11-03 08:56:33 +00:00
|
|
|
#if ENABLED(DUAL_X_CARRIAGE)
|
2018-11-07 03:52:20 +00:00
|
|
|
dualx_tool_change(tmp_extruder, no_move);
|
|
|
|
#elif ENABLED(PARKING_EXTRUDER) // Dual Parking extruder
|
|
|
|
parking_extruder_tool_change(tmp_extruder, no_move);
|
|
|
|
#elif ENABLED(SWITCHING_TOOLHEAD) // Switching Toolhead
|
|
|
|
switching_toolhead_tool_change(tmp_extruder, fr_mm_s, no_move);
|
|
|
|
#elif ENABLED(SWITCHING_NOZZLE)
|
|
|
|
// Always raise by a configured distance to avoid workpiece
|
|
|
|
current_position[Z_AXIS] += MAX(-zdiff, 0.0) + toolchange_settings.z_raise;
|
|
|
|
#if HAS_SOFTWARE_ENDSTOPS
|
|
|
|
NOMORE(current_position[Z_AXIS], soft_endstop_max[Z_AXIS]);
|
|
|
|
#endif
|
|
|
|
if (!no_move)planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Z_AXIS], active_extruder);
|
|
|
|
move_nozzle_servo(tmp_extruder);
|
2018-08-04 01:47:29 +00:00
|
|
|
#endif
|
|
|
|
|
2018-11-07 03:52:20 +00:00
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
if (DEBUGGING(LEVELING)) {
|
|
|
|
SERIAL_ECHOPAIR("Offset Tool XY by { ", xdiff);
|
|
|
|
SERIAL_ECHOPAIR(", ", ydiff);
|
|
|
|
SERIAL_ECHOPAIR(", ", zdiff);
|
|
|
|
SERIAL_ECHOLNPGM(" }");
|
|
|
|
}
|
2017-09-06 11:28:31 +00:00
|
|
|
#endif
|
|
|
|
|
2018-11-07 03:52:20 +00:00
|
|
|
// The newly-selected extruder XY is actually at...
|
|
|
|
#if DISABLED(DUAL_X_CARRIAGE)
|
|
|
|
current_position[X_AXIS] += xdiff;
|
|
|
|
#endif
|
|
|
|
current_position[Y_AXIS] += ydiff;
|
|
|
|
current_position[Z_AXIS] += zdiff;
|
2018-10-07 22:06:14 +00:00
|
|
|
|
2018-11-07 03:52:20 +00:00
|
|
|
// Set the new active extruder if not already done in tool specific function above
|
|
|
|
active_extruder = tmp_extruder;
|
2018-10-07 22:06:14 +00:00
|
|
|
|
2018-11-07 03:52:20 +00:00
|
|
|
// Tell the planner the new "current position"
|
|
|
|
sync_plan_position();
|
2018-10-14 04:08:20 +00:00
|
|
|
|
2018-11-07 03:52:20 +00:00
|
|
|
#if ENABLED(DELTA)
|
|
|
|
//LOOP_XYZ(i) update_software_endstops(i); // or modify the constrain function
|
|
|
|
const bool safe_to_move = current_position[Z_AXIS] < delta_clip_start_height - 1;
|
|
|
|
#else
|
|
|
|
constexpr bool safe_to_move = true;
|
|
|
|
#endif
|
2018-10-08 20:39:55 +00:00
|
|
|
|
2018-11-07 03:52:20 +00:00
|
|
|
// Return to position and lower again
|
|
|
|
if (safe_to_move && !no_move && IsRunning()) {
|
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_POS("Move back", destination);
|
|
|
|
#endif
|
2018-10-07 22:06:14 +00:00
|
|
|
|
2018-11-07 03:52:20 +00:00
|
|
|
#if ENABLED(SINGLENOZZLE)
|
|
|
|
#if FAN_COUNT > 0
|
|
|
|
singlenozzle_fan_speed[active_extruder] = fan_speed[0];
|
|
|
|
fan_speed[0] = singlenozzle_fan_speed[tmp_extruder];
|
2018-10-12 20:19:03 +00:00
|
|
|
#endif
|
2018-10-14 04:08:20 +00:00
|
|
|
|
2018-11-07 03:52:20 +00:00
|
|
|
singlenozzle_temp[active_extruder] = thermalManager.target_temperature[0];
|
|
|
|
if (singlenozzle_temp[tmp_extruder] && singlenozzle_temp[tmp_extruder] != singlenozzle_temp[active_extruder]) {
|
|
|
|
thermalManager.setTargetHotend(singlenozzle_temp[tmp_extruder], 0);
|
|
|
|
#if ENABLED(ULTRA_LCD)
|
|
|
|
thermalManager.set_heating_message(0);
|
|
|
|
#endif
|
|
|
|
(void)thermalManager.wait_for_hotend(0, false); // Wait for heating or cooling
|
|
|
|
}
|
|
|
|
active_extruder = tmp_extruder;
|
|
|
|
#endif
|
2018-10-07 22:06:14 +00:00
|
|
|
|
2018-11-07 03:52:20 +00:00
|
|
|
#if ENABLED(TOOLCHANGE_FILAMENT_SWAP)
|
|
|
|
if (should_swap && !too_cold) {
|
|
|
|
#if ENABLED(ADVANCED_PAUSE_FEATURE)
|
|
|
|
do_pause_e_move(toolchange_settings.swap_length, toolchange_settings.prime_speed);
|
|
|
|
#else
|
|
|
|
current_position[E_AXIS] += toolchange_settings.swap_length / planner.e_factor[tmp_extruder];
|
|
|
|
planner.buffer_line(current_position, toolchange_settings.prime_speed, tmp_extruder);
|
|
|
|
#endif
|
|
|
|
planner.synchronize();
|
|
|
|
}
|
|
|
|
#endif
|
2018-10-07 22:06:14 +00:00
|
|
|
|
2018-11-07 03:52:20 +00:00
|
|
|
// Move back to the original (or tweaked) position
|
|
|
|
do_blocking_move_to(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS]);
|
|
|
|
#if ENABLED(DUAL_X_CARRIAGE)
|
|
|
|
active_extruder_parked = false;
|
|
|
|
#endif
|
|
|
|
feedrate_mm_s = old_feedrate_mm_s;
|
|
|
|
}
|
|
|
|
#if ENABLED(SWITCHING_NOZZLE)
|
|
|
|
else {
|
|
|
|
// Move back down. (Including when the new tool is higher.)
|
|
|
|
do_blocking_move_to_z(destination[Z_AXIS], planner.settings.max_feedrate_mm_s[Z_AXIS]);
|
2018-10-12 20:19:03 +00:00
|
|
|
}
|
2018-11-07 03:52:20 +00:00
|
|
|
#endif
|
|
|
|
} // (tmp_extruder != active_extruder)
|
2018-10-07 22:06:14 +00:00
|
|
|
|
2018-11-07 03:52:20 +00:00
|
|
|
planner.synchronize();
|
2018-10-07 22:06:14 +00:00
|
|
|
|
2018-11-07 03:52:20 +00:00
|
|
|
#if ENABLED(EXT_SOLENOID) && DISABLED(PARKING_EXTRUDER)
|
|
|
|
disable_all_solenoids();
|
|
|
|
enable_solenoid_on_active_extruder();
|
|
|
|
#endif
|
2018-10-07 22:06:14 +00:00
|
|
|
|
2018-11-07 03:52:20 +00:00
|
|
|
#if HAS_SOFTWARE_ENDSTOPS && ENABLED(DUAL_X_CARRIAGE)
|
|
|
|
update_software_endstops(X_AXIS);
|
|
|
|
#endif
|
2017-09-06 11:28:31 +00:00
|
|
|
|
2018-11-07 03:52:20 +00:00
|
|
|
#if ENABLED(MK2_MULTIPLEXER)
|
|
|
|
if (tmp_extruder >= E_STEPPERS) return invalid_extruder_error(tmp_extruder);
|
|
|
|
select_multiplexed_stepper(tmp_extruder);
|
|
|
|
#endif
|
2017-09-06 11:28:31 +00:00
|
|
|
|
2018-03-29 23:29:52 +00:00
|
|
|
#if DO_SWITCH_EXTRUDER
|
2018-05-12 06:38:02 +00:00
|
|
|
planner.synchronize();
|
2017-09-06 11:28:31 +00:00
|
|
|
move_extruder_servo(active_extruder);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if HAS_FANMUX
|
|
|
|
fanmux_switch(active_extruder);
|
|
|
|
#endif
|
2018-08-21 14:06:10 +00:00
|
|
|
|
2018-08-16 00:30:52 +00:00
|
|
|
#if HAS_LEVELING
|
2018-08-21 14:06:10 +00:00
|
|
|
// Restore leveling to re-establish the logical position
|
|
|
|
set_bed_leveling_enabled(leveling_was_active);
|
2018-08-16 00:30:52 +00:00
|
|
|
#endif
|
2018-08-21 14:06:10 +00:00
|
|
|
|
2017-09-06 11:28:31 +00:00
|
|
|
SERIAL_ECHO_START();
|
2018-09-11 04:09:26 +00:00
|
|
|
SERIAL_ECHOLNPAIR(MSG_ACTIVE_EXTRUDER, int(active_extruder));
|
2017-09-06 11:28:31 +00:00
|
|
|
|
2018-11-07 03:52:20 +00:00
|
|
|
#endif // EXTRUDERS <= 1 && (!MIXING_EXTRUDER || MIXING_VIRTUAL_TOOLS <= 1)
|
2017-09-06 11:28:31 +00:00
|
|
|
}
|