2017-09-06 11:28:31 +00:00
|
|
|
/**
|
|
|
|
* Marlin 3D Printer Firmware
|
2019-06-28 04:57:50 +00:00
|
|
|
* Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
2017-09-06 11:28:31 +00:00
|
|
|
*
|
|
|
|
* Based on Sprinter and grbl.
|
2019-06-28 04:57:50 +00:00
|
|
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
2017-09-06 11:28:31 +00:00
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2017-09-16 07:13:07 +00:00
|
|
|
#include "../../../inc/MarlinConfig.h"
|
|
|
|
|
|
|
|
#if ENABLED(ADVANCED_PAUSE_FEATURE)
|
|
|
|
|
|
|
|
#include "../../gcode.h"
|
2017-12-27 04:16:13 +00:00
|
|
|
#include "../../../feature/pause.h"
|
2017-10-13 07:08:02 +00:00
|
|
|
#include "../../../module/motion.h"
|
2017-09-16 07:13:07 +00:00
|
|
|
#include "../../../module/printcounter.h"
|
2017-09-06 11:28:31 +00:00
|
|
|
|
2017-12-27 04:16:13 +00:00
|
|
|
#if EXTRUDERS > 1
|
|
|
|
#include "../../../module/tool_change.h"
|
|
|
|
#endif
|
|
|
|
|
2018-10-30 21:34:45 +00:00
|
|
|
#if HAS_LCD_MENU
|
2018-01-04 11:06:34 +00:00
|
|
|
#include "../../../lcd/ultralcd.h"
|
|
|
|
#endif
|
|
|
|
|
2019-02-12 18:55:49 +00:00
|
|
|
#if ENABLED(MMU2_MENUS)
|
2019-02-06 23:38:46 +00:00
|
|
|
#include "../../../lcd/menu/menu_mmu2.h"
|
2019-02-01 01:10:52 +00:00
|
|
|
#endif
|
|
|
|
|
2019-05-02 02:55:58 +00:00
|
|
|
#if ENABLED(MIXING_EXTRUDER)
|
|
|
|
#include "../../../feature/mixing.h"
|
|
|
|
#endif
|
|
|
|
|
2017-09-06 11:28:31 +00:00
|
|
|
/**
|
|
|
|
* M600: Pause for filament change
|
|
|
|
*
|
2018-01-04 11:06:34 +00:00
|
|
|
* E[distance] - Retract the filament this far
|
2017-09-06 11:28:31 +00:00
|
|
|
* Z[distance] - Move the Z axis by this distance
|
|
|
|
* X[position] - Move to this X position, with Y
|
|
|
|
* Y[position] - Move to this Y position, with X
|
2018-01-04 11:06:34 +00:00
|
|
|
* U[distance] - Retract distance for removal (manual reload)
|
|
|
|
* L[distance] - Extrude distance for insertion (manual reload)
|
2017-09-06 11:28:31 +00:00
|
|
|
* B[count] - Number of times to beep, -1 for indefinite (if equipped with a buzzer)
|
2017-12-27 04:16:13 +00:00
|
|
|
* T[toolhead] - Select extruder for filament change
|
2017-09-06 11:28:31 +00:00
|
|
|
*
|
|
|
|
* Default values are used for omitted arguments.
|
|
|
|
*/
|
2017-09-16 07:13:07 +00:00
|
|
|
void GcodeSuite::M600() {
|
2017-09-06 11:28:31 +00:00
|
|
|
|
2019-05-02 02:55:58 +00:00
|
|
|
#if ENABLED(MIXING_EXTRUDER)
|
|
|
|
const int8_t target_e_stepper = get_target_e_stepper_from_command();
|
|
|
|
if (target_e_stepper < 0) return;
|
|
|
|
|
|
|
|
const uint8_t old_mixing_tool = mixer.get_current_vtool();
|
|
|
|
mixer.T(MIXER_DIRECT_SET_TOOL);
|
|
|
|
|
|
|
|
MIXER_STEPPER_LOOP(i) mixer.set_collector(i, i == uint8_t(target_e_stepper) ? 1.0 : 0.0);
|
|
|
|
mixer.normalize();
|
|
|
|
|
|
|
|
const int8_t target_extruder = active_extruder;
|
|
|
|
#else
|
|
|
|
const int8_t target_extruder = get_target_extruder_from_command();
|
|
|
|
if (target_extruder < 0) return;
|
|
|
|
#endif
|
2018-01-04 11:06:34 +00:00
|
|
|
|
2018-09-17 06:06:22 +00:00
|
|
|
#if ENABLED(DUAL_X_CARRIAGE)
|
|
|
|
int8_t DXC_ext = target_extruder;
|
|
|
|
if (!parser.seen('T')) { // If no tool index is specified, M600 was (probably) sent in response to filament runout.
|
|
|
|
// In this case, for duplicating modes set DXC_ext to the extruder that ran out.
|
2019-02-13 02:08:34 +00:00
|
|
|
#if HAS_FILAMENT_SENSOR && NUM_RUNOUT_SENSORS > 1
|
2018-09-17 06:06:22 +00:00
|
|
|
if (dxc_is_duplicating())
|
|
|
|
DXC_ext = (READ(FIL_RUNOUT2_PIN) == FIL_RUNOUT_INVERTING) ? 1 : 0;
|
|
|
|
#else
|
|
|
|
DXC_ext = active_extruder;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-01-22 10:37:40 +00:00
|
|
|
// Show initial "wait for start" message
|
2019-02-12 18:55:49 +00:00
|
|
|
#if HAS_LCD_MENU && DISABLED(MMU2_MENUS)
|
2019-03-14 07:26:07 +00:00
|
|
|
lcd_pause_show_message(PAUSE_MESSAGE_CHANGING, PAUSE_MODE_PAUSE_PRINT, target_extruder);
|
2018-01-04 11:06:34 +00:00
|
|
|
#endif
|
|
|
|
|
2017-09-06 11:28:31 +00:00
|
|
|
#if ENABLED(HOME_BEFORE_FILAMENT_CHANGE)
|
|
|
|
// Don't allow filament change without homing first
|
2019-09-26 02:01:29 +00:00
|
|
|
if (axes_need_homing()) home_all_axes();
|
2017-09-06 11:28:31 +00:00
|
|
|
#endif
|
|
|
|
|
2017-12-27 04:16:13 +00:00
|
|
|
#if EXTRUDERS > 1
|
|
|
|
// Change toolhead if specified
|
2018-09-17 06:06:22 +00:00
|
|
|
const uint8_t active_extruder_before_filament_change = active_extruder;
|
|
|
|
if (
|
|
|
|
active_extruder != target_extruder
|
|
|
|
#if ENABLED(DUAL_X_CARRIAGE)
|
2019-03-16 03:46:27 +00:00
|
|
|
&& dual_x_carriage_mode != DXC_DUPLICATION_MODE && dual_x_carriage_mode != DXC_MIRRORED_MODE
|
2018-09-17 06:06:22 +00:00
|
|
|
#endif
|
2019-06-24 01:00:48 +00:00
|
|
|
) tool_change(target_extruder, false);
|
2017-12-27 04:16:13 +00:00
|
|
|
#endif
|
|
|
|
|
2017-09-06 11:28:31 +00:00
|
|
|
// Initial retract before move to filament change position
|
2018-05-13 06:10:34 +00:00
|
|
|
const float retract = -ABS(parser.seen('E') ? parser.value_axis_units(E_AXIS) : 0
|
2017-09-06 11:28:31 +00:00
|
|
|
#ifdef PAUSE_PARK_RETRACT_LENGTH
|
2018-01-04 11:06:34 +00:00
|
|
|
+ (PAUSE_PARK_RETRACT_LENGTH)
|
2017-09-06 11:28:31 +00:00
|
|
|
#endif
|
2018-01-04 11:06:34 +00:00
|
|
|
);
|
2017-09-06 11:28:31 +00:00
|
|
|
|
2019-09-29 09:25:39 +00:00
|
|
|
xyz_pos_t park_point NOZZLE_PARK_POINT;
|
|
|
|
|
2018-03-20 18:19:10 +00:00
|
|
|
// Lift Z axis
|
|
|
|
if (parser.seenval('Z')) park_point.z = parser.linearval('Z');
|
|
|
|
|
2017-12-25 07:38:06 +00:00
|
|
|
// Move XY axes to filament change position or given position
|
2017-12-27 04:16:13 +00:00
|
|
|
if (parser.seenval('X')) park_point.x = parser.linearval('X');
|
|
|
|
if (parser.seenval('Y')) park_point.y = parser.linearval('Y');
|
2017-12-25 07:38:06 +00:00
|
|
|
|
2019-07-05 23:20:15 +00:00
|
|
|
#if HAS_HOTEND_OFFSET && NONE(DUAL_X_CARRIAGE, DELTA)
|
2019-09-29 09:25:39 +00:00
|
|
|
park_point += hotend_offset[active_extruder];
|
2017-12-25 07:38:06 +00:00
|
|
|
#endif
|
2017-09-06 11:28:31 +00:00
|
|
|
|
2019-02-12 18:55:49 +00:00
|
|
|
#if ENABLED(MMU2_MENUS)
|
2019-02-01 01:10:52 +00:00
|
|
|
// For MMU2 reset retract and load/unload values so they don't mess with MMU filament handling
|
|
|
|
constexpr float unload_length = 0.5f,
|
|
|
|
slow_load_length = 0.0f,
|
|
|
|
fast_load_length = 0.0f;
|
|
|
|
#else
|
|
|
|
// Unload filament
|
|
|
|
const float unload_length = -ABS(parser.seen('U') ? parser.value_axis_units(E_AXIS)
|
|
|
|
: fc_settings[active_extruder].unload_length);
|
|
|
|
|
|
|
|
// Slow load filament
|
|
|
|
constexpr float slow_load_length = FILAMENT_CHANGE_SLOW_LOAD_LENGTH;
|
|
|
|
|
|
|
|
// Fast load filament
|
|
|
|
const float fast_load_length = ABS(parser.seen('L') ? parser.value_axis_units(E_AXIS)
|
|
|
|
: fc_settings[active_extruder].load_length);
|
|
|
|
#endif
|
2017-09-06 11:28:31 +00:00
|
|
|
|
|
|
|
const int beep_count = parser.intval('B',
|
2018-01-04 11:06:34 +00:00
|
|
|
#ifdef FILAMENT_CHANGE_ALERT_BEEPS
|
|
|
|
FILAMENT_CHANGE_ALERT_BEEPS
|
2017-09-06 11:28:31 +00:00
|
|
|
#else
|
|
|
|
-1
|
|
|
|
#endif
|
|
|
|
);
|
|
|
|
|
2018-09-17 06:06:22 +00:00
|
|
|
if (pause_print(retract, park_point, unload_length, true DXC_PASS)) {
|
2019-02-12 18:55:49 +00:00
|
|
|
#if ENABLED(MMU2_MENUS)
|
2019-02-01 01:10:52 +00:00
|
|
|
mmu2_M600();
|
|
|
|
resume_print(slow_load_length, fast_load_length, 0, beep_count DXC_PASS);
|
|
|
|
#else
|
|
|
|
wait_for_confirmation(true, beep_count DXC_PASS);
|
|
|
|
resume_print(slow_load_length, fast_load_length, ADVANCED_PAUSE_PURGE_LENGTH, beep_count DXC_PASS);
|
|
|
|
#endif
|
2017-09-06 11:28:31 +00:00
|
|
|
}
|
|
|
|
|
2017-12-27 04:16:13 +00:00
|
|
|
#if EXTRUDERS > 1
|
|
|
|
// Restore toolhead if it was changed
|
2018-01-04 11:06:34 +00:00
|
|
|
if (active_extruder_before_filament_change != active_extruder)
|
2019-06-24 01:00:48 +00:00
|
|
|
tool_change(active_extruder_before_filament_change, false);
|
2017-12-27 04:16:13 +00:00
|
|
|
#endif
|
2019-05-02 02:55:58 +00:00
|
|
|
|
|
|
|
#if ENABLED(MIXING_EXTRUDER)
|
|
|
|
mixer.T(old_mixing_tool); // Restore original mixing tool
|
|
|
|
#endif
|
2017-09-06 11:28:31 +00:00
|
|
|
}
|
2017-09-16 07:13:07 +00:00
|
|
|
|
|
|
|
#endif // ADVANCED_PAUSE_FEATURE
|