🐛 Fix Multi-Endstop stepping (#22625)

This commit is contained in:
Ryan V1 2021-08-24 20:34:10 -07:00 committed by GitHub
parent 7dec5c2674
commit 71c96db932
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -257,25 +257,30 @@ xyze_int8_t Stepper::count_direction{0};
}; };
#endif #endif
#define DUAL_ENDSTOP_APPLY_STEP(A,V) \ #define MINDIR(A) (count_direction[_AXIS(A)] < 0)
if (separate_multi_axis) { \ #define MAXDIR(A) (count_direction[_AXIS(A)] > 0)
if (ENABLED(A##_HOME_TO_MIN)) { \
if (TERN0(HAS_##A##_MIN, !(TEST(endstops.state(), A##_MIN) && count_direction[_AXIS(A)] < 0) && !locked_##A##_motor)) A##_STEP_WRITE(V); \ #define STEPTEST(A,M,I) TERN0(HAS_ ##A## ##I## _ ##M, !(TEST(endstops.state(), A## ##I## _ ##M) && M## DIR(A)) && !locked_ ##A## ##I## _motor)
if (TERN0(HAS_##A##2_MIN, !(TEST(endstops.state(), A##2_MIN) && count_direction[_AXIS(A)] < 0) && !locked_##A##2_motor)) A##2_STEP_WRITE(V); \
} \ #define DUAL_ENDSTOP_APPLY_STEP(A,V) \
else { \ if (separate_multi_axis) { \
if (TERN0(HAS_##A##_MAX, !(TEST(endstops.state(), A##_MAX) && count_direction[_AXIS(A)] > 0) && !locked_##A##_motor)) A##_STEP_WRITE(V); \ if (ENABLED(A##_HOME_TO_MIN)) { \
if (TERN0(HAS_##A##2_MAX, !(TEST(endstops.state(), A##2_MAX) && count_direction[_AXIS(A)] > 0) && !locked_##A##2_motor)) A##2_STEP_WRITE(V); \ if (STEPTEST(A,MIN, )) A## _STEP_WRITE(V); \
} \ if (STEPTEST(A,MIN,2)) A##2_STEP_WRITE(V); \
} \ } \
else { \ else if (ENABLED(A##_HOME_TO_MAX)) { \
A##_STEP_WRITE(V); \ if (STEPTEST(A,MAX, )) A## _STEP_WRITE(V); \
A##2_STEP_WRITE(V); \ if (STEPTEST(A,MAX,2)) A##2_STEP_WRITE(V); \
} \
} \
else { \
A##_STEP_WRITE(V); \
A##2_STEP_WRITE(V); \
} }
#define DUAL_SEPARATE_APPLY_STEP(A,V) \ #define DUAL_SEPARATE_APPLY_STEP(A,V) \
if (separate_multi_axis) { \ if (separate_multi_axis) { \
if (!locked_##A##_motor) A##_STEP_WRITE(V); \ if (!locked_##A## _motor) A## _STEP_WRITE(V); \
if (!locked_##A##2_motor) A##2_STEP_WRITE(V); \ if (!locked_##A##2_motor) A##2_STEP_WRITE(V); \
} \ } \
else { \ else { \
@ -283,60 +288,68 @@ xyze_int8_t Stepper::count_direction{0};
A##2_STEP_WRITE(V); \ A##2_STEP_WRITE(V); \
} }
#define TRIPLE_ENDSTOP_APPLY_STEP(A,V) \ #define TRIPLE_ENDSTOP_APPLY_STEP(A,V) \
if (separate_multi_axis) { \ if (separate_multi_axis) { \
if (ENABLED(A##_HOME_TO_MIN)) { \ if (ENABLED(A##_HOME_TO_MIN)) { \
if (!(TEST(endstops.state(), A##_MIN) && count_direction[_AXIS(A)] < 0) && !locked_##A##_motor) A##_STEP_WRITE(V); \ if (STEPTEST(A,MIN, )) A## _STEP_WRITE(V); \
if (!(TEST(endstops.state(), A##2_MIN) && count_direction[_AXIS(A)] < 0) && !locked_##A##2_motor) A##2_STEP_WRITE(V); \ if (STEPTEST(A,MIN,2)) A##2_STEP_WRITE(V); \
if (!(TEST(endstops.state(), A##3_MIN) && count_direction[_AXIS(A)] < 0) && !locked_##A##3_motor) A##3_STEP_WRITE(V); \ if (STEPTEST(A,MIN,3)) A##3_STEP_WRITE(V); \
} \ } \
else { \ else if (ENABLED(A##_HOME_TO_MAX)) { \
if (!(TEST(endstops.state(), A##_MAX) && count_direction[_AXIS(A)] > 0) && !locked_##A##_motor) A##_STEP_WRITE(V); \ if (STEPTEST(A,MAX, )) A## _STEP_WRITE(V); \
if (!(TEST(endstops.state(), A##2_MAX) && count_direction[_AXIS(A)] > 0) && !locked_##A##2_motor) A##2_STEP_WRITE(V); \ if (STEPTEST(A,MAX,2)) A##2_STEP_WRITE(V); \
if (!(TEST(endstops.state(), A##3_MAX) && count_direction[_AXIS(A)] > 0) && !locked_##A##3_motor) A##3_STEP_WRITE(V); \ if (STEPTEST(A,MAX,3)) A##3_STEP_WRITE(V); \
} \ } \
} \ } \
else { \ else { \
A##_STEP_WRITE(V); \ A##_STEP_WRITE(V); \
A##2_STEP_WRITE(V); \ A##2_STEP_WRITE(V); \
A##3_STEP_WRITE(V); \ A##3_STEP_WRITE(V); \
} }
#define TRIPLE_SEPARATE_APPLY_STEP(A,V) \ #define TRIPLE_SEPARATE_APPLY_STEP(A,V) \
if (separate_multi_axis) { \ if (separate_multi_axis) { \
if (!locked_##A##_motor) A##_STEP_WRITE(V); \ if (!locked_##A## _motor) A## _STEP_WRITE(V); \
if (!locked_##A##2_motor) A##2_STEP_WRITE(V); \ if (!locked_##A##2_motor) A##2_STEP_WRITE(V); \
if (!locked_##A##3_motor) A##3_STEP_WRITE(V); \ if (!locked_##A##3_motor) A##3_STEP_WRITE(V); \
} \ } \
else { \ else { \
A##_STEP_WRITE(V); \ A## _STEP_WRITE(V); \
A##2_STEP_WRITE(V); \ A##2_STEP_WRITE(V); \
A##3_STEP_WRITE(V); \ A##3_STEP_WRITE(V); \
} }
#define QUAD_ENDSTOP_APPLY_STEP(A,V) \ #define QUAD_ENDSTOP_APPLY_STEP(A,V) \
if (separate_multi_axis) { \ if (separate_multi_axis) { \
if (!(TEST(endstops.state(), (TERN(A##_HOME_TO_MIN, A##_MIN, A##_MAX))) && count_direction[_AXIS(A)] < 0) && !locked_##A##_motor) A##_STEP_WRITE(V); \ if (ENABLED(A##_HOME_TO_MIN)) { \
if (!(TEST(endstops.state(), (TERN(A##_HOME_TO_MIN, A##2_MIN, A##2_MAX))) && count_direction[_AXIS(A)] < 0) && !locked_##A##2_motor) A##2_STEP_WRITE(V); \ if (STEPTEST(A,MIN, )) A## _STEP_WRITE(V); \
if (!(TEST(endstops.state(), (TERN(A##_HOME_TO_MIN, A##3_MIN, A##3_MAX))) && count_direction[_AXIS(A)] < 0) && !locked_##A##3_motor) A##3_STEP_WRITE(V); \ if (STEPTEST(A,MIN,2)) A##2_STEP_WRITE(V); \
if (!(TEST(endstops.state(), (TERN(A##_HOME_TO_MIN, A##4_MIN, A##4_MAX))) && count_direction[_AXIS(A)] < 0) && !locked_##A##4_motor) A##4_STEP_WRITE(V); \ if (STEPTEST(A,MIN,3)) A##3_STEP_WRITE(V); \
} \ if (STEPTEST(A,MIN,4)) A##4_STEP_WRITE(V); \
else { \ } \
A##_STEP_WRITE(V); \ else if (ENABLED(A##_HOME_TO_MAX)) { \
A##2_STEP_WRITE(V); \ if (STEPTEST(A,MAX, )) A## _STEP_WRITE(V); \
A##3_STEP_WRITE(V); \ if (STEPTEST(A,MAX,2)) A##2_STEP_WRITE(V); \
A##4_STEP_WRITE(V); \ if (STEPTEST(A,MAX,3)) A##3_STEP_WRITE(V); \
if (STEPTEST(A,MAX,4)) A##4_STEP_WRITE(V); \
} \
} \
else { \
A## _STEP_WRITE(V); \
A##2_STEP_WRITE(V); \
A##3_STEP_WRITE(V); \
A##4_STEP_WRITE(V); \
} }
#define QUAD_SEPARATE_APPLY_STEP(A,V) \ #define QUAD_SEPARATE_APPLY_STEP(A,V) \
if (separate_multi_axis) { \ if (separate_multi_axis) { \
if (!locked_##A##_motor) A##_STEP_WRITE(V); \ if (!locked_##A## _motor) A## _STEP_WRITE(V); \
if (!locked_##A##2_motor) A##2_STEP_WRITE(V); \ if (!locked_##A##2_motor) A##2_STEP_WRITE(V); \
if (!locked_##A##3_motor) A##3_STEP_WRITE(V); \ if (!locked_##A##3_motor) A##3_STEP_WRITE(V); \
if (!locked_##A##4_motor) A##4_STEP_WRITE(V); \ if (!locked_##A##4_motor) A##4_STEP_WRITE(V); \
} \ } \
else { \ else { \
A##_STEP_WRITE(V); \ A## _STEP_WRITE(V); \
A##2_STEP_WRITE(V); \ A##2_STEP_WRITE(V); \
A##3_STEP_WRITE(V); \ A##3_STEP_WRITE(V); \
A##4_STEP_WRITE(V); \ A##4_STEP_WRITE(V); \