diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 4f15621a254b..ad9a1efe10cd 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -341,21 +341,21 @@ #ifdef MANUAL_U_HOME_POS #define U_HOME_POS MANUAL_U_HOME_POS #else - #define U_HOME_POS (U_HOME_DIR < 0 ? U_MIN_POS : U_MAX_POS) + #define U_HOME_POS TERN(U_HOME_TO_MIN, U_MIN_POS, U_MAX_POS) #endif #endif #if HAS_V_AXIS #ifdef MANUAL_V_HOME_POS #define V_HOME_POS MANUAL_V_HOME_POS #else - #define V_HOME_POS (V_HOME_DIR < 0 ? V_MIN_POS : V_MAX_POS) + #define V_HOME_POS TERN(V_HOME_TO_MIN, V_MIN_POS, V_MAX_POS) #endif #endif #if HAS_W_AXIS #ifdef MANUAL_W_HOME_POS #define W_HOME_POS MANUAL_W_HOME_POS #else - #define W_HOME_POS (W_HOME_DIR < 0 ? W_MIN_POS : W_MAX_POS) + #define W_HOME_POS TERN(W_HOME_TO_MIN, W_MIN_POS, W_MAX_POS) #endif #endif diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp index ef5f5d06e120..b6cbf47c4b90 100644 --- a/Marlin/src/module/endstops.cpp +++ b/Marlin/src/module/endstops.cpp @@ -1107,17 +1107,13 @@ void Endstops::update() { #endif #if HAS_G38_PROBE // TODO (DerAndere): Add support for HAS_I_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 - #if HAS_Z_AXIS - else if (stepper.axis_is_moving(Z_AXIS)) { _ENDSTOP_HIT(Z, TERN(Z_HOME_TO_MIN, MIN, MAX)); planner.endstop_triggered(Z_AXIS); } - #endif + if (G38_move && TEST_ENDSTOP(_ENDSTOP(Z, TERN(USES_Z_MIN_PROBE_PIN, MIN_PROBE, MIN))) == 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)); } + const Flags moving = { value_t(NUM_AXES)(0 MAIN_AXIS_MAP(_G38_SET)) }; + MAIN_AXIS_MAP(_G38_RESP); } #endif