2017-09-06 11:28:31 +00:00
|
|
|
/**
|
|
|
|
* Marlin 3D Printer Firmware
|
2020-02-03 14:00:57 +00:00
|
|
|
* Copyright (c) 2020 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/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
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"
|
2020-01-03 01:01:38 +00:00
|
|
|
#include "../../../MarlinCore.h"
|
2018-01-04 11:06:34 +00:00
|
|
|
#include "../../../module/motion.h"
|
|
|
|
#include "../../../module/temperature.h"
|
2019-10-31 18:18:03 +00:00
|
|
|
#include "../../../feature/pause.h"
|
2018-01-04 11:06:34 +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-01 01:10:52 +00:00
|
|
|
#if ENABLED(PRUSA_MMU2)
|
|
|
|
#include "../../../feature/prusa_MMU2/mmu2.h"
|
|
|
|
#endif
|
|
|
|
|
2019-05-02 02:55:58 +00:00
|
|
|
#if ENABLED(MIXING_EXTRUDER)
|
|
|
|
#include "../../../feature/mixing.h"
|
|
|
|
#endif
|
|
|
|
|
2018-01-04 11:06:34 +00:00
|
|
|
/**
|
|
|
|
* M701: Load filament
|
|
|
|
*
|
2019-05-02 02:55:58 +00:00
|
|
|
* T<extruder> - Extruder number. Required for mixing extruder.
|
|
|
|
* For non-mixing, current extruder if omitted.
|
2018-06-18 21:12:51 +00:00
|
|
|
* 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() {
|
2019-09-29 09:25:39 +00:00
|
|
|
xyz_pos_t park_point = NOZZLE_PARK_POINT;
|
2018-01-04 11:06:34 +00:00
|
|
|
|
2018-01-22 16:21:42 +00:00
|
|
|
#if ENABLED(NO_MOTION_BEFORE_HOMING)
|
2019-09-26 02:01:29 +00:00
|
|
|
// Don't raise Z if the machine isn't homed
|
|
|
|
if (axes_need_homing()) park_point.z = 0;
|
2018-01-22 16:21:42 +00:00
|
|
|
#endif
|
|
|
|
|
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);
|
2018-11-14 23:33:04 +00:00
|
|
|
|
2019-05-02 02:55:58 +00:00
|
|
|
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
|
|
|
|
|
|
|
// 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-10-30 21:34:45 +00:00
|
|
|
#if HAS_LCD_MENU
|
2019-03-14 07:26:07 +00:00
|
|
|
lcd_pause_show_message(PAUSE_MESSAGE_LOAD, PAUSE_MODE_LOAD_FILAMENT, target_extruder);
|
2018-01-04 11:06:34 +00:00
|
|
|
#endif
|
|
|
|
|
2019-02-01 01:10:52 +00:00
|
|
|
#if EXTRUDERS > 1 && DISABLED(PRUSA_MMU2)
|
2018-01-04 11:06:34 +00:00
|
|
|
// Change toolhead if specified
|
|
|
|
uint8_t active_extruder_before_filament_change = active_extruder;
|
|
|
|
if (active_extruder != target_extruder)
|
2019-06-24 01:00:48 +00:00
|
|
|
tool_change(target_extruder, false);
|
2018-01-04 11:06:34 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// Lift Z axis
|
|
|
|
if (park_point.z > 0)
|
2019-09-29 09:25:39 +00:00
|
|
|
do_blocking_move_to_z(_MIN(current_position.z + park_point.z, Z_MAX_POS), feedRate_t(NOZZLE_PARK_Z_FEEDRATE));
|
2018-01-04 11:06:34 +00:00
|
|
|
|
2018-03-20 18:19:10 +00:00
|
|
|
// Load filament
|
2019-02-01 01:10:52 +00:00
|
|
|
#if ENABLED(PRUSA_MMU2)
|
2019-04-08 22:56:40 +00:00
|
|
|
mmu2.load_filament_to_nozzle(target_extruder);
|
2019-02-01 01:10:52 +00:00
|
|
|
#else
|
2019-10-02 23:51:25 +00:00
|
|
|
constexpr float purge_length = ADVANCED_PAUSE_PURGE_LENGTH,
|
|
|
|
slow_load_length = FILAMENT_CHANGE_SLOW_LOAD_LENGTH;
|
|
|
|
const float fast_load_length = ABS(parser.seen('L') ? parser.value_axis_units(E_AXIS)
|
|
|
|
: fc_settings[active_extruder].load_length);
|
|
|
|
load_filament(
|
|
|
|
slow_load_length, fast_load_length, purge_length,
|
|
|
|
FILAMENT_CHANGE_ALERT_BEEPS,
|
|
|
|
true, // show_lcd
|
|
|
|
thermalManager.still_heating(target_extruder), // pause_for_user
|
|
|
|
PAUSE_MODE_LOAD_FILAMENT // pause_mode
|
|
|
|
#if ENABLED(DUAL_X_CARRIAGE)
|
|
|
|
, target_extruder // Dual X target
|
|
|
|
#endif
|
|
|
|
);
|
2019-02-01 01:10:52 +00:00
|
|
|
#endif
|
2018-01-04 11:06:34 +00:00
|
|
|
|
|
|
|
// Restore Z axis
|
|
|
|
if (park_point.z > 0)
|
2019-09-29 09:25:39 +00:00
|
|
|
do_blocking_move_to_z(_MAX(current_position.z - park_point.z, 0), feedRate_t(NOZZLE_PARK_Z_FEEDRATE));
|
2018-01-04 11:06:34 +00:00
|
|
|
|
2019-02-01 01:10:52 +00:00
|
|
|
#if EXTRUDERS > 1 && DISABLED(PRUSA_MMU2)
|
2018-01-04 11:06:34 +00:00
|
|
|
// Restore toolhead if it was changed
|
|
|
|
if (active_extruder_before_filament_change != active_extruder)
|
2019-06-24 01:00:48 +00:00
|
|
|
tool_change(active_extruder_before_filament_change, false);
|
2018-01-04 11:06:34 +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
|
|
|
|
|
2018-01-04 11:06:34 +00:00
|
|
|
// Show status screen
|
2018-10-30 21:34:45 +00:00
|
|
|
#if HAS_LCD_MENU
|
2019-03-14 07:26:07 +00:00
|
|
|
lcd_pause_show_message(PAUSE_MESSAGE_STATUS);
|
2018-01-04 11:06:34 +00:00
|
|
|
#endif
|
|
|
|
}
|
2017-09-06 11:28:31 +00:00
|
|
|
|
|
|
|
/**
|
2018-01-04 11:06:34 +00:00
|
|
|
* M702: Unload filament
|
|
|
|
*
|
2019-05-02 02:55:58 +00:00
|
|
|
* T<extruder> - Extruder number. Required for mixing extruder.
|
|
|
|
* For non-mixing, 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() {
|
2019-09-29 09:25:39 +00:00
|
|
|
xyz_pos_t park_point = NOZZLE_PARK_POINT;
|
2018-01-04 11:06:34 +00:00
|
|
|
|
2018-01-22 16:21:42 +00:00
|
|
|
#if ENABLED(NO_MOTION_BEFORE_HOMING)
|
2019-09-26 02:01:29 +00:00
|
|
|
// Don't raise Z if the machine isn't homed
|
|
|
|
if (axes_need_homing()) park_point.z = 0;
|
2018-01-22 16:21:42 +00:00
|
|
|
#endif
|
|
|
|
|
2019-05-02 02:55:58 +00:00
|
|
|
#if ENABLED(MIXING_EXTRUDER)
|
|
|
|
const uint8_t old_mixing_tool = mixer.get_current_vtool();
|
|
|
|
|
|
|
|
#if ENABLED(FILAMENT_UNLOAD_ALL_EXTRUDERS)
|
|
|
|
float mix_multiplier = 1.0;
|
|
|
|
if (!parser.seenval('T')) {
|
|
|
|
mixer.T(MIXER_AUTORETRACT_TOOL);
|
|
|
|
mix_multiplier = MIXING_STEPPERS;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
const int8_t target_e_stepper = get_target_e_stepper_from_command();
|
|
|
|
if (target_e_stepper < 0) return;
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
// 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-10-30 21:34:45 +00:00
|
|
|
#if HAS_LCD_MENU
|
2019-03-14 07:26:07 +00:00
|
|
|
lcd_pause_show_message(PAUSE_MESSAGE_UNLOAD, PAUSE_MODE_UNLOAD_FILAMENT, target_extruder);
|
2018-01-04 11:06:34 +00:00
|
|
|
#endif
|
|
|
|
|
2019-02-01 01:10:52 +00:00
|
|
|
#if EXTRUDERS > 1 && DISABLED(PRUSA_MMU2)
|
2018-01-04 11:06:34 +00:00
|
|
|
// Change toolhead if specified
|
|
|
|
uint8_t active_extruder_before_filament_change = active_extruder;
|
|
|
|
if (active_extruder != target_extruder)
|
2019-06-24 01:00:48 +00:00
|
|
|
tool_change(target_extruder, false);
|
2018-01-04 11:06:34 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// Lift Z axis
|
|
|
|
if (park_point.z > 0)
|
2019-09-29 09:25:39 +00:00
|
|
|
do_blocking_move_to_z(_MIN(current_position.z + park_point.z, Z_MAX_POS), feedRate_t(NOZZLE_PARK_Z_FEEDRATE));
|
2018-01-04 11:06:34 +00:00
|
|
|
|
|
|
|
// Unload filament
|
2019-02-01 01:10:52 +00:00
|
|
|
#if ENABLED(PRUSA_MMU2)
|
|
|
|
mmu2.unload();
|
|
|
|
#else
|
|
|
|
#if EXTRUDERS > 1 && ENABLED(FILAMENT_UNLOAD_ALL_EXTRUDERS)
|
|
|
|
if (!parser.seenval('T')) {
|
|
|
|
HOTEND_LOOP() {
|
2019-06-24 01:00:48 +00:00
|
|
|
if (e != active_extruder) tool_change(e, false);
|
2019-03-14 07:26:07 +00:00
|
|
|
unload_filament(-fc_settings[e].unload_length, true, PAUSE_MODE_UNLOAD_FILAMENT);
|
2019-02-01 01:10:52 +00:00
|
|
|
}
|
2018-01-04 11:06:34 +00:00
|
|
|
}
|
2019-02-01 01:10:52 +00:00
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
// Unload length
|
|
|
|
const float unload_length = -ABS(parser.seen('U') ? parser.value_axis_units(E_AXIS)
|
|
|
|
: fc_settings[target_extruder].unload_length);
|
|
|
|
|
2019-05-02 02:55:58 +00:00
|
|
|
unload_filament(unload_length, true, PAUSE_MODE_UNLOAD_FILAMENT
|
|
|
|
#if ALL(FILAMENT_UNLOAD_ALL_EXTRUDERS, MIXING_EXTRUDER)
|
|
|
|
, mix_multiplier
|
|
|
|
#endif
|
|
|
|
);
|
2018-01-04 11:06:34 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Restore Z axis
|
|
|
|
if (park_point.z > 0)
|
2019-09-29 09:25:39 +00:00
|
|
|
do_blocking_move_to_z(_MAX(current_position.z - park_point.z, 0), feedRate_t(NOZZLE_PARK_Z_FEEDRATE));
|
2018-01-04 11:06:34 +00:00
|
|
|
|
2019-02-01 01:10:52 +00:00
|
|
|
#if EXTRUDERS > 1 && DISABLED(PRUSA_MMU2)
|
2018-01-04 11:06:34 +00:00
|
|
|
// Restore toolhead if it was changed
|
|
|
|
if (active_extruder_before_filament_change != active_extruder)
|
2019-06-24 01:00:48 +00:00
|
|
|
tool_change(active_extruder_before_filament_change, false);
|
2018-01-04 11:06:34 +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
|
|
|
|
|
2018-01-04 11:06:34 +00:00
|
|
|
// Show status screen
|
2018-10-30 21:34:45 +00:00
|
|
|
#if HAS_LCD_MENU
|
2019-03-14 07:26:07 +00:00
|
|
|
lcd_pause_show_message(PAUSE_MESSAGE_STATUS);
|
2018-01-04 11:06:34 +00:00
|
|
|
#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
|