Skip to content

Commit

Permalink
🐛 Fix NUM_ENDSTOP_STATES with Z_MIN_PROBE = Z_MIN (MarlinFirmware#27190)
Browse files Browse the repository at this point in the history
Co-authored-by: Scott Lahteine <[email protected]>
  • Loading branch information
tombrazier and thinkyhead authored Jul 13, 2024
1 parent 228179e commit 57bda2f
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions Marlin/src/module/endstops.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#define _ES_ENUM(A,M) A##_##M
#define ES_ENUM(A,M) _ES_ENUM(A,M)

#define _ES_ITEM(N) N,
#define _ES_ITEM(N) , N
#define ES_ITEM(K,N) TERN(K,_ES_ITEM,_IF_1_ELSE)(N)

#define _ESN_ITEM(K,A,M) ES_ITEM(K,ES_ENUM(A,M))
Expand All @@ -57,7 +57,9 @@
* - Z_MIN_PROBE is an alias to Z_MIN when the Z_MIN_PIN is being used as the probe pin.
* - When homing with the probe Z_ENDSTOP is a Z_MIN_PROBE alias, otherwise a Z_MIN/MAX alias.
*/
enum EndstopEnum : char {
enum EndstopEnum : int8_t {
_ES_START_ = -1

// Common XYZ (ABC) endstops.
ES_MINMAX(X) ES_MINMAX(Y) ES_MINMAX(Z)
ES_MINMAX(I) ES_MINMAX(J) ES_MINMAX(K)
Expand All @@ -70,12 +72,18 @@ enum EndstopEnum : char {
ES_ITEM(HAS_CALIBRATION_STATE, CALIBRATION)

// Bed Probe state is distinct or shared with Z_MIN (i.e., when the probe is the only Z endstop)
ES_ITEM(HAS_Z_PROBE_STATE, Z_MIN_PROBE IF_DISABLED(USE_Z_MIN_PROBE, = Z_MIN))
#if HAS_Z_PROBE_STATE && USE_Z_MIN_PROBE
, Z_MIN_PROBE
#endif

// The total number of states
NUM_ENDSTOP_STATES
// The total number of distinct states
, NUM_ENDSTOP_STATES

// Endstop aliases
#if HAS_Z_PROBE_STATE && !USE_Z_MIN_PROBE
, Z_MIN_PROBE = Z_MIN
#endif

#if HAS_X_STATE
, X_ENDSTOP = TERN(X_HOME_TO_MAX, X_MAX, X_MIN)
#endif
Expand All @@ -88,7 +96,6 @@ enum EndstopEnum : char {
#if HAS_Y2_STATE
, Y2_ENDSTOP = TERN(Y_HOME_TO_MAX, Y2_MAX, Y2_MIN)
#endif

#if HOMING_Z_WITH_PROBE
, Z_ENDSTOP = Z_MIN_PROBE // "Z" endstop alias when homing with the probe
#elif HAS_Z_STATE
Expand Down

0 comments on commit 57bda2f

Please sign in to comment.