From 558d2ff68029b67d0b40f1b098821df7dd1f4b16 Mon Sep 17 00:00:00 2001 From: Jay Robson <45777442+jsrobson10@users.noreply.github.com> Date: Thu, 20 Apr 2023 06:58:42 +1000 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20G38=20with=20Z,=20support?= =?UTF-8?q?=209=20axes=20(#25691)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Scott Lahteine --- Marlin/src/inc/Conditionals_post.h | 6 +++--- Marlin/src/module/endstops.cpp | 14 +++++--------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index c09f6684504e..96b7313f29d2 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 6719925f15fa..ccad00062e2a 100644 --- a/Marlin/src/module/endstops.cpp +++ b/Marlin/src/module/endstops.cpp @@ -913,17 +913,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