Skip to content

Commit

Permalink
Try this instead
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Jul 29, 2021
1 parent 13771cc commit f791ba5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
27 changes: 12 additions & 15 deletions Marlin/src/module/endstops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -596,14 +596,15 @@ void _O2 Endstops::report_states() {
// endstop ISR or the Stepper ISR.

#if BOTH(DELTA, SENSORLESS_PROBING)
#define _ENDSTOP(AXIS, MINMAX) AXIS ##_MAX
#define _ENDSTOP_PIN(AXIS, MINMAX) AXIS ##_MAX_PIN
#define _ENDSTOP_INVERTING(AXIS, MINMAX) AXIS ##_MAX_ENDSTOP_INVERTING
#define __ENDSTOP(AXIS, ...) AXIS ##_MAX
#define _ENDSTOP_PIN(AXIS, ...) AXIS ##_MAX_PIN
#define _ENDSTOP_INVERTING(AXIS, ...) AXIS ##_MAX_ENDSTOP_INVERTING
#else
#define _ENDSTOP(AXIS, MINMAX) AXIS ##_## MINMAX
#define __ENDSTOP(AXIS, MINMAX) AXIS ##_## MINMAX
#define _ENDSTOP_PIN(AXIS, MINMAX) AXIS ##_## MINMAX ##_PIN
#define _ENDSTOP_INVERTING(AXIS, MINMAX) AXIS ##_## MINMAX ##_ENDSTOP_INVERTING
#endif
#define _ENDSTOP(AXIS, MINMAX) __ENDSTOP(AXIS, MINMAX)

// Check endstops - Could be called from Temperature ISR!
void Endstops::update() {
Expand All @@ -615,10 +616,10 @@ void Endstops::update() {
#define UPDATE_ENDSTOP_BIT(AXIS, MINMAX) SET_BIT_TO(live_state, _ENDSTOP(AXIS, MINMAX), (READ(_ENDSTOP_PIN(AXIS, MINMAX)) != _ENDSTOP_INVERTING(AXIS, MINMAX)))
#define COPY_LIVE_STATE(SRC_BIT, DST_BIT) SET_BIT_TO(live_state, DST_BIT, TEST(live_state, SRC_BIT))

#if ENABLED(G38_PROBE_TARGET) && EITHER(HAS_Z_MIN_PROBE_PIN, USES_Z_MIN_PROBE_PIN) && NONE(CORE_IS_XY, CORE_IS_XZ, MARKFORGED_XY)
#if ENABLED(G38_PROBE_TARGET) && NONE(CORE_IS_XY, CORE_IS_XZ, MARKFORGED_XY)
#define HAS_G38_PROBE 1
// If G38 command is active check Z_MIN_PROBE for ALL movement
if (G38_move) UPDATE_ENDSTOP_BIT(Z, MIN_PROBE);
// 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));
#endif

// With Dual X, endstops are only checked in the homing direction for the active extruder
Expand Down Expand Up @@ -932,14 +933,10 @@ void Endstops::update() {
#endif

#if HAS_G38_PROBE
#if ENABLED(G38_PROBE_AWAY)
#define _G38_OPEN_STATE (G38_move >= 4)
#else
#define _G38_OPEN_STATE LOW
#endif
// If G38 command is active check Z_MIN_PROBE for ALL movement
if (G38_move && TEST_ENDSTOP(_ENDSTOP(Z, MIN_PROBE)) != _G38_OPEN_STATE) {
if (stepper.axis_is_moving(X_AXIS)) { _ENDSTOP_HIT(X, TERN(X_HOME_TO_MIN, MIN, MAX)); planner.endstop_triggered(X_AXIS); }
#define _G38_OPEN_STATE TERN(G38_PROBE_AWAY, (G38_move >= 4), LOW)
// 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))) != _G38_OPEN_STATE) {
if (stepper.axis_is_moving(X_AXIS)) { _ENDSTOP_HIT(X, TERN(X_HOME_TO_MIN, MIN, MAX)); planner.endstop_triggered(X_AXIS); }
#if HAS_Y_AXIS
else if (stepper.axis_is_moving(Y_AXIS)) { _ENDSTOP_HIT(Y, TERN(Y_HOME_TO_MIN, MIN, MAX)); planner.endstop_triggered(Y_AXIS); }
#endif
Expand Down
4 changes: 4 additions & 0 deletions Marlin/src/pins/pins_postprocess.h
Original file line number Diff line number Diff line change
Expand Up @@ -1134,6 +1134,10 @@
#define USE_ZMIN_PLUG
#endif
#undef _STOP_IN_USE
#if !USES_Z_MIN_PROBE_PIN
#undef Z_MIN_PROBE_PIN
#define Z_MIN_PROBE_PIN -1
#endif
#if DISABLED(USE_XMIN_PLUG)
#undef X_MIN_PIN
#define X_MIN_PIN -1
Expand Down

0 comments on commit f791ba5

Please sign in to comment.