Skip to content

Commit

Permalink
🐛 Fix up endstop flags (MarlinFirmware#22487)
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead authored and ptoal committed Dec 16, 2021
1 parent f52d045 commit 20b8d75
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 54 deletions.
71 changes: 39 additions & 32 deletions Marlin/src/inc/Conditionals_post.h
Original file line number Diff line number Diff line change
Expand Up @@ -2122,72 +2122,79 @@
#define IS_Z4_ENDSTOP(A,M) (ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 4 && Z4_USE_ENDSTOP == _##A##M##_)

#define _HAS_STOP(A,M) (PIN_EXISTS(A##_##M) && !IS_PROBE_PIN(A,M) && !IS_X2_ENDSTOP(A,M) && !IS_Y2_ENDSTOP(A,M) && !IS_Z2_ENDSTOP(A,M) && !IS_Z3_ENDSTOP(A,M) && !IS_Z4_ENDSTOP(A,M))
#if _HAS_STOP(X,MIN)
#if BOTH(X_HOME_TO_MIN, USE_XMIN_PLUG) && _HAS_STOP(X,MIN)
#define HAS_X_MIN 1
#endif
#if _HAS_STOP(X,MAX)
#if (BOTH(X_HOME_TO_MAX, USE_XMAX_PLUG) || ENABLED(DUAL_X_CARRIAGE)) && _HAS_STOP(X,MAX)
#define HAS_X_MAX 1
#endif
#if HAS_Y_AXIS && _HAS_STOP(Y,MIN)
#if ALL(HAS_Y_AXIS, Y_HOME_TO_MIN, USE_YMIN_PLUG) && _HAS_STOP(Y,MIN)
#define HAS_Y_MIN 1
#endif
#if HAS_Y_AXIS && _HAS_STOP(Y,MAX)
#if ALL(HAS_Y_AXIS, Y_HOME_TO_MAX, USE_YMAX_PLUG) && _HAS_STOP(Y,MAX)
#define HAS_Y_MAX 1
#endif
#if BOTH(HAS_Z_AXIS, USE_ZMIN_PLUG) && _HAS_STOP(Z,MIN)
#define HAS_Z_MIN 1
#endif
#if BOTH(HAS_Z_AXIS, USE_ZMAX_PLUG) && _HAS_STOP(Z,MAX)
#if ALL(HAS_Z_AXIS, Z_HOME_TO_MAX, USE_ZMAX_PLUG) && _HAS_STOP(Z,MAX)
#define HAS_Z_MAX 1
#endif
#if _HAS_STOP(I,MIN)
#if LINEAR_AXES >= 4 && BOTH(I_HOME_TO_MIN, USE_IMIN_PLUG) && _HAS_STOP(I,MIN)
#define HAS_I_MIN 1
#endif
#if _HAS_STOP(I,MAX)
#if LINEAR_AXES >= 4 && BOTH(I_HOME_TO_MAX, USE_IMAX_PLUG) && _HAS_STOP(I,MAX)
#define HAS_I_MAX 1
#endif
#if _HAS_STOP(J,MIN)
#if LINEAR_AXES >= 5 && BOTH(J_HOME_TO_MIN, USE_JMIN_PLUG) && _HAS_STOP(J,MIN)
#define HAS_J_MIN 1
#endif
#if _HAS_STOP(J,MAX)
#if LINEAR_AXES >= 5 && BOTH(J_HOME_TO_MAX, USE_JMAX_PLUG) && _HAS_STOP(J,MAX)
#define HAS_J_MAX 1
#endif
#if _HAS_STOP(K,MIN)
#if LINEAR_AXES >= 6 && BOTH(K_HOME_TO_MIN, USE_KMIN_PLUG) && _HAS_STOP(K,MIN)
#define HAS_K_MIN 1
#endif
#if _HAS_STOP(K,MAX)
#if LINEAR_AXES >= 6 && BOTH(K_HOME_TO_MAX, USE_KMAX_PLUG) && _HAS_STOP(K,MAX)
#define HAS_K_MAX 1
#endif
#if PIN_EXISTS(X2_MIN)
#if BOTH(X_HOME_TO_MIN, X_DUAL_ENDSTOPS) && PIN_EXISTS(X2_MIN)
#define HAS_X2_MIN 1
#endif
#if PIN_EXISTS(X2_MAX)
#if BOTH(X_HOME_TO_MAX, X_DUAL_ENDSTOPS) && PIN_EXISTS(X2_MAX)
#define HAS_X2_MAX 1
#endif
#if PIN_EXISTS(Y2_MIN)
#if BOTH(Y_HOME_TO_MIN, Y_DUAL_ENDSTOPS) && PIN_EXISTS(Y2_MIN)
#define HAS_Y2_MIN 1
#endif
#if PIN_EXISTS(Y2_MAX)
#if BOTH(Y_HOME_TO_MAX, Y_DUAL_ENDSTOPS) && PIN_EXISTS(Y2_MAX)
#define HAS_Y2_MAX 1
#endif
#if PIN_EXISTS(Z2_MIN)
#define HAS_Z2_MIN 1
#endif
#if PIN_EXISTS(Z2_MAX)
#define HAS_Z2_MAX 1
#endif
#if PIN_EXISTS(Z3_MIN)
#define HAS_Z3_MIN 1
#endif
#if PIN_EXISTS(Z3_MAX)
#define HAS_Z3_MAX 1
#endif
#if PIN_EXISTS(Z4_MIN)
#define HAS_Z4_MIN 1
#endif
#if PIN_EXISTS(Z4_MAX)
#define HAS_Z4_MAX 1
#if ENABLED(Z_MULTI_ENDSTOPS)
#if Z_HOME_TO_MIN && PIN_EXISTS(Z2_MIN)
#define HAS_Z2_MIN 1
#endif
#if Z_HOME_TO_MAX && PIN_EXISTS(Z2_MAX)
#define HAS_Z2_MAX 1
#endif
#if NUM_Z_STEPPER_DRIVERS >= 3
#if Z_HOME_TO_MIN && PIN_EXISTS(Z3_MIN)
#define HAS_Z3_MIN 1
#endif
#if Z_HOME_TO_MAX && PIN_EXISTS(Z3_MAX)
#define HAS_Z3_MAX 1
#endif
#if NUM_Z_STEPPER_DRIVERS >= 4
#if Z_HOME_TO_MIN && PIN_EXISTS(Z4_MIN)
#define HAS_Z4_MIN 1
#endif
#if Z_HOME_TO_MAX && PIN_EXISTS(Z4_MAX)
#define HAS_Z4_MAX 1
#endif
#endif
#endif
#endif

#if HAS_BED_PROBE && PIN_EXISTS(Z_MIN_PROBE)
#define HAS_Z_MIN_PROBE_PIN 1
#endif
Expand Down
30 changes: 10 additions & 20 deletions Marlin/src/module/endstops.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,26 +47,16 @@ enum EndstopEnum : char {
_ES_ITEM(HAS_K_MAX, K_MAX)

// Extra Endstops for XYZ
#if ENABLED(X_DUAL_ENDSTOPS)
_ES_ITEM(HAS_X_MIN, X2_MIN)
_ES_ITEM(HAS_X_MAX, X2_MAX)
#endif
#if ENABLED(Y_DUAL_ENDSTOPS)
_ES_ITEM(HAS_Y_MIN, Y2_MIN)
_ES_ITEM(HAS_Y_MAX, Y2_MAX)
#endif
#if ENABLED(Z_MULTI_ENDSTOPS)
_ES_ITEM(HAS_Z_MIN, Z2_MIN)
_ES_ITEM(HAS_Z_MAX, Z2_MAX)
#if NUM_Z_STEPPER_DRIVERS >= 3
_ES_ITEM(HAS_Z_MIN, Z3_MIN)
_ES_ITEM(HAS_Z_MAX, Z3_MAX)
#endif
#if NUM_Z_STEPPER_DRIVERS >= 4
_ES_ITEM(HAS_Z_MIN, Z4_MIN)
_ES_ITEM(HAS_Z_MAX, Z4_MAX)
#endif
#endif
_ES_ITEM(HAS_X2_MIN, X2_MIN)
_ES_ITEM(HAS_X2_MAX, X2_MAX)
_ES_ITEM(HAS_Y2_MIN, Y2_MIN)
_ES_ITEM(HAS_Y2_MAX, Y2_MAX)
_ES_ITEM(HAS_Z2_MIN, Z2_MIN)
_ES_ITEM(HAS_Z2_MAX, Z2_MAX)
_ES_ITEM(HAS_Z3_MIN, Z3_MIN)
_ES_ITEM(HAS_Z3_MAX, Z3_MAX)
_ES_ITEM(HAS_Z4_MIN, Z4_MIN)
_ES_ITEM(HAS_Z4_MAX, Z4_MAX)

// Bed Probe state is distinct or shared with Z_MIN (i.e., when the probe is the only Z endstop)
_ES_ITEM(HAS_BED_PROBE, Z_MIN_PROBE IF_DISABLED(USES_Z_MIN_PROBE_PIN, = Z_MIN))
Expand Down
2 changes: 1 addition & 1 deletion buildroot/tests/teensy35
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ exec_test $1 $2 "Teensy 3.5/3.6 COREXZ | BACKLASH" "$3"
# Enable Dual Z with Dual Z endstops
#
restore_configs
opt_set MOTHERBOARD BOARD_TEENSY35_36 NUM_Z_STEPPER_DRIVERS 2 Z2_MAX_PIN 2
opt_set MOTHERBOARD BOARD_TEENSY35_36 NUM_Z_STEPPER_DRIVERS 2 Z2_MIN_PIN 2
opt_enable Z_MULTI_ENDSTOPS USE_XMAX_PLUG
pins_set ramps/RAMPS X_MAX_PIN -1
exec_test $1 $2 "Dual Z with Dual Z endstops" "$3"
Expand Down
2 changes: 1 addition & 1 deletion buildroot/tests/teensy41
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ exec_test $1 $2 "Teensy 4.0/4.1 COREXZ" "$3"
# Enable Dual Z with Dual Z endstops
#
restore_configs
opt_set MOTHERBOARD BOARD_TEENSY41 NUM_Z_STEPPER_DRIVERS 2 Z2_MAX_PIN 2
opt_set MOTHERBOARD BOARD_TEENSY41 NUM_Z_STEPPER_DRIVERS 2 Z2_MIN_PIN 2
opt_enable Z_MULTI_ENDSTOPS USE_XMAX_PLUG
pins_set ramps/RAMPS X_MAX_PIN -1
exec_test $1 $2 "Dual Z with Dual Z endstops" "$3"
Expand Down

0 comments on commit 20b8d75

Please sign in to comment.