Skip to content

Commit 53c4e3b

Browse files
ellenspptoal
authored andcommitted
🐛 Fix Z_MULTI_ENDSTOPS + NUM_Z_STEPPER_DRIVERS 4 compile (MarlinFirmware#22203)
1 parent 6826b33 commit 53c4e3b

File tree

3 files changed

+28
-37
lines changed

3 files changed

+28
-37
lines changed

Marlin/src/gcode/calibrate/M666.cpp

+10-12
Original file line numberDiff line numberDiff line change
@@ -71,29 +71,27 @@
7171
#endif
7272
#if ENABLED(Z_MULTI_ENDSTOPS)
7373
if (parser.seenval('Z')) {
74-
#if NUM_Z_STEPPER_DRIVERS >= 3
75-
const float z_adj = parser.value_linear_units();
76-
const int ind = parser.intval('S');
77-
if (!ind || ind == 2) endstops.z2_endstop_adj = z_adj;
78-
if (!ind || ind == 3) endstops.z3_endstop_adj = z_adj;
79-
#if NUM_Z_STEPPER_DRIVERS >= 4
80-
if (!ind || ind == 4) endstops.z4_endstop_adj = z_adj;
81-
#endif
74+
const float z_adj = parser.value_linear_units();
75+
#if NUM_Z_STEPPER_DRIVERS == 2
76+
endstops.z2_endstop_adj = z_adj;
8277
#else
83-
endstops.z2_endstop_adj = parser.value_linear_units();
78+
const int ind = parser.intval('S');
79+
#define _SET_ZADJ(N) if (!ind || ind == N) endstops.z##N##_endstop_adj = z_adj;
80+
REPEAT_S(2, INCREMENT(NUM_Z_STEPPER_DRIVERS), _SET_ZADJ)
8481
#endif
8582
}
8683
#endif
8784
if (!parser.seen("XYZ")) {
85+
auto echo_adj = [](PGM_P const label, const_float_t value) { SERIAL_ECHOPAIR_P(label, value); };
8886
SERIAL_ECHOPGM("Dual Endstop Adjustment (mm): ");
8987
#if ENABLED(X_DUAL_ENDSTOPS)
90-
SERIAL_ECHOPAIR(" X2:", endstops.x2_endstop_adj);
88+
echo_adj(PSTR(" X2:"), endstops.x2_endstop_adj);
9189
#endif
9290
#if ENABLED(Y_DUAL_ENDSTOPS)
93-
SERIAL_ECHOPAIR(" Y2:", endstops.y2_endstop_adj);
91+
echo_adj(PSTR(" Y2:"), endstops.y2_endstop_adj);
9492
#endif
9593
#if ENABLED(Z_MULTI_ENDSTOPS)
96-
#define _ECHO_ZADJ(N) SERIAL_ECHOPAIR(" Z" STRINGIFY(N) ":", endstops.z##N##_endstop_adj);
94+
#define _ECHO_ZADJ(N) echo_adj(PSTR(" Z" STRINGIFY(N) ":"), endstops.z##N##_endstop_adj);
9795
REPEAT_S(2, INCREMENT(NUM_Z_STEPPER_DRIVERS), _ECHO_ZADJ)
9896
#endif
9997
SERIAL_EOL();

Marlin/src/module/stepper.cpp

+12-20
Original file line numberDiff line numberDiff line change
@@ -314,26 +314,18 @@ xyze_int8_t Stepper::count_direction{0};
314314
A##3_STEP_WRITE(V); \
315315
}
316316

317-
#define QUAD_ENDSTOP_APPLY_STEP(A,V) \
318-
if (separate_multi_axis) { \
319-
if (ENABLED(A##_HOME_TO_MIN)) { \
320-
if (!(TEST(endstops.state(), A##_MIN) && count_direction[_AXIS(A)] < 0) && !locked_##A##_motor) A##_STEP_WRITE(V); \
321-
if (!(TEST(endstops.state(), A##2_MIN) && count_direction[_AXIS(A)] < 0) && !locked_##A##2_motor) A##2_STEP_WRITE(V); \
322-
if (!(TEST(endstops.state(), A##3_MIN) && count_direction[_AXIS(A)] < 0) && !locked_##A##3_motor) A##3_STEP_WRITE(V); \
323-
if (!(TEST(endstops.state(), A##4_MIN) && count_direction[_AXIS(A)] < 0) && !locked_##A##4_motor) A##4_STEP_WRITE(V); \
324-
} \
325-
else { \
326-
if (!(TEST(endstops.state(), A##_MAX) && count_direction[_AXIS(A)] > 0) && !locked_##A##_motor) A##_STEP_WRITE(V); \
327-
if (!(TEST(endstops.state(), A##2_MAX) && count_direction[_AXIS(A)] > 0) && !locked_##A##2_motor) A##2_STEP_WRITE(V); \
328-
if (!(TEST(endstops.state(), A##3_MAX) && count_direction[_AXIS(A)] > 0) && !locked_##A##3_motor) A##3_STEP_WRITE(V); \
329-
if (!(TEST(endstops.state(), A##4_MAX) && count_direction[_AXIS(A)] > 0) && !locked_##A##4_motor) A##4_STEP_WRITE(V); \
330-
} \
331-
} \
332-
else { \
333-
A##_STEP_WRITE(V); \
334-
A##2_STEP_WRITE(V); \
335-
A##3_STEP_WRITE(V); \
336-
A##4_STEP_WRITE(V); \
317+
#define QUAD_ENDSTOP_APPLY_STEP(A,V) \
318+
if (separate_multi_axis) { \
319+
if (!(TEST(endstops.state(), (TERN(A##_HOME_TO_MIN, A##_MIN, A##_MAX))) && count_direction[_AXIS(A)] < 0) && !locked_##A##_motor) A##_STEP_WRITE(V); \
320+
if (!(TEST(endstops.state(), (TERN(A##_HOME_TO_MIN, A##2_MIN, A##2_MAX))) && count_direction[_AXIS(A)] < 0) && !locked_##A##2_motor) A##2_STEP_WRITE(V); \
321+
if (!(TEST(endstops.state(), (TERN(A##_HOME_TO_MIN, A##3_MIN, A##3_MAX))) && count_direction[_AXIS(A)] < 0) && !locked_##A##3_motor) A##3_STEP_WRITE(V); \
322+
if (!(TEST(endstops.state(), (TERN(A##_HOME_TO_MIN, A##4_MIN, A##4_MAX))) && count_direction[_AXIS(A)] < 0) && !locked_##A##4_motor) A##4_STEP_WRITE(V); \
323+
} \
324+
else { \
325+
A##_STEP_WRITE(V); \
326+
A##2_STEP_WRITE(V); \
327+
A##3_STEP_WRITE(V); \
328+
A##4_STEP_WRITE(V); \
337329
}
338330

339331
#define QUAD_SEPARATE_APPLY_STEP(A,V) \

buildroot/tests/BIGTREE_GTR_V1_0

+6-5
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ exec_test $1 $2 "BigTreeTech GTR | 8 Extruders | Auto-Fan | Mixed TMC Drivers |
2020

2121
restore_configs
2222
opt_set MOTHERBOARD BOARD_BTT_GTR_V1_0 SERIAL_PORT -1 \
23-
EXTRUDERS 6 TEMP_SENSOR_1 1 TEMP_SENSOR_2 1 TEMP_SENSOR_3 1 TEMP_SENSOR_4 1 TEMP_SENSOR_5 1 \
24-
NUM_Z_STEPPER_DRIVERS 3 \
25-
DEFAULT_Kp_LIST '{ 22.2, 20.0, 21.0, 19.0, 18.0, 17.0 }' DEFAULT_Ki_LIST '{ 1.08 }' DEFAULT_Kd_LIST '{ 114.0, 112.0, 110.0, 108.0 }'
26-
opt_enable TOOLCHANGE_FILAMENT_SWAP TOOLCHANGE_MIGRATION_FEATURE TOOLCHANGE_FS_INIT_BEFORE_SWAP TOOLCHANGE_FS_PRIME_FIRST_USED PID_PARAMS_PER_HOTEND
27-
exec_test $1 $2 "BigTreeTech GTR | 6 Extruders | Triple Z" "$3"
23+
EXTRUDERS 5 TEMP_SENSOR_1 1 TEMP_SENSOR_2 1 TEMP_SENSOR_3 1 TEMP_SENSOR_4 1 \
24+
NUM_Z_STEPPER_DRIVERS 4 \
25+
DEFAULT_Kp_LIST '{ 22.2, 20.0, 21.0, 19.0, 18.0 }' DEFAULT_Ki_LIST '{ 1.08 }' DEFAULT_Kd_LIST '{ 114.0, 112.0, 110.0, 108.0 }'
26+
opt_enable TOOLCHANGE_FILAMENT_SWAP TOOLCHANGE_MIGRATION_FEATURE TOOLCHANGE_FS_INIT_BEFORE_SWAP TOOLCHANGE_FS_PRIME_FIRST_USED \
27+
PID_PARAMS_PER_HOTEND Z_MULTI_ENDSTOPS
28+
exec_test $1 $2 "BigTreeTech GTR | 6 Extruders | Quad Z + Endstops" "$3"
2829

2930
restore_configs
3031
opt_set MOTHERBOARD BOARD_BTT_GTR_V1_0 SERIAL_PORT -1 \

0 commit comments

Comments
 (0)