2017-09-06 13:28:31 +02:00
|
|
|
/**
|
|
|
|
* Marlin 3D Printer Firmware
|
2020-02-03 15:00:57 +01:00
|
|
|
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
2017-09-06 13:28:31 +02:00
|
|
|
*
|
|
|
|
* Based on Sprinter and grbl.
|
2019-06-28 06:57:50 +02:00
|
|
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
2017-09-06 13:28:31 +02: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-18 00:24:56 +02:00
|
|
|
#include "../../inc/MarlinConfig.h"
|
|
|
|
|
2019-03-13 06:42:50 +01:00
|
|
|
#if HAS_DUPLICATION_MODE
|
2017-09-18 00:24:56 +02:00
|
|
|
|
2018-10-17 18:11:41 +02:00
|
|
|
//#define DEBUG_DXC_MODE
|
|
|
|
|
2017-09-18 00:24:56 +02:00
|
|
|
#include "../gcode.h"
|
|
|
|
#include "../../module/motion.h"
|
|
|
|
#include "../../module/stepper.h"
|
2018-09-02 17:18:59 +02:00
|
|
|
#include "../../module/tool_change.h"
|
|
|
|
#include "../../module/planner.h"
|
2017-09-18 00:24:56 +02:00
|
|
|
|
2019-03-16 04:46:27 +01:00
|
|
|
#define DEBUG_OUT ENABLED(DEBUG_DXC_MODE)
|
|
|
|
#include "../../core/debug_out.h"
|
|
|
|
|
2017-09-06 13:28:31 +02:00
|
|
|
#if ENABLED(DUAL_X_CARRIAGE)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* M605: Set dual x-carriage movement mode
|
|
|
|
*
|
2019-03-16 04:46:27 +01:00
|
|
|
* M605 S0 : (FULL_CONTROL) The slicer has full control over both X-carriages and can achieve optimal travel
|
|
|
|
* results as long as it supports dual X-carriages.
|
2019-04-04 03:21:06 +02:00
|
|
|
*
|
2019-03-16 04:46:27 +01:00
|
|
|
* M605 S1 : (AUTO_PARK) The firmware automatically parks and unparks the X-carriages on tool-change so that
|
|
|
|
* additional slicer support is not required.
|
2019-04-04 03:21:06 +02:00
|
|
|
*
|
2019-03-16 04:46:27 +01:00
|
|
|
* M605 S2 X R : (DUPLICATION) The firmware moves the second X-carriage and extruder in synchronization with
|
|
|
|
* the first X-carriage and extruder, to print 2 copies of the same object at the same time.
|
|
|
|
* Set the constant X-offset and temperature differential with M605 S2 X[offs] R[deg] and
|
|
|
|
* follow with "M605 S2" to initiate duplicated movement. For example, use "M605 S2 X100 R2" to
|
|
|
|
* make a copy 100mm to the right with E1 2° hotter than E0.
|
|
|
|
*
|
|
|
|
* M605 S3 : (MIRRORED) Formbot/Vivedino-inspired mirrored mode in which the second extruder duplicates
|
|
|
|
* the movement of the first except the second extruder is reversed in the X axis.
|
|
|
|
* The temperature differential and initial X offset must be set with "M605 S2 X[offs] R[deg]",
|
|
|
|
* then followed by "M605 S3" to initiate mirrored movement.
|
|
|
|
*
|
2018-09-02 17:18:59 +02:00
|
|
|
* M605 W : IDEX What? command.
|
2017-09-06 13:28:31 +02:00
|
|
|
*
|
2019-03-16 04:46:27 +01:00
|
|
|
* Note: the X axis should be homed after changing Dual X-carriage mode.
|
2017-09-06 13:28:31 +02:00
|
|
|
*/
|
2017-09-18 00:24:56 +02:00
|
|
|
void GcodeSuite::M605() {
|
2018-05-12 08:38:02 +02:00
|
|
|
planner.synchronize();
|
2018-09-02 17:18:59 +02:00
|
|
|
|
2018-09-04 06:15:31 +02:00
|
|
|
if (parser.seen('S')) {
|
2018-09-17 08:06:22 +02:00
|
|
|
const DualXMode previous_mode = dual_x_carriage_mode;
|
|
|
|
|
2018-09-02 17:18:59 +02:00
|
|
|
dual_x_carriage_mode = (DualXMode)parser.value_byte();
|
2019-03-16 04:46:27 +01:00
|
|
|
mirrored_duplication_mode = false;
|
2019-03-13 06:42:50 +01:00
|
|
|
|
2019-03-16 04:46:27 +01:00
|
|
|
if (dual_x_carriage_mode == DXC_MIRRORED_MODE) {
|
2018-09-17 08:06:22 +02:00
|
|
|
if (previous_mode != DXC_DUPLICATION_MODE) {
|
2019-02-03 06:32:48 +01:00
|
|
|
SERIAL_ECHOLNPGM("Printer must be in DXC_DUPLICATION_MODE prior to ");
|
2019-03-16 04:46:27 +01:00
|
|
|
SERIAL_ECHOLNPGM("specifying DXC_MIRRORED_MODE.");
|
2018-09-17 08:06:22 +02:00
|
|
|
dual_x_carriage_mode = DEFAULT_DUAL_X_CARRIAGE_MODE;
|
|
|
|
return;
|
|
|
|
}
|
2019-03-16 04:46:27 +01:00
|
|
|
mirrored_duplication_mode = true;
|
2018-09-17 08:06:22 +02:00
|
|
|
stepper.set_directions();
|
2019-09-29 11:25:39 +02:00
|
|
|
float x_jog = current_position.x - .1;
|
2018-09-17 08:06:22 +02:00
|
|
|
for (uint8_t i = 2; --i;) {
|
2019-09-29 11:25:39 +02:00
|
|
|
planner.buffer_line(x_jog, current_position.y, current_position.z, current_position.e, feedrate_mm_s, 0);
|
2018-09-17 08:06:22 +02:00
|
|
|
x_jog += .1;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2018-09-02 17:18:59 +02:00
|
|
|
|
|
|
|
switch (dual_x_carriage_mode) {
|
|
|
|
case DXC_FULL_CONTROL_MODE:
|
|
|
|
case DXC_AUTO_PARK_MODE:
|
|
|
|
break;
|
|
|
|
case DXC_DUPLICATION_MODE:
|
2019-07-06 01:01:21 +02:00
|
|
|
if (parser.seen('X')) duplicate_extruder_x_offset = _MAX(parser.value_linear_units(), X2_MIN_POS - x_home_pos(0));
|
2018-09-04 06:15:31 +02:00
|
|
|
if (parser.seen('R')) duplicate_extruder_temp_offset = parser.value_celsius_diff();
|
|
|
|
if (active_extruder != 0) tool_change(0);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
dual_x_carriage_mode = DEFAULT_DUAL_X_CARRIAGE_MODE;
|
2018-09-02 17:18:59 +02:00
|
|
|
break;
|
|
|
|
}
|
2018-09-04 06:15:31 +02:00
|
|
|
active_extruder_parked = false;
|
|
|
|
extruder_duplication_enabled = false;
|
2018-09-17 08:06:22 +02:00
|
|
|
stepper.set_directions();
|
2018-09-04 06:15:31 +02:00
|
|
|
delayed_move_time = 0;
|
|
|
|
}
|
|
|
|
else if (!parser.seen('W')) // if no S or W parameter, the DXC mode gets reset to the user's default
|
|
|
|
dual_x_carriage_mode = DEFAULT_DUAL_X_CARRIAGE_MODE;
|
2018-09-02 17:18:59 +02:00
|
|
|
|
2018-10-17 18:11:41 +02:00
|
|
|
#ifdef DEBUG_DXC_MODE
|
|
|
|
|
|
|
|
if (parser.seen('W')) {
|
2019-03-16 04:46:27 +01:00
|
|
|
DEBUG_ECHO_START();
|
|
|
|
DEBUG_ECHOPGM("Dual X Carriage Mode ");
|
2018-10-17 18:11:41 +02:00
|
|
|
switch (dual_x_carriage_mode) {
|
2019-03-16 04:46:27 +01:00
|
|
|
case DXC_FULL_CONTROL_MODE: DEBUG_ECHOPGM("FULL_CONTROL"); break;
|
|
|
|
case DXC_AUTO_PARK_MODE: DEBUG_ECHOPGM("AUTO_PARK"); break;
|
|
|
|
case DXC_DUPLICATION_MODE: DEBUG_ECHOPGM("DUPLICATION"); break;
|
|
|
|
case DXC_MIRRORED_MODE: DEBUG_ECHOPGM("MIRRORED"); break;
|
2018-10-17 18:11:41 +02:00
|
|
|
}
|
2019-03-16 04:46:27 +01:00
|
|
|
DEBUG_ECHOPAIR("\nActive Ext: ", int(active_extruder));
|
|
|
|
if (!active_extruder_parked) DEBUG_ECHOPGM(" NOT ");
|
|
|
|
DEBUG_ECHOPGM(" parked.");
|
2019-09-29 11:25:39 +02:00
|
|
|
DEBUG_ECHOPAIR("\nactive_extruder_x_pos: ", current_position.x);
|
2019-03-16 04:46:27 +01:00
|
|
|
DEBUG_ECHOPAIR("\ninactive_extruder_x_pos: ", inactive_extruder_x_pos);
|
|
|
|
DEBUG_ECHOPAIR("\nextruder_duplication_enabled: ", int(extruder_duplication_enabled));
|
|
|
|
DEBUG_ECHOPAIR("\nduplicate_extruder_x_offset: ", duplicate_extruder_x_offset);
|
|
|
|
DEBUG_ECHOPAIR("\nduplicate_extruder_temp_offset: ", duplicate_extruder_temp_offset);
|
|
|
|
DEBUG_ECHOPAIR("\ndelayed_move_time: ", delayed_move_time);
|
|
|
|
DEBUG_ECHOPAIR("\nX1 Home X: ", x_home_pos(0), "\nX1_MIN_POS=", int(X1_MIN_POS), "\nX1_MAX_POS=", int(X1_MAX_POS));
|
|
|
|
DEBUG_ECHOPAIR("\nX2 Home X: ", x_home_pos(1), "\nX2_MIN_POS=", int(X2_MIN_POS), "\nX2_MAX_POS=", int(X2_MAX_POS));
|
|
|
|
DEBUG_ECHOPAIR("\nX2_HOME_DIR=", int(X2_HOME_DIR), "\nX2_HOME_POS=", int(X2_HOME_POS));
|
|
|
|
DEBUG_ECHOPAIR("\nDEFAULT_DUAL_X_CARRIAGE_MODE=", STRINGIFY(DEFAULT_DUAL_X_CARRIAGE_MODE));
|
2019-05-28 02:51:29 +02:00
|
|
|
DEBUG_ECHOPAIR("\toolchange_settings.z_raise=", toolchange_settings.z_raise);
|
2019-03-16 04:46:27 +01:00
|
|
|
DEBUG_ECHOPAIR("\nDEFAULT_DUPLICATION_X_OFFSET=", int(DEFAULT_DUPLICATION_X_OFFSET));
|
|
|
|
DEBUG_EOL();
|
|
|
|
|
|
|
|
HOTEND_LOOP() {
|
2020-02-02 00:05:42 +01:00
|
|
|
DEBUG_ECHOPAIR_P(SP_T_STR, int(e));
|
2020-03-01 17:36:15 +01:00
|
|
|
LOOP_XYZ(a) DEBUG_ECHOPAIR(" hotend_offset[", int(e), "].", XYZ_CHAR(a) | 0x20, "=", hotend_offset[e][a]);
|
2019-03-16 04:46:27 +01:00
|
|
|
DEBUG_EOL();
|
2018-09-17 08:06:22 +02:00
|
|
|
}
|
2019-03-16 04:46:27 +01:00
|
|
|
DEBUG_EOL();
|
2018-09-17 08:06:22 +02:00
|
|
|
}
|
2018-10-17 18:11:41 +02:00
|
|
|
#endif // DEBUG_DXC_MODE
|
2017-09-06 13:28:31 +02:00
|
|
|
}
|
|
|
|
|
2019-03-13 06:42:50 +01:00
|
|
|
#elif ENABLED(MULTI_NOZZLE_DUPLICATION)
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2019-03-13 06:42:50 +01:00
|
|
|
/**
|
|
|
|
* M605: Set multi-nozzle duplication mode
|
|
|
|
*
|
|
|
|
* S2 - Enable duplication mode
|
|
|
|
* P[mask] - Bit-mask of nozzles to include in the duplication set.
|
|
|
|
* A value of 0 disables duplication.
|
|
|
|
* E[index] - Last nozzle index to include in the duplication set.
|
|
|
|
* A value of 0 disables duplication.
|
|
|
|
*/
|
2017-09-18 00:24:56 +02:00
|
|
|
void GcodeSuite::M605() {
|
2019-06-13 03:01:08 +02:00
|
|
|
bool ena = false;
|
2019-03-13 06:42:50 +01:00
|
|
|
if (parser.seen("EPS")) {
|
|
|
|
planner.synchronize();
|
|
|
|
if (parser.seenval('P')) duplication_e_mask = parser.value_int(); // Set the mask directly
|
2019-06-13 03:01:08 +02:00
|
|
|
else if (parser.seenval('E')) duplication_e_mask = pow(2, parser.value_int() + 1) - 1; // Set the mask by E index
|
|
|
|
ena = (2 == parser.intval('S', extruder_duplication_enabled ? 2 : 0));
|
2019-03-13 06:42:50 +01:00
|
|
|
extruder_duplication_enabled = ena && (duplication_e_mask >= 3);
|
|
|
|
}
|
2017-09-06 13:28:31 +02:00
|
|
|
SERIAL_ECHO_START();
|
2020-02-26 10:02:03 +01:00
|
|
|
SERIAL_ECHOPGM(STR_DUPLICATION_MODE);
|
2019-03-13 06:42:50 +01:00
|
|
|
serialprint_onoff(extruder_duplication_enabled);
|
|
|
|
if (ena) {
|
|
|
|
SERIAL_ECHOPGM(" ( ");
|
|
|
|
HOTEND_LOOP() if (TEST(duplication_e_mask, e)) { SERIAL_ECHO(e); SERIAL_CHAR(' '); }
|
|
|
|
SERIAL_CHAR(')');
|
|
|
|
}
|
|
|
|
SERIAL_EOL();
|
2017-09-06 13:28:31 +02:00
|
|
|
}
|
|
|
|
|
2019-03-13 06:42:50 +01:00
|
|
|
#endif // MULTI_NOZZLE_DUPLICATION
|
2017-09-18 00:24:56 +02:00
|
|
|
|
2019-03-13 06:42:50 +01:00
|
|
|
#endif // HAS_DUPICATION_MODE
|