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 ad361d2
Showing 1 changed file with 51 additions and 51 deletions.
102 changes: 51 additions & 51 deletions Marlin/src/module/stepper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,20 +257,20 @@ 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) { \
if (TERN0(A##_HOME_TO_MIN, count_direction[_AXIS(A)] < 0)) { \
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, count_direction[_AXIS(A)] > 0)) { \
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 +283,23 @@ 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) { \
if (TERN0(A##_HOME_TO_MIN, count_direction[_AXIS(A)] < 0)) { \
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, count_direction[_AXIS(A)] > 0)) { \
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 +314,26 @@ 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) { \
if (TERN0(A##_HOME_TO_MIN, count_direction[_AXIS(A)] < 0)) { \
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); \
} \
else if (TERN0(A##_HOME_TO_MAX, count_direction[_AXIS(A)] > 0)) { \
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 ad361d2

Please sign in to comment.