2017-09-06 13:28:31 +02: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/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2017-09-16 09:13:07 +02:00
|
|
|
#include "../../../inc/MarlinConfig.h"
|
|
|
|
|
|
|
|
#if ENABLED(ADVANCED_PAUSE_FEATURE)
|
|
|
|
|
|
|
|
#include "../../gcode.h"
|
2017-12-27 05:16:13 +01:00
|
|
|
#include "../../../feature/pause.h"
|
2017-10-13 09:08:02 +02:00
|
|
|
#include "../../../module/motion.h"
|
2017-09-16 09:13:07 +02:00
|
|
|
#include "../../../module/printcounter.h"
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2017-12-27 05:16:13 +01:00
|
|
|
#if EXTRUDERS > 1
|
|
|
|
#include "../../../module/tool_change.h"
|
|
|
|
#endif
|
|
|
|
|
2017-09-06 13:28:31 +02:00
|
|
|
/**
|
|
|
|
* M600: Pause for filament change
|
|
|
|
*
|
|
|
|
* E[distance] - Retract the filament this far (negative value)
|
|
|
|
* 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
|
|
|
|
* U[distance] - Retract distance for removal (negative value) (manual reload)
|
|
|
|
* L[distance] - Extrude distance for insertion (positive value) (manual reload)
|
|
|
|
* B[count] - Number of times to beep, -1 for indefinite (if equipped with a buzzer)
|
2017-12-27 05:16:13 +01:00
|
|
|
* T[toolhead] - Select extruder for filament change
|
2017-09-06 13:28:31 +02:00
|
|
|
*
|
|
|
|
* Default values are used for omitted arguments.
|
|
|
|
*
|
|
|
|
*/
|
2017-09-16 09:13:07 +02:00
|
|
|
void GcodeSuite::M600() {
|
2017-12-25 08:38:06 +01:00
|
|
|
point_t park_point = NOZZLE_PARK_POINT;
|
2017-09-06 13:28:31 +02:00
|
|
|
|
|
|
|
#if ENABLED(HOME_BEFORE_FILAMENT_CHANGE)
|
|
|
|
// Don't allow filament change without homing first
|
|
|
|
if (axis_unhomed_error()) home_all_axes();
|
|
|
|
#endif
|
|
|
|
|
2017-12-27 05:16:13 +01:00
|
|
|
#if EXTRUDERS > 1
|
|
|
|
// Change toolhead if specified
|
|
|
|
uint8_t active_extruder_before_filament_change = -1;
|
|
|
|
if (parser.seen('T')) {
|
|
|
|
const uint8_t extruder = parser.value_byte();
|
|
|
|
if (active_extruder != extruder) {
|
|
|
|
active_extruder_before_filament_change = active_extruder;
|
|
|
|
tool_change(extruder, 0, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-09-06 13:28:31 +02:00
|
|
|
// Initial retract before move to filament change position
|
|
|
|
const float retract = parser.seen('E') ? parser.value_axis_units(E_AXIS) : 0
|
|
|
|
#ifdef PAUSE_PARK_RETRACT_LENGTH
|
|
|
|
- (PAUSE_PARK_RETRACT_LENGTH)
|
|
|
|
#endif
|
|
|
|
;
|
|
|
|
|
2017-12-25 08:38:06 +01:00
|
|
|
// Move XY axes to filament change position or given position
|
2017-12-27 05:16:13 +01:00
|
|
|
if (parser.seenval('X')) park_point.x = parser.linearval('X');
|
|
|
|
if (parser.seenval('Y')) park_point.y = parser.linearval('Y');
|
2017-12-25 08:38:06 +01:00
|
|
|
|
2017-12-27 05:16:13 +01:00
|
|
|
// Lift Z axis
|
|
|
|
if (parser.seenval('Z')) park_point.z = parser.linearval('Z');
|
2017-12-25 08:38:06 +01:00
|
|
|
|
|
|
|
#if HOTENDS > 1 && DISABLED(DUAL_X_CARRIAGE)
|
|
|
|
park_point.x += (active_extruder ? hotend_offset[X_AXIS][active_extruder] : 0);
|
|
|
|
park_point.y += (active_extruder ? hotend_offset[Y_AXIS][active_extruder] : 0);
|
|
|
|
#endif
|
2017-09-06 13:28:31 +02:00
|
|
|
|
|
|
|
// Unload filament
|
|
|
|
const float unload_length = parser.seen('U') ? parser.value_axis_units(E_AXIS) : 0
|
|
|
|
#if defined(FILAMENT_CHANGE_UNLOAD_LENGTH) && FILAMENT_CHANGE_UNLOAD_LENGTH > 0
|
|
|
|
- (FILAMENT_CHANGE_UNLOAD_LENGTH)
|
|
|
|
#endif
|
|
|
|
;
|
|
|
|
|
|
|
|
// Load filament
|
|
|
|
const float load_length = parser.seen('L') ? parser.value_axis_units(E_AXIS) : 0
|
|
|
|
#ifdef FILAMENT_CHANGE_LOAD_LENGTH
|
|
|
|
+ FILAMENT_CHANGE_LOAD_LENGTH
|
|
|
|
#endif
|
|
|
|
;
|
|
|
|
|
|
|
|
const int beep_count = parser.intval('B',
|
|
|
|
#ifdef FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS
|
|
|
|
FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS
|
|
|
|
#else
|
|
|
|
-1
|
|
|
|
#endif
|
|
|
|
);
|
|
|
|
|
|
|
|
const bool job_running = print_job_timer.isRunning();
|
|
|
|
|
2017-12-25 08:38:06 +01:00
|
|
|
if (pause_print(retract, park_point, unload_length, beep_count, true)) {
|
2017-09-06 13:28:31 +02:00
|
|
|
wait_for_filament_reload(beep_count);
|
|
|
|
resume_print(load_length, ADVANCED_PAUSE_EXTRUDE_LENGTH, beep_count);
|
|
|
|
}
|
|
|
|
|
2017-12-27 05:16:13 +01:00
|
|
|
#if EXTRUDERS > 1
|
|
|
|
// Restore toolhead if it was changed
|
|
|
|
if (active_extruder_before_filament_change >= 0)
|
|
|
|
tool_change(active_extruder_before_filament_change, 0, true);
|
|
|
|
#endif
|
|
|
|
|
2017-09-06 13:28:31 +02:00
|
|
|
// Resume the print job timer if it was running
|
|
|
|
if (job_running) print_job_timer.start();
|
|
|
|
}
|
2017-09-16 09:13:07 +02:00
|
|
|
|
|
|
|
#endif // ADVANCED_PAUSE_FEATURE
|