Skip to content

Commit 02914fb

Browse files
committed
support up to 9 axes
1 parent 043b917 commit 02914fb

File tree

1 file changed

+4
-18
lines changed

1 file changed

+4
-18
lines changed

Marlin/src/module/endstops.cpp

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -916,24 +916,10 @@ void Endstops::update() {
916916
// For G38 moves check the probe's pin for ALL movement
917917
if (G38_move && TEST_ENDSTOP(_ENDSTOP(Z, TERN(USES_Z_MIN_PROBE_PIN, MIN_PROBE, MIN))) == TERN1(G38_PROBE_AWAY, (G38_move < 4))) {
918918
G38_did_trigger = true;
919-
#if HAS_X_AXIS
920-
const bool xmoving = stepper.axis_is_moving(X_AXIS);
921-
#endif
922-
#if HAS_Y_AXIS
923-
const bool ymoving = stepper.axis_is_moving(Y_AXIS);
924-
#endif
925-
#if HAS_Z_AXIS
926-
const bool zmoving = stepper.axis_is_moving(Z_AXIS);
927-
#endif
928-
#if HAS_X_AXIS
929-
if (xmoving) { _ENDSTOP_HIT(X, ENDSTOP); planner.endstop_triggered(X_AXIS); }
930-
#endif
931-
#if HAS_Y_AXIS
932-
if (ymoving) { _ENDSTOP_HIT(Y, ENDSTOP); planner.endstop_triggered(Y_AXIS); }
933-
#endif
934-
#if HAS_Z_AXIS
935-
if (zmoving) { _ENDSTOP_HIT(Z, ENDSTOP); planner.endstop_triggered(Z_AXIS); }
936-
#endif
919+
#define _G38_SET(Q) | (stepper.axis_is_moving(_AXIS(Q)) << _AXIS(Q))
920+
#define _G38_RESP(Q) if (moving[_AXIS(Q)]) { _ENDSTOP_HIT(Q, ENDSTOP); planner.endstop_triggered(_AXIS(Q)); }
921+
const Flags<NUM_AXES> moving = { value_t(NUM_AXES)(0 MAIN_AXIS_MAP(_G38_SET)) };
922+
MAIN_AXIS_MAP(_G38_RESP);
937923
}
938924
#endif
939925

0 commit comments

Comments
 (0)