diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp index d0ad234a7f664..e32c71b7dd4ed 100644 --- a/Marlin/src/module/endstops.cpp +++ b/Marlin/src/module/endstops.cpp @@ -786,7 +786,6 @@ void Endstops::update() { #define PROCESS_ENDSTOP_Z(MINMAX) PROCESS_DUAL_ENDSTOP(Z, MINMAX) #endif - #if ENABLED(G38_PROBE_TARGET) // For G38 moves check the probe's pin for ALL movement if (G38_move && TEST_ENDSTOP(Z_MIN_PROBE) == TERN1(G38_PROBE_AWAY, (G38_move < 4))) { @@ -801,17 +800,20 @@ void Endstops::update() { // Signal, after validation, if an endstop limit is pressed or not #if HAS_X_AXIS - #if ENABLED(FT_MOTION) - const bool x_moving_pos = ftMotion.axis_moving_pos(X_AXIS_HEAD), - x_moving_neg = ftMotion.axis_moving_neg(X_AXIS_HEAD); - #define X_MOVE_TEST x_moving_pos || x_moving_neg - #define X_NEG_DIR_TEST x_moving_neg - #else - #define X_MOVE_TEST stepper.axis_is_moving(X_AXIS) - #define X_NEG_DIR_TEST !stepper.motor_direction(X_AXIS_HEAD) - #endif - if (X_MOVE_TEST) { - if (X_NEG_DIR_TEST) { // -direction + bool x_moving, x_moving_neg; + if (TERN0(FT_MOTION, ftMotion.cfg.mode != ftMotionMode_DISABLED)) { + #if ENABLED(FT_MOTION) + const bool x_moving_pos = ftMotion.axis_moving_pos(X_AXIS_HEAD); + x_moving_neg = ftMotion.axis_moving_neg(X_AXIS_HEAD); + x_moving = x_moving_pos || x_moving_neg; + #endif + } + else { + x_moving = stepper.axis_is_moving(X_AXIS); + x_moving_neg = !stepper.motor_direction(X_AXIS_HEAD); + } + if (x_moving) { + if (x_moving_neg) { // -direction #if HAS_X_MIN_STATE PROCESS_ENDSTOP_X(MIN); #if CORE_DIAG(XY, Y, MIN) @@ -843,17 +845,20 @@ void Endstops::update() { #endif // HAS_X_AXIS #if HAS_Y_AXIS - #if ENABLED(FT_MOTION) - const bool y_moving_pos = ftMotion.axis_moving_pos(Y_AXIS_HEAD), - y_moving_neg = ftMotion.axis_moving_neg(Y_AXIS_HEAD); - #define Y_MOVE_TEST y_moving_pos || y_moving_neg - #define Y_NEG_DIR_TEST y_moving_neg - #else - #define Y_MOVE_TEST stepper.axis_is_moving(Y_AXIS) - #define Y_NEG_DIR_TEST !stepper.motor_direction(Y_AXIS_HEAD) - #endif - if (Y_MOVE_TEST) { - if (Y_NEG_DIR_TEST) { // -direction + bool y_moving, y_moving_neg; + if (TERN0(FT_MOTION, ftMotion.cfg.mode != ftMotionMode_DISABLED)) { + #if ENABLED(FT_MOTION) + const bool y_moving_pos = ftMotion.axis_moving_pos(Y_AXIS_HEAD); + y_moving_neg = ftMotion.axis_moving_neg(Y_AXIS_HEAD); + y_moving = y_moving_pos || y_moving_neg; + #endif + } + else { + y_moving = stepper.axis_is_moving(Y_AXIS); + y_moving_neg = !stepper.motor_direction(Y_AXIS_HEAD); + } + if (y_moving) { + if (y_moving_neg) { // -direction #if HAS_Y_MIN_STATE PROCESS_ENDSTOP_Y(MIN); #if CORE_DIAG(XY, X, MIN) @@ -885,17 +890,20 @@ void Endstops::update() { #endif // HAS_Y_AXIS #if HAS_Z_AXIS - #if ENABLED(FT_MOTION) - const bool z_moving_pos = ftMotion.axis_moving_pos(Z_AXIS_HEAD), - z_moving_neg = ftMotion.axis_moving_neg(Z_AXIS_HEAD); - #define Z_MOVE_TEST z_moving_pos || z_moving_neg - #define Z_NEG_DIR_TEST z_moving_neg - #else - #define Z_MOVE_TEST stepper.axis_is_moving(Z_AXIS) - #define Z_NEG_DIR_TEST !stepper.motor_direction(Z_AXIS_HEAD) - #endif - if (Z_MOVE_TEST) { - if (Z_NEG_DIR_TEST) { // Z -direction. Gantry down, bed up. + bool z_moving, z_moving_neg; + if (TERN0(FT_MOTION, ftMotion.cfg.mode != ftMotionMode_DISABLED)) { + #if ENABLED(FT_MOTION) + const bool z_moving_pos = ftMotion.axis_moving_pos(Z_AXIS_HEAD); + z_moving_neg = ftMotion.axis_moving_neg(Z_AXIS_HEAD); + z_moving = z_moving_pos || z_moving_neg; + #endif + } + else { + z_moving = stepper.axis_is_moving(Z_AXIS); + z_moving_neg = !stepper.motor_direction(Z_AXIS_HEAD); + } + if (z_moving) { + if (z_moving_neg) { // Z -direction. Gantry down, bed up. #if HAS_Z_MIN_STATE // If the Z_MIN_PIN is being used for the probe there's no // separate Z_MIN endstop. But a Z endstop could be wired @@ -939,9 +947,20 @@ void Endstops::update() { #endif // HAS_Z_AXIS #if HAS_I_AXIS - // TODO: FT_Motion logic. - if (stepper.axis_is_moving(I_AXIS)) { - if (!stepper.motor_direction(I_AXIS_HEAD)) { // -direction + bool i_moving, i_moving_neg; + if (TERN0(FT_MOTION, ftMotion.cfg.mode != ftMotionMode_DISABLED)) { + #if ENABLED(FT_MOTION) + const bool i_moving_pos = ftMotion.axis_moving_pos(I_AXIS_HEAD); + i_moving_neg = ftMotion.axis_moving_neg(I_AXIS_HEAD); + i_moving = i_moving_pos || i_moving_neg; + #endif + } + else { + i_moving = stepper.axis_is_moving(I_AXIS); + i_moving_neg = !stepper.motor_direction(I_AXIS_HEAD); + } + if (i_moving) { + if (i_moving_neg) { // -direction #if HAS_I_MIN_STATE PROCESS_ENDSTOP(I, MIN); #endif @@ -955,8 +974,20 @@ void Endstops::update() { #endif // HAS_I_AXIS #if HAS_J_AXIS - if (stepper.axis_is_moving(J_AXIS)) { - if (!stepper.motor_direction(J_AXIS_HEAD)) { // -direction + bool j_moving, j_moving_neg; + if (TERN0(FT_MOTION, ftMotion.cfg.mode != ftMotionMode_DISABLED)) { + #if ENABLED(FT_MOTION) + const bool j_moving_pos = ftMotion.axis_moving_pos(J_AXIS_HEAD); + j_moving_neg = ftMotion.axis_moving_neg(J_AXIS_HEAD); + j_moving = j_moving_pos || j_moving_neg; + #endif + } + else { + j_moving = stepper.axis_is_moving(J_AXIS); + j_moving_neg = !stepper.motor_direction(J_AXIS_HEAD); + } + if (j_moving) { + if (j_moving_neg) { // -direction #if HAS_J_MIN_STATE PROCESS_ENDSTOP(J, MIN); #endif @@ -970,8 +1001,20 @@ void Endstops::update() { #endif // HAS_J_AXIS #if HAS_K_AXIS - if (stepper.axis_is_moving(K_AXIS)) { - if (!stepper.motor_direction(K_AXIS_HEAD)) { // -direction + bool k_moving, k_moving_neg; + if (TERN0(FT_MOTION, ftMotion.cfg.mode != ftMotionMode_DISABLED)) { + #if ENABLED(FT_MOTION) + const bool k_moving_pos = ftMotion.axis_moving_pos(K_AXIS_HEAD); + k_moving_neg = ftMotion.axis_moving_neg(K_AXIS_HEAD); + k_moving = k_moving_pos || k_moving_neg; + #endif + } + else { + k_moving = stepper.axis_is_moving(K_AXIS); + k_moving_neg = !stepper.motor_direction(K_AXIS_HEAD); + } + if (k_moving) { + if (k_moving_neg) { // -direction #if HAS_K_MIN_STATE PROCESS_ENDSTOP(K, MIN); #endif @@ -985,8 +1028,20 @@ void Endstops::update() { #endif // HAS_K_AXIS #if HAS_U_AXIS - if (stepper.axis_is_moving(U_AXIS)) { - if (!stepper.motor_direction(U_AXIS_HEAD)) { // -direction + bool u_moving, u_moving_neg; + if (TERN0(FT_MOTION, ftMotion.cfg.mode != ftMotionMode_DISABLED)) { + #if ENABLED(FT_MOTION) + const bool u_moving_pos = ftMotion.axis_moving_pos(U_AXIS_HEAD); + u_moving_neg = ftMotion.axis_moving_neg(U_AXIS_HEAD); + u_moving = u_moving_pos || u_moving_neg; + #endif + } + else { + u_moving = stepper.axis_is_moving(U_AXIS); + u_moving_neg = !stepper.motor_direction(U_AXIS_HEAD); + } + if (u_moving) { + if (u_moving_neg) { // -direction #if HAS_U_MIN_STATE PROCESS_ENDSTOP(U, MIN); #endif @@ -1000,8 +1055,20 @@ void Endstops::update() { #endif // HAS_U_AXIS #if HAS_V_AXIS - if (stepper.axis_is_moving(V_AXIS)) { - if (!stepper.motor_direction(V_AXIS_HEAD)) { // -direction + bool v_moving, v_moving_neg; + if (TERN0(FT_MOTION, ftMotion.cfg.mode != ftMotionMode_DISABLED)) { + #if ENABLED(FT_MOTION) + const bool v_moving_pos = ftMotion.axis_moving_pos(V_AXIS_HEAD); + v_moving_neg = ftMotion.axis_moving_neg(V_AXIS_HEAD); + v_moving = v_moving_pos || v_moving_neg; + #endif + } + else { + v_moving = stepper.axis_is_moving(V_AXIS); + v_moving_neg = !stepper.motor_direction(V_AXIS_HEAD); + } + if (v_moving) { + if (v_moving_neg) { // -direction #if HAS_V_MIN_STATE PROCESS_ENDSTOP(V, MIN); #endif @@ -1015,8 +1082,20 @@ void Endstops::update() { #endif // HAS_V_AXIS #if HAS_W_AXIS - if (stepper.axis_is_moving(W_AXIS)) { - if (!stepper.motor_direction(W_AXIS_HEAD)) { // -direction + bool w_moving, w_moving_neg; + if (TERN0(FT_MOTION, ftMotion.cfg.mode != ftMotionMode_DISABLED)) { + #if ENABLED(FT_MOTION) + const bool w_moving_pos = ftMotion.axis_moving_pos(W_AXIS_HEAD); + w_moving_neg = ftMotion.axis_moving_neg(W_AXIS_HEAD); + w_moving = w_moving_pos || w_moving_neg; + #endif + } + else { + w_moving = stepper.axis_is_moving(W_AXIS); + w_moving_neg = !stepper.motor_direction(W_AXIS_HEAD); + } + if (w_moving) { + if (w_moving_neg) { // -direction #if HAS_W_MIN_STATE PROCESS_ENDSTOP(W, MIN); #endif