Skip to content

Commit

Permalink
Use convenience enums
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Apr 19, 2023
1 parent 62641bb commit 5f74472
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
16 changes: 11 additions & 5 deletions Marlin/src/module/endstops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,9 +497,16 @@ void __O2 Endstops::report_states() {

} // Endstops::report_states

#if HOMING_Z_WITH_PROBE
#define Z_ENDSTOP_ENDSTOP_HIT_STATE Z_MIN_PROBE_ENDSTOP_HIT_STATE
#elif Z_HOME_TO_MAX
#define Z_ENDSTOP_ENDSTOP_HIT_STATE Z_MAX_ENDSTOP_HIT_STATE
#elif Z_HOME_TO_MIN
#define Z_ENDSTOP_ENDSTOP_HIT_STATE Z_MIN_ENDSTOP_HIT_STATE
#endif
#define _ENDSTOP_HIT_STATE(AXIS, MINMAX) AXIS ##_## MINMAX ##_ENDSTOP_HIT_STATE
#define __ENDSTOP(AXIS, MINMAX) AXIS ##_## MINMAX
#define _ENDSTOP_PIN(AXIS, MINMAX) AXIS ##_## MINMAX ##_PIN
#define _ENDSTOP_HIT_STATE(AXIS, MINMAX) AXIS ##_## MINMAX ##_ENDSTOP_HIT_STATE
#define _ENDSTOP(AXIS, MINMAX) __ENDSTOP(AXIS, MINMAX)

/**
Expand All @@ -519,7 +526,7 @@ void Endstops::update() {

#if ENABLED(G38_PROBE_TARGET)
// For G38 moves check the probe's pin for ALL movement
if (G38_move) UPDATE_ENDSTOP_BIT(Z, TERN(USES_Z_MIN_PROBE_PIN, MIN_PROBE, MIN));
if (G38_move) UPDATE_ENDSTOP_BIT(Z, ENDSTOP);
#endif

// With Dual X, endstops are only checked in the homing direction for the active extruder
Expand Down Expand Up @@ -624,8 +631,7 @@ void Endstops::update() {

#if HAS_BED_PROBE
// When closing the gap check the enabled probe
if (probe_switch_activated())
UPDATE_ENDSTOP_BIT(Z, TERN(USES_Z_MIN_PROBE_PIN, MIN_PROBE, MIN));
if (probe_switch_activated()) UPDATE_ENDSTOP_BIT(Z, ENDSTOP);
#endif

#if HAS_Z_MAX && !Z_SPI_SENSORLESS
Expand Down Expand Up @@ -913,7 +919,7 @@ void Endstops::update() {

#if ENABLED(G38_PROBE_TARGET)
// For G38 moves check the probe's pin for ALL movement
if (G38_move && TEST_ENDSTOP(_ENDSTOP(Z, TERN(USES_Z_MIN_PROBE_PIN, MIN_PROBE, MIN))) == TERN1(G38_PROBE_AWAY, (G38_move < 4))) {
if (G38_move && TEST_ENDSTOP(Z_MIN_PROBE) == TERN1(G38_PROBE_AWAY, (G38_move < 4))) {
G38_did_trigger = true;
#define _G38_SET(Q) | (stepper.axis_is_moving(_AXIS(Q)) << _AXIS(Q))
#define _G38_RESP(Q) if (moving[_AXIS(Q)]) { _ENDSTOP_HIT(Q, ENDSTOP); planner.endstop_triggered(_AXIS(Q)); }
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/module/endstops.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ enum EndstopEnum : char {
#endif
#endif
#if HAS_Z_MIN || HAS_Z_MAX || HOMING_Z_WITH_PROBE
, Z_ENDSTOP = TERN(Z_HOME_TO_MAX, Z_MAX, TERN(HOMING_Z_WITH_PROBE, Z_MIN_PROBE, Z_MIN))
, Z_ENDSTOP = TERN(HOMING_Z_WITH_PROBE, Z_MIN_PROBE, TERN(Z_HOME_TO_MAX, Z_MAX, Z_MIN))
#endif
#if HAS_I_MIN || HAS_I_MAX
, I_ENDSTOP = TERN(I_HOME_TO_MAX, I_MAX, I_MIN)
Expand Down

0 comments on commit 5f74472

Please sign in to comment.