♻️ Patches for Zero Extruders (with TMC)

This commit is contained in:
Scott Lahteine 2021-06-01 20:23:37 -05:00
parent 4194cdda5b
commit d3c56a76e7
10 changed files with 618 additions and 567 deletions

View file

@ -360,7 +360,7 @@ struct XYZval {
FI void set(const XYval<T> pxy, const T pz) { x = pxy.x; y = pxy.y; z = pz; } FI void set(const XYval<T> pxy, const T pz) { x = pxy.x; y = pxy.y; z = pz; }
FI void set(const T (&arr)[XY]) { x = arr[0]; y = arr[1]; } FI void set(const T (&arr)[XY]) { x = arr[0]; y = arr[1]; }
FI void set(const T (&arr)[LINEAR_AXES]) { LINEAR_AXIS_CODE(x = arr[0], y = arr[1], z = arr[2]); } FI void set(const T (&arr)[LINEAR_AXES]) { LINEAR_AXIS_CODE(x = arr[0], y = arr[1], z = arr[2]); }
#if LINEAR_AXES >= XYZ #if HAS_Z_AXIS
FI void set(LINEAR_AXIS_LIST(const T px, const T py, const T pz)) FI void set(LINEAR_AXIS_LIST(const T px, const T py, const T pz))
{ LINEAR_AXIS_CODE(x = px, y = py, z = pz); } { LINEAR_AXIS_CODE(x = px, y = py, z = pz); }
#endif #endif
@ -475,7 +475,7 @@ struct XYZEval {
FI void set(const T px, const T py) { x = px; y = py; } FI void set(const T px, const T py) { x = px; y = py; }
FI void set(const XYval<T> pxy) { x = pxy.x; y = pxy.y; } FI void set(const XYval<T> pxy) { x = pxy.x; y = pxy.y; }
FI void set(const XYZval<T> pxyz) { set(LINEAR_AXIS_LIST(pxyz.x, pxyz.y, pxyz.z)); } FI void set(const XYZval<T> pxyz) { set(LINEAR_AXIS_LIST(pxyz.x, pxyz.y, pxyz.z)); }
#if LINEAR_AXES >= XYZ #if HAS_Z_AXIS
FI void set(LINEAR_AXIS_LIST(const T px, const T py, const T pz)) { FI void set(LINEAR_AXIS_LIST(const T px, const T py, const T pz)) {
LINEAR_AXIS_CODE(x = px, y = py, z = pz); LINEAR_AXIS_CODE(x = px, y = py, z = pz);
} }

View file

@ -770,6 +770,7 @@
#endif #endif
} }
#if LINEAR_AXES >= XY
if (print_y) { if (print_y) {
#if AXIS_IS_TMC(Y) #if AXIS_IS_TMC(Y)
tmc_status(stepperY, i); tmc_status(stepperY, i);
@ -778,8 +779,9 @@
tmc_status(stepperY2, i); tmc_status(stepperY2, i);
#endif #endif
} }
#endif
if (print_z) { if (TERN0(HAS_Z_AXIS, print_z)) {
#if AXIS_IS_TMC(Z) #if AXIS_IS_TMC(Z)
tmc_status(stepperZ, i); tmc_status(stepperZ, i);
#endif #endif
@ -794,7 +796,7 @@
#endif #endif
} }
if (print_e) { if (TERN0(HAS_EXTRUDERS, print_e)) {
#if AXIS_IS_TMC(E0) #if AXIS_IS_TMC(E0)
tmc_status(stepperE0, i); tmc_status(stepperE0, i);
#endif #endif
@ -837,6 +839,7 @@
#endif #endif
} }
#if LINEAR_AXES >= XY
if (print_y) { if (print_y) {
#if AXIS_IS_TMC(Y) #if AXIS_IS_TMC(Y)
tmc_parse_drv_status(stepperY, i); tmc_parse_drv_status(stepperY, i);
@ -845,8 +848,9 @@
tmc_parse_drv_status(stepperY2, i); tmc_parse_drv_status(stepperY2, i);
#endif #endif
} }
#endif
if (print_z) { if (TERN0(HAS_Z_AXIS, print_z)) {
#if AXIS_IS_TMC(Z) #if AXIS_IS_TMC(Z)
tmc_parse_drv_status(stepperZ, i); tmc_parse_drv_status(stepperZ, i);
#endif #endif
@ -861,7 +865,7 @@
#endif #endif
} }
if (print_e) { if (TERN0(HAS_EXTRUDERS, print_e)) {
#if AXIS_IS_TMC(E0) #if AXIS_IS_TMC(E0)
tmc_parse_drv_status(stepperE0, i); tmc_parse_drv_status(stepperE0, i);
#endif #endif
@ -1037,6 +1041,7 @@
#endif #endif
} }
#if LINEAR_AXES >= XY
if (print_y) { if (print_y) {
#if AXIS_IS_TMC(Y) #if AXIS_IS_TMC(Y)
tmc_get_registers(stepperY, i); tmc_get_registers(stepperY, i);
@ -1045,8 +1050,9 @@
tmc_get_registers(stepperY2, i); tmc_get_registers(stepperY2, i);
#endif #endif
} }
#endif
if (print_z) { if (TERN0(HAS_Z_AXIS, print_z)) {
#if AXIS_IS_TMC(Z) #if AXIS_IS_TMC(Z)
tmc_get_registers(stepperZ, i); tmc_get_registers(stepperZ, i);
#endif #endif
@ -1061,7 +1067,7 @@
#endif #endif
} }
if (print_e) { if (TERN0(HAS_EXTRUDERS, print_e)) {
#if AXIS_IS_TMC(E0) #if AXIS_IS_TMC(E0)
tmc_get_registers(stepperE0, i); tmc_get_registers(stepperE0, i);
#endif #endif
@ -1242,6 +1248,7 @@ void test_tmc_connection(
#endif #endif
} }
#if LINEAR_AXES >= XY
if (test_y) { if (test_y) {
#if AXIS_IS_TMC(Y) #if AXIS_IS_TMC(Y)
axis_connection += test_connection(stepperY); axis_connection += test_connection(stepperY);
@ -1250,8 +1257,9 @@ void test_tmc_connection(
axis_connection += test_connection(stepperY2); axis_connection += test_connection(stepperY2);
#endif #endif
} }
#endif
if (test_z) { if (TERN0(HAS_Z_AXIS, test_z)) {
#if AXIS_IS_TMC(Z) #if AXIS_IS_TMC(Z)
axis_connection += test_connection(stepperZ); axis_connection += test_connection(stepperZ);
#endif #endif
@ -1266,7 +1274,7 @@ void test_tmc_connection(
#endif #endif
} }
if (test_e) { if (TERN0(HAS_EXTRUDERS, test_e)) {
#if AXIS_IS_TMC(E0) #if AXIS_IS_TMC(E0)
axis_connection += test_connection(stepperE0); axis_connection += test_connection(stepperE0);
#endif #endif

View file

@ -252,6 +252,8 @@ void GcodeSuite::M906() {
if (index == 1) L6470_SET_KVAL_HOLD(X2); if (index == 1) L6470_SET_KVAL_HOLD(X2);
#endif #endif
break; break;
#if LINEAR_AXES >= XY
case Y_AXIS: case Y_AXIS:
#if AXIS_IS_L64XX(Y) #if AXIS_IS_L64XX(Y)
if (index == 0) L6470_SET_KVAL_HOLD(Y); if (index == 0) L6470_SET_KVAL_HOLD(Y);
@ -260,6 +262,9 @@ void GcodeSuite::M906() {
if (index == 1) L6470_SET_KVAL_HOLD(Y2); if (index == 1) L6470_SET_KVAL_HOLD(Y2);
#endif #endif
break; break;
#endif
#if HAS_Z_AXIS
case Z_AXIS: case Z_AXIS:
#if AXIS_IS_L64XX(Z) #if AXIS_IS_L64XX(Z)
if (index == 0) L6470_SET_KVAL_HOLD(Z); if (index == 0) L6470_SET_KVAL_HOLD(Z);
@ -274,6 +279,9 @@ void GcodeSuite::M906() {
if (index == 3) L6470_SET_KVAL_HOLD(Z4); if (index == 3) L6470_SET_KVAL_HOLD(Z4);
#endif #endif
break; break;
#endif
#if HAS_EXTRUDERS
case E_AXIS: { case E_AXIS: {
const int8_t target_extruder = get_target_extruder_from_command(); const int8_t target_extruder = get_target_extruder_from_command();
if (target_extruder < 0) return; if (target_extruder < 0) return;
@ -304,6 +312,7 @@ void GcodeSuite::M906() {
#endif #endif
} }
} break; } break;
#endif
} }
} }

View file

@ -60,6 +60,8 @@ static void set_stealth_status(const bool enable, const int8_t target_extruder)
if (index == 1) TMC_SET_STEALTH(X2); if (index == 1) TMC_SET_STEALTH(X2);
#endif #endif
break; break;
#if LINEAR_AXES >= XY
case Y_AXIS: case Y_AXIS:
#if AXIS_HAS_STEALTHCHOP(Y) #if AXIS_HAS_STEALTHCHOP(Y)
if (index == 0) TMC_SET_STEALTH(Y); if (index == 0) TMC_SET_STEALTH(Y);
@ -68,6 +70,9 @@ static void set_stealth_status(const bool enable, const int8_t target_extruder)
if (index == 1) TMC_SET_STEALTH(Y2); if (index == 1) TMC_SET_STEALTH(Y2);
#endif #endif
break; break;
#endif
#if HAS_Z_AXIS
case Z_AXIS: case Z_AXIS:
#if AXIS_HAS_STEALTHCHOP(Z) #if AXIS_HAS_STEALTHCHOP(Z)
if (index == 0) TMC_SET_STEALTH(Z); if (index == 0) TMC_SET_STEALTH(Z);
@ -82,6 +87,9 @@ static void set_stealth_status(const bool enable, const int8_t target_extruder)
if (index == 3) TMC_SET_STEALTH(Z4); if (index == 3) TMC_SET_STEALTH(Z4);
#endif #endif
break; break;
#endif
#if HAS_EXTRUDERS
case E_AXIS: { case E_AXIS: {
if (target_extruder < 0) return; if (target_extruder < 0) return;
switch (target_extruder) { switch (target_extruder) {
@ -111,6 +119,7 @@ static void set_stealth_status(const bool enable, const int8_t target_extruder)
#endif #endif
} }
} break; } break;
#endif
} }
} }
} }

View file

@ -63,6 +63,8 @@ void GcodeSuite::M906() {
if (index == 1) TMC_SET_CURRENT(X2); if (index == 1) TMC_SET_CURRENT(X2);
#endif #endif
break; break;
#if LINEAR_AXES >= XY
case Y_AXIS: case Y_AXIS:
#if AXIS_IS_TMC(Y) #if AXIS_IS_TMC(Y)
if (index == 0) TMC_SET_CURRENT(Y); if (index == 0) TMC_SET_CURRENT(Y);
@ -71,6 +73,9 @@ void GcodeSuite::M906() {
if (index == 1) TMC_SET_CURRENT(Y2); if (index == 1) TMC_SET_CURRENT(Y2);
#endif #endif
break; break;
#endif
#if HAS_Z_AXIS
case Z_AXIS: case Z_AXIS:
#if AXIS_IS_TMC(Z) #if AXIS_IS_TMC(Z)
if (index == 0) TMC_SET_CURRENT(Z); if (index == 0) TMC_SET_CURRENT(Z);
@ -85,6 +90,9 @@ void GcodeSuite::M906() {
if (index == 3) TMC_SET_CURRENT(Z4); if (index == 3) TMC_SET_CURRENT(Z4);
#endif #endif
break; break;
#endif
#if HAS_EXTRUDERS
case E_AXIS: { case E_AXIS: {
const int8_t target_extruder = get_target_extruder_from_command(); const int8_t target_extruder = get_target_extruder_from_command();
if (target_extruder < 0) return; if (target_extruder < 0) return;
@ -115,6 +123,7 @@ void GcodeSuite::M906() {
#endif #endif
} }
} break; } break;
#endif
} }
} }

View file

@ -624,6 +624,10 @@
#define LOGICAL_AXES LINEAR_AXES #define LOGICAL_AXES LINEAR_AXES
#endif #endif
#if LINEAR_AXES >= XYZ
#define HAS_Z_AXIS 1
#endif
/** /**
* DISTINCT_E_FACTORS is set to give extruders (some) individual settings. * DISTINCT_E_FACTORS is set to give extruders (some) individual settings.
* *

View file

@ -2959,6 +2959,10 @@ static_assert( _ARR_TEST(3,0) && _ARR_TEST(3,1) && _ARR_TEST(3,2)
#error "MECHANICAL_GANTRY_CALIBRATION Requires GANTRY_CALIBRATION_EXTRA_HEIGHT to be set." #error "MECHANICAL_GANTRY_CALIBRATION Requires GANTRY_CALIBRATION_EXTRA_HEIGHT to be set."
#elif !defined(GANTRY_CALIBRATION_FEEDRATE) #elif !defined(GANTRY_CALIBRATION_FEEDRATE)
#error "MECHANICAL_GANTRY_CALIBRATION Requires GANTRY_CALIBRATION_FEEDRATE to be set." #error "MECHANICAL_GANTRY_CALIBRATION Requires GANTRY_CALIBRATION_FEEDRATE to be set."
#elif ENABLED(Z_MULTI_ENDSTOPS)
#error "Sorry! MECHANICAL_GANTRY_CALIBRATION cannot be used with Z_MULTI_ENDSTOPS."
#elif ENABLED(Z_STEPPER_AUTO_ALIGN)
#error "Sorry! MECHANICAL_GANTRY_CALIBRATION cannot be used with Z_STEPPER_AUTO_ALIGN."
#endif #endif
#if defined(GANTRY_CALIBRATION_SAFE_POSITION) && !defined(GANTRY_CALIBRATION_XY_PARK_FEEDRATE) #if defined(GANTRY_CALIBRATION_SAFE_POSITION) && !defined(GANTRY_CALIBRATION_XY_PARK_FEEDRATE)
#error "GANTRY_CALIBRATION_SAFE_POSITION Requires GANTRY_CALIBRATION_XY_PARK_FEEDRATE to be set." #error "GANTRY_CALIBRATION_SAFE_POSITION Requires GANTRY_CALIBRATION_XY_PARK_FEEDRATE to be set."

View file

@ -181,11 +181,11 @@ void cubic_b_spline(
t = new_t; t = new_t;
// Compute and send new position // Compute and send new position
xyze_pos_t new_bez = { xyze_pos_t new_bez = LOGICAL_AXIS_ARRAY(
interp(position.e, target.e, t), // FIXME. These two are wrong, since the parameter t is not linear in the distance.
new_pos0, new_pos1, new_pos0, new_pos1,
interp(position.z, target.z, t), // FIXME. These two are wrong, since the parameter t is interp(position.z, target.z, t)
interp(position.e, target.e, t) // not linear in the distance. );
};
apply_motion_limits(new_bez); apply_motion_limits(new_bez);
bez_target = new_bez; bez_target = new_bez;

View file

@ -259,7 +259,7 @@ xyze_int8_t Stepper::count_direction{0};
#define DUAL_ENDSTOP_APPLY_STEP(A,V) \ #define DUAL_ENDSTOP_APPLY_STEP(A,V) \
if (separate_multi_axis) { \ if (separate_multi_axis) { \
if (A##_HOME_TO_MIN) { \ if (ENABLED(A##_HOME_TO_MIN)) { \
if (TERN0(HAS_##A##_MIN, !(TEST(endstops.state(), A##_MIN) && count_direction[_AXIS(A)] < 0) && !locked_##A##_motor)) A##_STEP_WRITE(V); \ if (TERN0(HAS_##A##_MIN, !(TEST(endstops.state(), A##_MIN) && count_direction[_AXIS(A)] < 0) && !locked_##A##_motor)) A##_STEP_WRITE(V); \
if (TERN0(HAS_##A##2_MIN, !(TEST(endstops.state(), A##2_MIN) && count_direction[_AXIS(A)] < 0) && !locked_##A##2_motor)) A##2_STEP_WRITE(V); \ if (TERN0(HAS_##A##2_MIN, !(TEST(endstops.state(), A##2_MIN) && count_direction[_AXIS(A)] < 0) && !locked_##A##2_motor)) A##2_STEP_WRITE(V); \
} \ } \
@ -285,7 +285,7 @@ xyze_int8_t Stepper::count_direction{0};
#define TRIPLE_ENDSTOP_APPLY_STEP(A,V) \ #define TRIPLE_ENDSTOP_APPLY_STEP(A,V) \
if (separate_multi_axis) { \ if (separate_multi_axis) { \
if (A##_HOME_TO_MIN) { \ if (ENABLED(A##_HOME_TO_MIN)) { \
if (!(TEST(endstops.state(), A##_MIN) && count_direction[_AXIS(A)] < 0) && !locked_##A##_motor) A##_STEP_WRITE(V); \ if (!(TEST(endstops.state(), A##_MIN) && count_direction[_AXIS(A)] < 0) && !locked_##A##_motor) A##_STEP_WRITE(V); \
if (!(TEST(endstops.state(), A##2_MIN) && count_direction[_AXIS(A)] < 0) && !locked_##A##2_motor) A##2_STEP_WRITE(V); \ if (!(TEST(endstops.state(), A##2_MIN) && count_direction[_AXIS(A)] < 0) && !locked_##A##2_motor) A##2_STEP_WRITE(V); \
if (!(TEST(endstops.state(), A##3_MIN) && count_direction[_AXIS(A)] < 0) && !locked_##A##3_motor) A##3_STEP_WRITE(V); \ if (!(TEST(endstops.state(), A##3_MIN) && count_direction[_AXIS(A)] < 0) && !locked_##A##3_motor) A##3_STEP_WRITE(V); \
@ -316,7 +316,7 @@ xyze_int8_t Stepper::count_direction{0};
#define QUAD_ENDSTOP_APPLY_STEP(A,V) \ #define QUAD_ENDSTOP_APPLY_STEP(A,V) \
if (separate_multi_axis) { \ if (separate_multi_axis) { \
if (A##_HOME_TO_MIN) { \ if (ENABLED(A##_HOME_TO_MIN)) { \
if (!(TEST(endstops.state(), A##_MIN) && count_direction[_AXIS(A)] < 0) && !locked_##A##_motor) A##_STEP_WRITE(V); \ if (!(TEST(endstops.state(), A##_MIN) && count_direction[_AXIS(A)] < 0) && !locked_##A##_motor) A##_STEP_WRITE(V); \
if (!(TEST(endstops.state(), A##2_MIN) && count_direction[_AXIS(A)] < 0) && !locked_##A##2_motor) A##2_STEP_WRITE(V); \ if (!(TEST(endstops.state(), A##2_MIN) && count_direction[_AXIS(A)] < 0) && !locked_##A##2_motor) A##2_STEP_WRITE(V); \
if (!(TEST(endstops.state(), A##3_MIN) && count_direction[_AXIS(A)] < 0) && !locked_##A##3_motor) A##3_STEP_WRITE(V); \ if (!(TEST(endstops.state(), A##3_MIN) && count_direction[_AXIS(A)] < 0) && !locked_##A##3_motor) A##3_STEP_WRITE(V); \

View file

@ -438,6 +438,392 @@
#define Z_STOP_PIN Z_MAX_PIN #define Z_STOP_PIN Z_MAX_PIN
#endif #endif
// Filament Sensor first pin alias
#if HAS_FILAMENT_SENSOR
#define FIL_RUNOUT1_PIN FIL_RUNOUT_PIN
#else
#undef FIL_RUNOUT_PIN
#undef FIL_RUNOUT1_PIN
#endif
#ifndef LCD_PINS_D4
#define LCD_PINS_D4 -1
#endif
#if HAS_MARLINUI_HD44780 || TOUCH_UI_ULTIPANEL
#ifndef LCD_PINS_D5
#define LCD_PINS_D5 -1
#endif
#ifndef LCD_PINS_D6
#define LCD_PINS_D6 -1
#endif
#ifndef LCD_PINS_D7
#define LCD_PINS_D7 -1
#endif
#endif
/**
* Auto-Assignment for Dual X, Dual Y, Multi-Z Steppers
*
* By default X2 is assigned to the next open E plug
* on the board, then in order, Y2, Z2, Z3. These can be
* overridden in Configuration.h or Configuration_adv.h.
*/
#define __PEXI(p,q) PIN_EXISTS(E##p##_##q)
#define _PEXI(p,q) __PEXI(p,q)
#define __EPIN(p,q) E##p##_##q##_PIN
#define _EPIN(p,q) __EPIN(p,q)
#define DIAG_REMAPPED(p,q) (PIN_EXISTS(q) && _EPIN(p##_E_INDEX, DIAG) == q##_PIN)
// The X2 axis, if any, should be the next open extruder port
#define X2_E_INDEX E_STEPPERS
#if EITHER(DUAL_X_CARRIAGE, X_DUAL_STEPPER_DRIVERS)
#ifndef X2_STEP_PIN
#define X2_STEP_PIN _EPIN(X2_E_INDEX, STEP)
#define X2_DIR_PIN _EPIN(X2_E_INDEX, DIR)
#define X2_ENABLE_PIN _EPIN(X2_E_INDEX, ENABLE)
#if X2_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(X2_STEP)
#error "No E stepper plug left for X2!"
#endif
#endif
#ifndef X2_MS1_PIN
#define X2_MS1_PIN _EPIN(X2_E_INDEX, MS1)
#endif
#ifndef X2_MS2_PIN
#define X2_MS2_PIN _EPIN(X2_E_INDEX, MS2)
#endif
#ifndef X2_MS3_PIN
#define X2_MS3_PIN _EPIN(X2_E_INDEX, MS3)
#endif
#if AXIS_HAS_SPI(X2) && !defined(X2_CS_PIN)
#define X2_CS_PIN _EPIN(X2_E_INDEX, CS)
#endif
#if AXIS_HAS_UART(X2)
#ifndef X2_SERIAL_TX_PIN
#define X2_SERIAL_TX_PIN _EPIN(X2_E_INDEX, SERIAL_TX)
#endif
#ifndef X2_SERIAL_RX_PIN
#define X2_SERIAL_RX_PIN _EPIN(X2_E_INDEX, SERIAL_RX)
#endif
#endif
//
// Auto-assign pins for stallGuard sensorless homing
//
#if !defined(X2_USE_ENDSTOP) && defined(X2_STALL_SENSITIVITY) && ENABLED(X_DUAL_ENDSTOPS) && _PEXI(X2_E_INDEX, DIAG)
#define X2_DIAG_PIN _EPIN(X2_E_INDEX, DIAG)
#if DIAG_REMAPPED(X2, X_MIN) // If already remapped in the pins file...
#define X2_USE_ENDSTOP _XMIN_
#elif DIAG_REMAPPED(X2, Y_MIN)
#define X2_USE_ENDSTOP _YMIN_
#elif DIAG_REMAPPED(X2, Z_MIN)
#define X2_USE_ENDSTOP _ZMIN_
#elif DIAG_REMAPPED(X2, X_MAX)
#define X2_USE_ENDSTOP _XMAX_
#elif DIAG_REMAPPED(X2, Y_MAX)
#define X2_USE_ENDSTOP _YMAX_
#elif DIAG_REMAPPED(X2, Z_MAX)
#define X2_USE_ENDSTOP _ZMAX_
#else // Otherwise use the driver DIAG_PIN directly
#define _X2_USE_ENDSTOP(P) _E##P##_DIAG_
#define X2_USE_ENDSTOP _X2_USE_ENDSTOP(X2_E_INDEX)
#endif
#undef X2_DIAG_PIN
#endif
#define Y2_E_INDEX INCREMENT(X2_E_INDEX)
#else
#define Y2_E_INDEX X2_E_INDEX
#endif
#ifndef X2_CS_PIN
#define X2_CS_PIN -1
#endif
#ifndef X2_MS1_PIN
#define X2_MS1_PIN -1
#endif
#ifndef X2_MS2_PIN
#define X2_MS2_PIN -1
#endif
#ifndef X2_MS3_PIN
#define X2_MS3_PIN -1
#endif
// The Y2 axis, if any, should be the next open extruder port
#if ENABLED(Y_DUAL_STEPPER_DRIVERS)
#ifndef Y2_STEP_PIN
#define Y2_STEP_PIN _EPIN(Y2_E_INDEX, STEP)
#define Y2_DIR_PIN _EPIN(Y2_E_INDEX, DIR)
#define Y2_ENABLE_PIN _EPIN(Y2_E_INDEX, ENABLE)
#if Y2_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(Y2_STEP)
#error "No E stepper plug left for Y2!"
#endif
#endif
#ifndef Y2_MS1_PIN
#define Y2_MS1_PIN _EPIN(Y2_E_INDEX, MS1)
#endif
#ifndef Y2_MS2_PIN
#define Y2_MS2_PIN _EPIN(Y2_E_INDEX, MS2)
#endif
#ifndef Y2_MS3_PIN
#define Y2_MS3_PIN _EPIN(Y2_E_INDEX, MS3)
#endif
#if AXIS_HAS_SPI(Y2) && !defined(Y2_CS_PIN)
#define Y2_CS_PIN _EPIN(Y2_E_INDEX, CS)
#endif
#if AXIS_HAS_UART(Y2)
#ifndef Y2_SERIAL_TX_PIN
#define Y2_SERIAL_TX_PIN _EPIN(Y2_E_INDEX, SERIAL_TX)
#endif
#ifndef Y2_SERIAL_RX_PIN
#define Y2_SERIAL_RX_PIN _EPIN(Y2_E_INDEX, SERIAL_RX)
#endif
#endif
// Auto-assign pins for stallGuard sensorless homing
#if !defined(Y2_USE_ENDSTOP) && defined(Y2_STALL_SENSITIVITY) && ENABLED(Y_DUAL_ENDSTOPS) && _PEXI(Y2_E_INDEX, DIAG)
#define Y2_DIAG_PIN _EPIN(Y2_E_INDEX, DIAG)
#if DIAG_REMAPPED(Y2, X_MIN)
#define Y2_USE_ENDSTOP _XMIN_
#elif DIAG_REMAPPED(Y2, Y_MIN)
#define Y2_USE_ENDSTOP _YMIN_
#elif DIAG_REMAPPED(Y2, Z_MIN)
#define Y2_USE_ENDSTOP _ZMIN_
#elif DIAG_REMAPPED(Y2, X_MAX)
#define Y2_USE_ENDSTOP _XMAX_
#elif DIAG_REMAPPED(Y2, Y_MAX)
#define Y2_USE_ENDSTOP _YMAX_
#elif DIAG_REMAPPED(Y2, Z_MAX)
#define Y2_USE_ENDSTOP _ZMAX_
#else
#define _Y2_USE_ENDSTOP(P) _E##P##_DIAG_
#define Y2_USE_ENDSTOP _Y2_USE_ENDSTOP(Y2_E_INDEX)
#endif
#undef Y2_DIAG_PIN
#endif
#define Z2_E_INDEX INCREMENT(Y2_E_INDEX)
#else
#define Z2_E_INDEX Y2_E_INDEX
#endif
#ifndef Y2_CS_PIN
#define Y2_CS_PIN -1
#endif
#ifndef Y2_MS1_PIN
#define Y2_MS1_PIN -1
#endif
#ifndef Y2_MS2_PIN
#define Y2_MS2_PIN -1
#endif
#ifndef Y2_MS3_PIN
#define Y2_MS3_PIN -1
#endif
// The Z2 axis, if any, should be the next open extruder port
#if NUM_Z_STEPPER_DRIVERS >= 2
#ifndef Z2_STEP_PIN
#define Z2_STEP_PIN _EPIN(Z2_E_INDEX, STEP)
#define Z2_DIR_PIN _EPIN(Z2_E_INDEX, DIR)
#define Z2_ENABLE_PIN _EPIN(Z2_E_INDEX, ENABLE)
#if Z2_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(Z2_STEP)
#error "No E stepper plug left for Z2!"
#endif
#endif
#ifndef Z2_MS1_PIN
#define Z2_MS1_PIN _EPIN(Z2_E_INDEX, MS1)
#endif
#ifndef Z2_MS2_PIN
#define Z2_MS2_PIN _EPIN(Z2_E_INDEX, MS2)
#endif
#ifndef Z2_MS3_PIN
#define Z2_MS3_PIN _EPIN(Z2_E_INDEX, MS3)
#endif
#if AXIS_HAS_SPI(Z2) && !defined(Z2_CS_PIN)
#define Z2_CS_PIN _EPIN(Z2_E_INDEX, CS)
#endif
#if AXIS_HAS_UART(Z2)
#ifndef Z2_SERIAL_TX_PIN
#define Z2_SERIAL_TX_PIN _EPIN(Z2_E_INDEX, SERIAL_TX)
#endif
#ifndef Z2_SERIAL_RX_PIN
#define Z2_SERIAL_RX_PIN _EPIN(Z2_E_INDEX, SERIAL_RX)
#endif
#endif
// Auto-assign pins for stallGuard sensorless homing
#if !defined(Z2_USE_ENDSTOP) && defined(Z2_STALL_SENSITIVITY) && ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 2 && _PEXI(Z2_E_INDEX, DIAG)
#define Z2_DIAG_PIN _EPIN(Z2_E_INDEX, DIAG)
#if DIAG_REMAPPED(Z2, X_MIN)
#define Z2_USE_ENDSTOP _XMIN_
#elif DIAG_REMAPPED(Z2, Y_MIN)
#define Z2_USE_ENDSTOP _YMIN_
#elif DIAG_REMAPPED(Z2, Z_MIN)
#define Z2_USE_ENDSTOP _ZMIN_
#elif DIAG_REMAPPED(Z2, X_MAX)
#define Z2_USE_ENDSTOP _XMAX_
#elif DIAG_REMAPPED(Z2, Y_MAX)
#define Z2_USE_ENDSTOP _YMAX_
#elif DIAG_REMAPPED(Z2, Z_MAX)
#define Z2_USE_ENDSTOP _ZMAX_
#else
#define _Z2_USE_ENDSTOP(P) _E##P##_DIAG_
#define Z2_USE_ENDSTOP _Z2_USE_ENDSTOP(Z2_E_INDEX)
#endif
#undef Z2_DIAG_PIN
#endif
#define Z3_E_INDEX INCREMENT(Z2_E_INDEX)
#else
#define Z3_E_INDEX Z2_E_INDEX
#endif
#ifndef Z2_CS_PIN
#define Z2_CS_PIN -1
#endif
#ifndef Z2_MS1_PIN
#define Z2_MS1_PIN -1
#endif
#ifndef Z2_MS2_PIN
#define Z2_MS2_PIN -1
#endif
#ifndef Z2_MS3_PIN
#define Z2_MS3_PIN -1
#endif
#if NUM_Z_STEPPER_DRIVERS >= 3
#ifndef Z3_STEP_PIN
#define Z3_STEP_PIN _EPIN(Z3_E_INDEX, STEP)
#define Z3_DIR_PIN _EPIN(Z3_E_INDEX, DIR)
#define Z3_ENABLE_PIN _EPIN(Z3_E_INDEX, ENABLE)
#if Z3_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(Z3_STEP)
#error "No E stepper plug left for Z3!"
#endif
#endif
#if AXIS_HAS_SPI(Z3)
#ifndef Z3_CS_PIN
#define Z3_CS_PIN _EPIN(Z3_E_INDEX, CS)
#endif
#endif
#ifndef Z3_MS1_PIN
#define Z3_MS1_PIN _EPIN(Z3_E_INDEX, MS1)
#endif
#ifndef Z3_MS2_PIN
#define Z3_MS2_PIN _EPIN(Z3_E_INDEX, MS2)
#endif
#ifndef Z3_MS3_PIN
#define Z3_MS3_PIN _EPIN(Z3_E_INDEX, MS3)
#endif
#if AXIS_HAS_UART(Z3)
#ifndef Z3_SERIAL_TX_PIN
#define Z3_SERIAL_TX_PIN _EPIN(Z3_E_INDEX, SERIAL_TX)
#endif
#ifndef Z3_SERIAL_RX_PIN
#define Z3_SERIAL_RX_PIN _EPIN(Z3_E_INDEX, SERIAL_RX)
#endif
#endif
// Auto-assign pins for stallGuard sensorless homing
#if !defined(Z3_USE_ENDSTOP) && defined(Z3_STALL_SENSITIVITY) && ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 3 && _PEXI(Z3_E_INDEX, DIAG)
#define Z3_DIAG_PIN _EPIN(Z3_E_INDEX, DIAG)
#if DIAG_REMAPPED(Z3, X_MIN)
#define Z3_USE_ENDSTOP _XMIN_
#elif DIAG_REMAPPED(Z3, Y_MIN)
#define Z3_USE_ENDSTOP _YMIN_
#elif DIAG_REMAPPED(Z3, Z_MIN)
#define Z3_USE_ENDSTOP _ZMIN_
#elif DIAG_REMAPPED(Z3, X_MAX)
#define Z3_USE_ENDSTOP _XMAX_
#elif DIAG_REMAPPED(Z3, Y_MAX)
#define Z3_USE_ENDSTOP _YMAX_
#elif DIAG_REMAPPED(Z3, Z_MAX)
#define Z3_USE_ENDSTOP _ZMAX_
#else
#define _Z3_USE_ENDSTOP(P) _E##P##_DIAG_
#define Z3_USE_ENDSTOP _Z3_USE_ENDSTOP(Z3_E_INDEX)
#endif
#undef Z3_DIAG_PIN
#endif
#define Z4_E_INDEX INCREMENT(Z3_E_INDEX)
#endif
#ifndef Z3_CS_PIN
#define Z3_CS_PIN -1
#endif
#ifndef Z3_MS1_PIN
#define Z3_MS1_PIN -1
#endif
#ifndef Z3_MS2_PIN
#define Z3_MS2_PIN -1
#endif
#ifndef Z3_MS3_PIN
#define Z3_MS3_PIN -1
#endif
#if NUM_Z_STEPPER_DRIVERS >= 4
#ifndef Z4_STEP_PIN
#define Z4_STEP_PIN _EPIN(Z4_E_INDEX, STEP)
#define Z4_DIR_PIN _EPIN(Z4_E_INDEX, DIR)
#define Z4_ENABLE_PIN _EPIN(Z4_E_INDEX, ENABLE)
#if Z4_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(Z4_STEP)
#error "No E stepper plug left for Z4!"
#endif
#endif
#if AXIS_HAS_SPI(Z4)
#ifndef Z4_CS_PIN
#define Z4_CS_PIN _EPIN(Z4_E_INDEX, CS)
#endif
#endif
#ifndef Z4_MS1_PIN
#define Z4_MS1_PIN _EPIN(Z4_E_INDEX, MS1)
#endif
#ifndef Z4_MS2_PIN
#define Z4_MS2_PIN _EPIN(Z4_E_INDEX, MS2)
#endif
#ifndef Z4_MS3_PIN
#define Z4_MS3_PIN _EPIN(Z4_E_INDEX, MS3)
#endif
#if AXIS_HAS_UART(Z4)
#ifndef Z4_SERIAL_TX_PIN
#define Z4_SERIAL_TX_PIN _EPIN(Z4_E_INDEX, SERIAL_TX)
#endif
#ifndef Z4_SERIAL_RX_PIN
#define Z4_SERIAL_RX_PIN _EPIN(Z4_E_INDEX, SERIAL_RX)
#endif
#endif
// Auto-assign pins for stallGuard sensorless homing
#if !defined(Z4_USE_ENDSTOP) && defined(Z4_STALL_SENSITIVITY) && ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 4 && _PEXI(Z4_E_INDEX, DIAG)
#define Z4_DIAG_PIN _EPIN(Z4_E_INDEX, DIAG)
#if DIAG_REMAPPED(Z4, X_MIN)
#define Z4_USE_ENDSTOP _XMIN_
#elif DIAG_REMAPPED(Z4, Y_MIN)
#define Z4_USE_ENDSTOP _YMIN_
#elif DIAG_REMAPPED(Z4, Z_MIN)
#define Z4_USE_ENDSTOP _ZMIN_
#elif DIAG_REMAPPED(Z4, X_MAX)
#define Z4_USE_ENDSTOP _XMAX_
#elif DIAG_REMAPPED(Z4, Y_MAX)
#define Z4_USE_ENDSTOP _YMAX_
#elif DIAG_REMAPPED(Z4, Z_MAX)
#define Z4_USE_ENDSTOP _ZMAX_
#else
#define _Z4_USE_ENDSTOP(P) _E##P##_DIAG_
#define Z4_USE_ENDSTOP _Z4_USE_ENDSTOP(Z4_E_INDEX)
#endif
#undef Z4_DIAG_PIN
#endif
#endif
#ifndef Z4_CS_PIN
#define Z4_CS_PIN -1
#endif
#ifndef Z4_MS1_PIN
#define Z4_MS1_PIN -1
#endif
#ifndef Z4_MS2_PIN
#define Z4_MS2_PIN -1
#endif
#ifndef Z4_MS3_PIN
#define Z4_MS3_PIN -1
#endif
// //
// Disable unused endstop / probe pins // Disable unused endstop / probe pins
// //
@ -520,387 +906,9 @@
#undef Z4_MAX_PIN #undef Z4_MAX_PIN
#endif #endif
#if HAS_FILAMENT_SENSOR //
#define FIL_RUNOUT1_PIN FIL_RUNOUT_PIN // Default DOGLCD SPI delays
#else //
#undef FIL_RUNOUT_PIN
#undef FIL_RUNOUT1_PIN
#endif
#ifndef LCD_PINS_D4
#define LCD_PINS_D4 -1
#endif
#if HAS_MARLINUI_HD44780 || TOUCH_UI_ULTIPANEL
#ifndef LCD_PINS_D5
#define LCD_PINS_D5 -1
#endif
#ifndef LCD_PINS_D6
#define LCD_PINS_D6 -1
#endif
#ifndef LCD_PINS_D7
#define LCD_PINS_D7 -1
#endif
#endif
/**
* Auto-Assignment for Dual X, Dual Y, Multi-Z Steppers
*
* By default X2 is assigned to the next open E plug
* on the board, then in order, Y2, Z2, Z3. These can be
* overridden in Configuration.h or Configuration_adv.h.
*/
#define __PEXI(p,q) PIN_EXISTS(E##p##_##q)
#define _PEXI(p,q) __PEXI(p,q)
#define __EPIN(p,q) E##p##_##q##_PIN
#define _EPIN(p,q) __EPIN(p,q)
#define DIAG_REMAPPED(p,q) (PIN_EXISTS(q) && _EPIN(p##_E_INDEX, DIAG) == q##_PIN)
// The X2 axis, if any, should be the next open extruder port
#define X2_E_INDEX E_STEPPERS
#if EITHER(DUAL_X_CARRIAGE, X_DUAL_STEPPER_DRIVERS)
#ifndef X2_STEP_PIN
#define X2_STEP_PIN _EPIN(X2_E_INDEX, STEP)
#define X2_DIR_PIN _EPIN(X2_E_INDEX, DIR)
#define X2_ENABLE_PIN _EPIN(X2_E_INDEX, ENABLE)
#if X2_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(X2_STEP)
#error "No E stepper plug left for X2!"
#endif
#endif
#ifndef X2_MS1_PIN
#define X2_MS1_PIN _EPIN(X2_E_INDEX, MS1)
#endif
#ifndef X2_MS2_PIN
#define X2_MS2_PIN _EPIN(X2_E_INDEX, MS2)
#endif
#ifndef X2_MS3_PIN
#define X2_MS3_PIN _EPIN(X2_E_INDEX, MS3)
#endif
#if AXIS_HAS_SPI(X2) && !defined(X2_CS_PIN)
#define X2_CS_PIN _EPIN(X2_E_INDEX, CS)
#endif
#if AXIS_HAS_UART(X2)
#ifndef X2_SERIAL_TX_PIN
#define X2_SERIAL_TX_PIN _EPIN(X2_E_INDEX, SERIAL_TX)
#endif
#ifndef X2_SERIAL_RX_PIN
#define X2_SERIAL_RX_PIN _EPIN(X2_E_INDEX, SERIAL_RX)
#endif
#endif
//
// Auto-assign pins for stallGuard sensorless homing
//
#if defined(X2_STALL_SENSITIVITY) && ENABLED(X_DUAL_ENDSTOPS) && _PEXI(X2_E_INDEX, DIAG)
#define X2_DIAG_PIN _EPIN(X2_E_INDEX, DIAG)
#if DIAG_REMAPPED(X2, X_MIN) // If already remapped in the pins file...
#define X2_USE_ENDSTOP _XMIN_
#elif DIAG_REMAPPED(X2, Y_MIN)
#define X2_USE_ENDSTOP _YMIN_
#elif DIAG_REMAPPED(X2, Z_MIN)
#define X2_USE_ENDSTOP _ZMIN_
#elif DIAG_REMAPPED(X2, X_MAX)
#define X2_USE_ENDSTOP _XMAX_
#elif DIAG_REMAPPED(X2, Y_MAX)
#define X2_USE_ENDSTOP _YMAX_
#elif DIAG_REMAPPED(X2, Z_MAX)
#define X2_USE_ENDSTOP _ZMAX_
#else // Otherwise use the driver DIAG_PIN directly
#define _X2_USE_ENDSTOP(P) _E##P##_DIAG_
#define X2_USE_ENDSTOP _X2_USE_ENDSTOP(X2_E_INDEX)
#endif
#undef X2_DIAG_PIN
#endif
#define Y2_E_INDEX INCREMENT(X2_E_INDEX)
#else
#define Y2_E_INDEX X2_E_INDEX
#endif
#ifndef X2_CS_PIN
#define X2_CS_PIN -1
#endif
#ifndef X2_MS1_PIN
#define X2_MS1_PIN -1
#endif
#ifndef X2_MS2_PIN
#define X2_MS2_PIN -1
#endif
#ifndef X2_MS3_PIN
#define X2_MS3_PIN -1
#endif
// The Y2 axis, if any, should be the next open extruder port
#if ENABLED(Y_DUAL_STEPPER_DRIVERS)
#ifndef Y2_STEP_PIN
#define Y2_STEP_PIN _EPIN(Y2_E_INDEX, STEP)
#define Y2_DIR_PIN _EPIN(Y2_E_INDEX, DIR)
#define Y2_ENABLE_PIN _EPIN(Y2_E_INDEX, ENABLE)
#if Y2_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(Y2_STEP)
#error "No E stepper plug left for Y2!"
#endif
#endif
#ifndef Y2_MS1_PIN
#define Y2_MS1_PIN _EPIN(Y2_E_INDEX, MS1)
#endif
#ifndef Y2_MS2_PIN
#define Y2_MS2_PIN _EPIN(Y2_E_INDEX, MS2)
#endif
#ifndef Y2_MS3_PIN
#define Y2_MS3_PIN _EPIN(Y2_E_INDEX, MS3)
#endif
#if AXIS_HAS_SPI(Y2) && !defined(Y2_CS_PIN)
#define Y2_CS_PIN _EPIN(Y2_E_INDEX, CS)
#endif
#if AXIS_HAS_UART(Y2)
#ifndef Y2_SERIAL_TX_PIN
#define Y2_SERIAL_TX_PIN _EPIN(Y2_E_INDEX, SERIAL_TX)
#endif
#ifndef Y2_SERIAL_RX_PIN
#define Y2_SERIAL_RX_PIN _EPIN(Y2_E_INDEX, SERIAL_RX)
#endif
#endif
#if defined(Y2_STALL_SENSITIVITY) && ENABLED(Y_DUAL_ENDSTOPS) && _PEXI(Y2_E_INDEX, DIAG)
#define Y2_DIAG_PIN _EPIN(Y2_E_INDEX, DIAG)
#if DIAG_REMAPPED(Y2, X_MIN)
#define Y2_USE_ENDSTOP _XMIN_
#elif DIAG_REMAPPED(Y2, Y_MIN)
#define Y2_USE_ENDSTOP _YMIN_
#elif DIAG_REMAPPED(Y2, Z_MIN)
#define Y2_USE_ENDSTOP _ZMIN_
#elif DIAG_REMAPPED(Y2, X_MAX)
#define Y2_USE_ENDSTOP _XMAX_
#elif DIAG_REMAPPED(Y2, Y_MAX)
#define Y2_USE_ENDSTOP _YMAX_
#elif DIAG_REMAPPED(Y2, Z_MAX)
#define Y2_USE_ENDSTOP _ZMAX_
#else
#define _Y2_USE_ENDSTOP(P) _E##P##_DIAG_
#define Y2_USE_ENDSTOP _Y2_USE_ENDSTOP(Y2_E_INDEX)
#endif
#undef Y2_DIAG_PIN
#endif
#define Z2_E_INDEX INCREMENT(Y2_E_INDEX)
#else
#define Z2_E_INDEX Y2_E_INDEX
#endif
#ifndef Y2_CS_PIN
#define Y2_CS_PIN -1
#endif
#ifndef Y2_MS1_PIN
#define Y2_MS1_PIN -1
#endif
#ifndef Y2_MS2_PIN
#define Y2_MS2_PIN -1
#endif
#ifndef Y2_MS3_PIN
#define Y2_MS3_PIN -1
#endif
// The Z2 axis, if any, should be the next open extruder port
#if NUM_Z_STEPPER_DRIVERS >= 2
#ifndef Z2_STEP_PIN
#define Z2_STEP_PIN _EPIN(Z2_E_INDEX, STEP)
#define Z2_DIR_PIN _EPIN(Z2_E_INDEX, DIR)
#define Z2_ENABLE_PIN _EPIN(Z2_E_INDEX, ENABLE)
#if Z2_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(Z2_STEP)
#error "No E stepper plug left for Z2!"
#endif
#endif
#ifndef Z2_MS1_PIN
#define Z2_MS1_PIN _EPIN(Z2_E_INDEX, MS1)
#endif
#ifndef Z2_MS2_PIN
#define Z2_MS2_PIN _EPIN(Z2_E_INDEX, MS2)
#endif
#ifndef Z2_MS3_PIN
#define Z2_MS3_PIN _EPIN(Z2_E_INDEX, MS3)
#endif
#if AXIS_HAS_SPI(Z2) && !defined(Z2_CS_PIN)
#define Z2_CS_PIN _EPIN(Z2_E_INDEX, CS)
#endif
#if AXIS_HAS_UART(Z2)
#ifndef Z2_SERIAL_TX_PIN
#define Z2_SERIAL_TX_PIN _EPIN(Z2_E_INDEX, SERIAL_TX)
#endif
#ifndef Z2_SERIAL_RX_PIN
#define Z2_SERIAL_RX_PIN _EPIN(Z2_E_INDEX, SERIAL_RX)
#endif
#endif
#if defined(Z2_STALL_SENSITIVITY) && ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 2 && _PEXI(Z2_E_INDEX, DIAG)
#define Z2_DIAG_PIN _EPIN(Z2_E_INDEX, DIAG)
#if DIAG_REMAPPED(Z2, X_MIN)
#define Z2_USE_ENDSTOP _XMIN_
#elif DIAG_REMAPPED(Z2, Y_MIN)
#define Z2_USE_ENDSTOP _YMIN_
#elif DIAG_REMAPPED(Z2, Z_MIN)
#define Z2_USE_ENDSTOP _ZMIN_
#elif DIAG_REMAPPED(Z2, X_MAX)
#define Z2_USE_ENDSTOP _XMAX_
#elif DIAG_REMAPPED(Z2, Y_MAX)
#define Z2_USE_ENDSTOP _YMAX_
#elif DIAG_REMAPPED(Z2, Z_MAX)
#define Z2_USE_ENDSTOP _ZMAX_
#else
#define _Z2_USE_ENDSTOP(P) _E##P##_DIAG_
#define Z2_USE_ENDSTOP _Z2_USE_ENDSTOP(Z2_E_INDEX)
#endif
#undef Z2_DIAG_PIN
#endif
#define Z3_E_INDEX INCREMENT(Z2_E_INDEX)
#else
#define Z3_E_INDEX Z2_E_INDEX
#endif
#ifndef Z2_CS_PIN
#define Z2_CS_PIN -1
#endif
#ifndef Z2_MS1_PIN
#define Z2_MS1_PIN -1
#endif
#ifndef Z2_MS2_PIN
#define Z2_MS2_PIN -1
#endif
#ifndef Z2_MS3_PIN
#define Z2_MS3_PIN -1
#endif
#if NUM_Z_STEPPER_DRIVERS >= 3
#ifndef Z3_STEP_PIN
#define Z3_STEP_PIN _EPIN(Z3_E_INDEX, STEP)
#define Z3_DIR_PIN _EPIN(Z3_E_INDEX, DIR)
#define Z3_ENABLE_PIN _EPIN(Z3_E_INDEX, ENABLE)
#if Z3_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(Z3_STEP)
#error "No E stepper plug left for Z3!"
#endif
#endif
#if AXIS_HAS_SPI(Z3)
#ifndef Z3_CS_PIN
#define Z3_CS_PIN _EPIN(Z3_E_INDEX, CS)
#endif
#endif
#ifndef Z3_MS1_PIN
#define Z3_MS1_PIN _EPIN(Z3_E_INDEX, MS1)
#endif
#ifndef Z3_MS2_PIN
#define Z3_MS2_PIN _EPIN(Z3_E_INDEX, MS2)
#endif
#ifndef Z3_MS3_PIN
#define Z3_MS3_PIN _EPIN(Z3_E_INDEX, MS3)
#endif
#if AXIS_HAS_UART(Z3)
#ifndef Z3_SERIAL_TX_PIN
#define Z3_SERIAL_TX_PIN _EPIN(Z3_E_INDEX, SERIAL_TX)
#endif
#ifndef Z3_SERIAL_RX_PIN
#define Z3_SERIAL_RX_PIN _EPIN(Z3_E_INDEX, SERIAL_RX)
#endif
#endif
#if defined(Z3_STALL_SENSITIVITY) && ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 3 && _PEXI(Z3_E_INDEX, DIAG)
#define Z3_DIAG_PIN _EPIN(Z3_E_INDEX, DIAG)
#if DIAG_REMAPPED(Z3, X_MIN)
#define Z3_USE_ENDSTOP _XMIN_
#elif DIAG_REMAPPED(Z3, Y_MIN)
#define Z3_USE_ENDSTOP _YMIN_
#elif DIAG_REMAPPED(Z3, Z_MIN)
#define Z3_USE_ENDSTOP _ZMIN_
#elif DIAG_REMAPPED(Z3, X_MAX)
#define Z3_USE_ENDSTOP _XMAX_
#elif DIAG_REMAPPED(Z3, Y_MAX)
#define Z3_USE_ENDSTOP _YMAX_
#elif DIAG_REMAPPED(Z3, Z_MAX)
#define Z3_USE_ENDSTOP _ZMAX_
#else
#define _Z3_USE_ENDSTOP(P) _E##P##_DIAG_
#define Z3_USE_ENDSTOP _Z3_USE_ENDSTOP(Z3_E_INDEX)
#endif
#undef Z3_DIAG_PIN
#endif
#define Z4_E_INDEX INCREMENT(Z3_E_INDEX)
#endif
#ifndef Z3_CS_PIN
#define Z3_CS_PIN -1
#endif
#ifndef Z3_MS1_PIN
#define Z3_MS1_PIN -1
#endif
#ifndef Z3_MS2_PIN
#define Z3_MS2_PIN -1
#endif
#ifndef Z3_MS3_PIN
#define Z3_MS3_PIN -1
#endif
#if NUM_Z_STEPPER_DRIVERS >= 4
#ifndef Z4_STEP_PIN
#define Z4_STEP_PIN _EPIN(Z4_E_INDEX, STEP)
#define Z4_DIR_PIN _EPIN(Z4_E_INDEX, DIR)
#define Z4_ENABLE_PIN _EPIN(Z4_E_INDEX, ENABLE)
#if Z4_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(Z4_STEP)
#error "No E stepper plug left for Z4!"
#endif
#endif
#if AXIS_HAS_SPI(Z4)
#ifndef Z4_CS_PIN
#define Z4_CS_PIN _EPIN(Z4_E_INDEX, CS)
#endif
#endif
#ifndef Z4_MS1_PIN
#define Z4_MS1_PIN _EPIN(Z4_E_INDEX, MS1)
#endif
#ifndef Z4_MS2_PIN
#define Z4_MS2_PIN _EPIN(Z4_E_INDEX, MS2)
#endif
#ifndef Z4_MS3_PIN
#define Z4_MS3_PIN _EPIN(Z4_E_INDEX, MS3)
#endif
#if AXIS_HAS_UART(Z4)
#ifndef Z4_SERIAL_TX_PIN
#define Z4_SERIAL_TX_PIN _EPIN(Z4_E_INDEX, SERIAL_TX)
#endif
#ifndef Z4_SERIAL_RX_PIN
#define Z4_SERIAL_RX_PIN _EPIN(Z4_E_INDEX, SERIAL_RX)
#endif
#endif
#if defined(Z4_STALL_SENSITIVITY) && ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 4 && _PEXI(Z4_E_INDEX, DIAG)
#define Z4_DIAG_PIN _EPIN(Z4_E_INDEX, DIAG)
#if DIAG_REMAPPED(Z4, X_MIN)
#define Z4_USE_ENDSTOP _XMIN_
#elif DIAG_REMAPPED(Z4, Y_MIN)
#define Z4_USE_ENDSTOP _YMIN_
#elif DIAG_REMAPPED(Z4, Z_MIN)
#define Z4_USE_ENDSTOP _ZMIN_
#elif DIAG_REMAPPED(Z4, X_MAX)
#define Z4_USE_ENDSTOP _XMAX_
#elif DIAG_REMAPPED(Z4, Y_MAX)
#define Z4_USE_ENDSTOP _YMAX_
#elif DIAG_REMAPPED(Z4, Z_MAX)
#define Z4_USE_ENDSTOP _ZMAX_
#else
#define _Z4_USE_ENDSTOP(P) _E##P##_DIAG_
#define Z4_USE_ENDSTOP _Z4_USE_ENDSTOP(Z4_E_INDEX)
#endif
#undef Z4_DIAG_PIN
#endif
#endif
#ifndef Z4_CS_PIN
#define Z4_CS_PIN -1
#endif
#ifndef Z4_MS1_PIN
#define Z4_MS1_PIN -1
#endif
#ifndef Z4_MS2_PIN
#define Z4_MS2_PIN -1
#endif
#ifndef Z4_MS3_PIN
#define Z4_MS3_PIN -1
#endif
#if HAS_MARLINUI_U8GLIB #if HAS_MARLINUI_U8GLIB
#if !defined(ST7920_DELAY_1) && defined(BOARD_ST7920_DELAY_1) #if !defined(ST7920_DELAY_1) && defined(BOARD_ST7920_DELAY_1)
#define ST7920_DELAY_1 BOARD_ST7920_DELAY_1 #define ST7920_DELAY_1 BOARD_ST7920_DELAY_1