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-01-04 11:06:34 +00:00
|
|
|
#include "../../../inc/MarlinConfigPre.h"
|
2017-09-17 21:58:16 +00:00
|
|
|
|
2018-01-04 11:06:34 +00:00
|
|
|
#if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES)
|
2017-09-17 21:58:16 +00:00
|
|
|
|
|
|
|
#include "../../gcode.h"
|
2017-11-27 19:39:59 +00:00
|
|
|
#include "../../../Marlin.h"
|
2018-01-04 11:06:34 +00:00
|
|
|
#include "../../../module/motion.h"
|
|
|
|
#include "../../../module/temperature.h"
|
|
|
|
#include "../../../libs/point_t.h"
|
|
|
|
|
|
|
|
#if EXTRUDERS > 1
|
|
|
|
#include "../../../module/tool_change.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if ENABLED(ULTIPANEL)
|
|
|
|
#include "../../../lcd/ultralcd.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* M701: Load filament
|
|
|
|
*
|
2018-06-18 21:12:51 +00:00
|
|
|
* T<extruder> - Optional extruder number. Current extruder if omitted.
|
|
|
|
* Z<distance> - Move the Z axis by this distance
|
|
|
|
* L<distance> - Extrude distance for insertion (positive value) (manual reload)
|
2018-01-04 11:06:34 +00:00
|
|
|
*
|
|
|
|
* Default values are used for omitted arguments.
|
|
|
|
*/
|
|
|
|
void GcodeSuite::M701() {
|
|
|
|
point_t park_point = NOZZLE_PARK_POINT;
|
|
|
|
|
2018-01-22 16:21:42 +00:00
|
|
|
#if ENABLED(NO_MOTION_BEFORE_HOMING)
|
|
|
|
// Only raise Z if the machine is homed
|
|
|
|
if (axis_unhomed_error()) park_point.z = 0;
|
|
|
|
#endif
|
|
|
|
|
2018-01-04 11:06:34 +00:00
|
|
|
if (get_target_extruder_from_command()) return;
|
|
|
|
|
|
|
|
// Z axis lift
|
|
|
|
if (parser.seenval('Z')) park_point.z = parser.linearval('Z');
|
|
|
|
|
2018-01-22 10:37:40 +00:00
|
|
|
// Show initial "wait for load" message
|
2018-01-04 11:06:34 +00:00
|
|
|
#if ENABLED(ULTIPANEL)
|
|
|
|
lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_LOAD, ADVANCED_PAUSE_MODE_LOAD_FILAMENT, target_extruder);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if EXTRUDERS > 1
|
|
|
|
// Change toolhead if specified
|
|
|
|
uint8_t active_extruder_before_filament_change = active_extruder;
|
|
|
|
if (active_extruder != target_extruder)
|
|
|
|
tool_change(target_extruder, 0, true);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Lift Z axis
|
|
|
|
if (park_point.z > 0)
|
2018-05-13 06:10:34 +00:00
|
|
|
do_blocking_move_to_z(MIN(current_position[Z_AXIS] + park_point.z, Z_MAX_POS), NOZZLE_PARK_Z_FEEDRATE);
|
2018-01-04 11:06:34 +00:00
|
|
|
|
2018-03-20 18:19:10 +00:00
|
|
|
// Load filament
|
|
|
|
constexpr float slow_load_length = FILAMENT_CHANGE_SLOW_LOAD_LENGTH;
|
2018-05-13 06:10:34 +00:00
|
|
|
const float fast_load_length = ABS(parser.seen('L') ? parser.value_axis_units(E_AXIS)
|
2018-03-20 18:19:10 +00:00
|
|
|
: filament_change_load_length[active_extruder]);
|
|
|
|
load_filament(slow_load_length, fast_load_length, ADVANCED_PAUSE_PURGE_LENGTH, FILAMENT_CHANGE_ALERT_BEEPS,
|
2018-09-29 06:44:47 +00:00
|
|
|
true, thermalManager.still_heating(target_extruder), ADVANCED_PAUSE_MODE_LOAD_FILAMENT
|
2018-09-17 06:06:22 +00:00
|
|
|
#if ENABLED(DUAL_X_CARRIAGE)
|
|
|
|
, target_extruder
|
|
|
|
#endif
|
|
|
|
);
|
2018-01-04 11:06:34 +00:00
|
|
|
|
|
|
|
// Restore Z axis
|
|
|
|
if (park_point.z > 0)
|
2018-05-13 06:10:34 +00:00
|
|
|
do_blocking_move_to_z(MAX(current_position[Z_AXIS] - park_point.z, 0), NOZZLE_PARK_Z_FEEDRATE);
|
2018-01-04 11:06:34 +00:00
|
|
|
|
|
|
|
#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, true);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Show status screen
|
|
|
|
#if ENABLED(ULTIPANEL)
|
|
|
|
lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_STATUS);
|
|
|
|
#endif
|
|
|
|
}
|
2017-09-06 11:28:31 +00:00
|
|
|
|
|
|
|
/**
|
2018-01-04 11:06:34 +00:00
|
|
|
* M702: Unload filament
|
|
|
|
*
|
2018-06-18 21:12:51 +00:00
|
|
|
* T<extruder> - Optional extruder number. If omitted, current extruder
|
2018-01-04 11:06:34 +00:00
|
|
|
* (or ALL extruders with FILAMENT_UNLOAD_ALL_EXTRUDERS).
|
2018-06-18 21:12:51 +00:00
|
|
|
* Z<distance> - Move the Z axis by this distance
|
|
|
|
* U<distance> - Retract distance for removal (manual reload)
|
2018-01-04 11:06:34 +00:00
|
|
|
*
|
|
|
|
* Default values are used for omitted arguments.
|
2017-09-06 11:28:31 +00:00
|
|
|
*/
|
2017-09-17 21:58:16 +00:00
|
|
|
void GcodeSuite::M702() {
|
2018-01-04 11:06:34 +00:00
|
|
|
point_t park_point = NOZZLE_PARK_POINT;
|
|
|
|
|
2018-01-22 16:21:42 +00:00
|
|
|
#if ENABLED(NO_MOTION_BEFORE_HOMING)
|
|
|
|
// Only raise Z if the machine is homed
|
|
|
|
if (axis_unhomed_error()) park_point.z = 0;
|
|
|
|
#endif
|
|
|
|
|
2018-01-04 11:06:34 +00:00
|
|
|
if (get_target_extruder_from_command()) return;
|
|
|
|
|
|
|
|
// Z axis lift
|
|
|
|
if (parser.seenval('Z')) park_point.z = parser.linearval('Z');
|
|
|
|
|
2018-01-22 10:37:40 +00:00
|
|
|
// Show initial "wait for unload" message
|
2018-01-04 11:06:34 +00:00
|
|
|
#if ENABLED(ULTIPANEL)
|
|
|
|
lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_UNLOAD, ADVANCED_PAUSE_MODE_UNLOAD_FILAMENT, target_extruder);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if EXTRUDERS > 1
|
|
|
|
// Change toolhead if specified
|
|
|
|
uint8_t active_extruder_before_filament_change = active_extruder;
|
|
|
|
if (active_extruder != target_extruder)
|
|
|
|
tool_change(target_extruder, 0, true);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Lift Z axis
|
|
|
|
if (park_point.z > 0)
|
2018-05-13 06:10:34 +00:00
|
|
|
do_blocking_move_to_z(MIN(current_position[Z_AXIS] + park_point.z, Z_MAX_POS), NOZZLE_PARK_Z_FEEDRATE);
|
2018-01-04 11:06:34 +00:00
|
|
|
|
|
|
|
// Unload filament
|
|
|
|
#if EXTRUDERS > 1 && ENABLED(FILAMENT_UNLOAD_ALL_EXTRUDERS)
|
|
|
|
if (!parser.seenval('T')) {
|
|
|
|
HOTEND_LOOP() {
|
|
|
|
if (e != active_extruder) tool_change(e, 0, true);
|
|
|
|
unload_filament(-filament_change_unload_length[e], true, ADVANCED_PAUSE_MODE_UNLOAD_FILAMENT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
// Unload length
|
2018-05-13 06:10:34 +00:00
|
|
|
const float unload_length = -ABS(parser.seen('U') ? parser.value_axis_units(E_AXIS) :
|
2018-01-04 11:06:34 +00:00
|
|
|
filament_change_unload_length[target_extruder]);
|
|
|
|
|
|
|
|
unload_filament(unload_length, true, ADVANCED_PAUSE_MODE_UNLOAD_FILAMENT);
|
2017-09-06 11:28:31 +00:00
|
|
|
}
|
2018-01-04 11:06:34 +00:00
|
|
|
|
|
|
|
// Restore Z axis
|
|
|
|
if (park_point.z > 0)
|
2018-05-13 06:10:34 +00:00
|
|
|
do_blocking_move_to_z(MAX(current_position[Z_AXIS] - park_point.z, 0), NOZZLE_PARK_Z_FEEDRATE);
|
2018-01-04 11:06:34 +00:00
|
|
|
|
|
|
|
#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, true);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Show status screen
|
|
|
|
#if ENABLED(ULTIPANEL)
|
|
|
|
lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_STATUS);
|
|
|
|
#endif
|
2017-09-06 11:28:31 +00:00
|
|
|
}
|
2017-09-17 21:58:16 +00:00
|
|
|
|
2018-01-04 11:06:34 +00:00
|
|
|
#endif // ADVANCED_PAUSE_FEATURE
|