Skip to content

Commit

Permalink
Shorten a little
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Aug 24, 2021
1 parent 1203cd7 commit b836456
Showing 1 changed file with 54 additions and 51 deletions.
105 changes: 54 additions & 51 deletions Marlin/src/module/stepper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,20 +257,21 @@ xyze_int8_t Stepper::count_direction{0};
};
#endif

#define DUAL_ENDSTOP_APPLY_STEP(A,V) \
if (separate_multi_axis) { \
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); \
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); \
} \
else { \
if (TERN0(HAS_##A## _MAX, !(TEST(endstops.state(), A## _MAX) && count_direction[_AXIS(A)] > 0) && !locked_##A## _motor)) A## _STEP_WRITE(V); \
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); \
} \
} \
else { \
A##_STEP_WRITE(V); \
A##2_STEP_WRITE(V); \
#define DUAL_ENDSTOP_APPLY_STEP(A,V) \
if (separate_multi_axis) { \
const bool tomin = count_direction[_AXIS(A)] < 0; \
if (TERN0(A##_HOME_TO_MIN, tomin)) { \
if (TERN0(HAS_##A## _MIN, !TEST(endstops.state(), A## _MIN) && !locked_##A## _motor)) A## _STEP_WRITE(V); \
if (TERN0(HAS_##A##2_MIN, !TEST(endstops.state(), A##2_MIN) && !locked_##A##2_motor)) A##2_STEP_WRITE(V); \
} \
else if (TERN0(A##_HOME_TO_MAX, !tomin)) { \
if (TERN0(HAS_##A## _MAX, !TEST(endstops.state(), A## _MAX) && !locked_##A## _motor)) A## _STEP_WRITE(V); \
if (TERN0(HAS_##A##2_MAX, !TEST(endstops.state(), A##2_MAX) && !locked_##A##2_motor)) A##2_STEP_WRITE(V); \
} \
} \
else { \
A##_STEP_WRITE(V); \
A##2_STEP_WRITE(V); \
}

#define DUAL_SEPARATE_APPLY_STEP(A,V) \
Expand All @@ -283,23 +284,24 @@ xyze_int8_t Stepper::count_direction{0};
A##2_STEP_WRITE(V); \
}

#define TRIPLE_ENDSTOP_APPLY_STEP(A,V) \
if (separate_multi_axis) { \
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); \
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); \
if (TERN0(HAS_##A##3_MIN, !(TEST(endstops.state(), A##3_MIN) && count_direction[_AXIS(A)] < 0) && !locked_##A##3_motor)) A##3_STEP_WRITE(V); \
} \
else { \
if (TERN0(HAS_##A## _MAX, !(TEST(endstops.state(), A## _MAX) && count_direction[_AXIS(A)] > 0) && !locked_##A## _motor)) A## _STEP_WRITE(V); \
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 (TERN0(HAS_##A##3_MAX, !(TEST(endstops.state(), A##3_MAX) && count_direction[_AXIS(A)] > 0) && !locked_##A##3_motor)) A##3_STEP_WRITE(V); \
} \
} \
else { \
A##_STEP_WRITE(V); \
A##2_STEP_WRITE(V); \
A##3_STEP_WRITE(V); \
#define TRIPLE_ENDSTOP_APPLY_STEP(A,V) \
if (separate_multi_axis) { \
const bool tomin = count_direction[_AXIS(A)] < 0; \
if (TERN0(A##_HOME_TO_MIN, tomin)) { \
if (TERN0(HAS_##A## _MIN, !TEST(endstops.state(), A## _MIN) && !locked_##A## _motor)) A## _STEP_WRITE(V); \
if (TERN0(HAS_##A##2_MIN, !TEST(endstops.state(), A##2_MIN) && !locked_##A##2_motor)) A##2_STEP_WRITE(V); \
if (TERN0(HAS_##A##3_MIN, !TEST(endstops.state(), A##3_MIN) && !locked_##A##3_motor)) A##3_STEP_WRITE(V); \
} \
else if (TERN0(A##_HOME_TO_MAX, !tomin)) { \
if (TERN0(HAS_##A## _MAX, !TEST(endstops.state(), A## _MAX) && !locked_##A## _motor)) A## _STEP_WRITE(V); \
if (TERN0(HAS_##A##2_MAX, !TEST(endstops.state(), A##2_MAX) && !locked_##A##2_motor)) A##2_STEP_WRITE(V); \
if (TERN0(HAS_##A##3_MAX, !TEST(endstops.state(), A##3_MAX) && !locked_##A##3_motor)) A##3_STEP_WRITE(V); \
} \
} \
else { \
A##_STEP_WRITE(V); \
A##2_STEP_WRITE(V); \
A##3_STEP_WRITE(V); \
}

#define TRIPLE_SEPARATE_APPLY_STEP(A,V) \
Expand All @@ -314,26 +316,27 @@ xyze_int8_t Stepper::count_direction{0};
A##3_STEP_WRITE(V); \
}

#define QUAD_ENDSTOP_APPLY_STEP(A,V) \
if (separate_multi_axis) { \
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); \
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); \
if (TERN0(HAS_##A##3_MIN, !(TEST(endstops.state(), A##3_MIN) && count_direction[_AXIS(A)] < 0) && !locked_##A##3_motor)) A##3_STEP_WRITE(V); \
if (TERN0(HAS_##A##4_MIN, !(TEST(endstops.state(), A##4_MIN) && count_direction[_AXIS(A)] < 0) && !locked_##A##4_motor)) A##4_STEP_WRITE(V); \
} \
else { \
if (TERN0(HAS_##A## _MAX, !(TEST(endstops.state(), A## _MAX) && count_direction[_AXIS(A)] > 0) && !locked_##A## _motor)) A## _STEP_WRITE(V); \
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 (TERN0(HAS_##A##3_MAX, !(TEST(endstops.state(), A##3_MAX) && count_direction[_AXIS(A)] > 0) && !locked_##A##3_motor)) A##3_STEP_WRITE(V); \
if (TERN0(HAS_##A##4_MAX, !(TEST(endstops.state(), A##4_MAX) && count_direction[_AXIS(A)] > 0) && !locked_##A##4_motor)) 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_ENDSTOP_APPLY_STEP(A,V) \
if (separate_multi_axis) { \
const bool tomin = count_direction[_AXIS(A)] < 0; \
if (TERN0(A##_HOME_TO_MIN, tomin)) { \
if (TERN0(HAS_##A## _MIN, !TEST(endstops.state(), A## _MIN) && !locked_##A## _motor)) A## _STEP_WRITE(V); \
if (TERN0(HAS_##A##2_MIN, !TEST(endstops.state(), A##2_MIN) && !locked_##A##2_motor)) A##2_STEP_WRITE(V); \
if (TERN0(HAS_##A##3_MIN, !TEST(endstops.state(), A##3_MIN) && !locked_##A##3_motor)) A##3_STEP_WRITE(V); \
if (TERN0(HAS_##A##4_MIN, !TEST(endstops.state(), A##4_MIN) && !locked_##A##4_motor)) A##4_STEP_WRITE(V); \
} \
if (TERN0(A##_HOME_TO_MAX, !tomin)) { \
if (TERN0(HAS_##A## _MAX, !TEST(endstops.state(), A## _MAX) && !locked_##A## _motor)) A## _STEP_WRITE(V); \
if (TERN0(HAS_##A##2_MAX, !TEST(endstops.state(), A##2_MAX) && !locked_##A##2_motor)) A##2_STEP_WRITE(V); \
if (TERN0(HAS_##A##3_MAX, !TEST(endstops.state(), A##3_MAX) && !locked_##A##3_motor)) A##3_STEP_WRITE(V); \
if (TERN0(HAS_##A##4_MAX, !TEST(endstops.state(), A##4_MAX) && !locked_##A##4_motor)) 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) \
Expand Down

0 comments on commit b836456

Please sign in to comment.