1
0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2024-11-23 12:04:19 +00:00

Apply _AXIS macro

This commit is contained in:
Scott Lahteine 2018-05-13 03:25:31 -05:00
parent 03e8f6c1d9
commit bf0fcebfe6
6 changed files with 30 additions and 30 deletions

View File

@ -3027,7 +3027,7 @@ static void do_homing_move(const AxisEnum axis, const float distance, const floa
* before updating the current position.
*/
#define HOMEAXIS(LETTER) homeaxis(LETTER##_AXIS)
#define HOMEAXIS(A) homeaxis(_AXIS(A))
static void homeaxis(const AxisEnum axis) {
@ -3036,7 +3036,7 @@ static void homeaxis(const AxisEnum axis) {
if (axis != Z_AXIS) { BUZZ(100, 880); return; }
#else
#define CAN_HOME(A) \
(axis == A##_AXIS && ((A##_MIN_PIN > -1 && A##_HOME_DIR < 0) || (A##_MAX_PIN > -1 && A##_HOME_DIR > 0)))
(axis == _AXIS(A) && ((A##_MIN_PIN > -1 && A##_HOME_DIR < 0) || (A##_MAX_PIN > -1 && A##_HOME_DIR > 0)))
if (!CAN_HOME(X) && !CAN_HOME(Y) && !CAN_HOME(Z)) return;
#endif
@ -11048,8 +11048,8 @@ inline void gcode_M502() {
*/
#if ENABLED(HYBRID_THRESHOLD)
inline void gcode_M913() {
#define TMC_SAY_PWMTHRS(P,Q) tmc_get_pwmthrs(stepper##Q, TMC_##Q, planner.axis_steps_per_mm[P##_AXIS])
#define TMC_SET_PWMTHRS(P,Q) tmc_set_pwmthrs(stepper##Q, value, planner.axis_steps_per_mm[P##_AXIS])
#define TMC_SAY_PWMTHRS(A,Q) tmc_get_pwmthrs(stepper##Q, TMC_##Q, planner.axis_steps_per_mm[_AXIS(A)])
#define TMC_SET_PWMTHRS(A,Q) tmc_set_pwmthrs(stepper##Q, value, planner.axis_steps_per_mm[_AXIS(A)])
#define TMC_SAY_PWMTHRS_E(E) do{ const uint8_t extruder = E; tmc_get_pwmthrs(stepperE##E, TMC_E##E, planner.axis_steps_per_mm[E_AXIS_N]); }while(0)
#define TMC_SET_PWMTHRS_E(E) do{ const uint8_t extruder = E; tmc_set_pwmthrs(stepperE##E, value, planner.axis_steps_per_mm[E_AXIS_N]); }while(0)
@ -13039,7 +13039,7 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) {
return;
}
#define MBL_SEGMENT_END(A) (current_position[A ##_AXIS] + (destination[A ##_AXIS] - current_position[A ##_AXIS]) * normalized_dist)
#define MBL_SEGMENT_END(A) (current_position[_AXIS(A)] + (destination[_AXIS(A)] - current_position[_AXIS(A)]) * normalized_dist)
float normalized_dist, end[XYZE];
const int8_t gcx = max(cx1, cx2), gcy = max(cy1, cy2);
@ -13083,7 +13083,7 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) {
#elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
#define CELL_INDEX(A,V) ((V - bilinear_start[A##_AXIS]) * ABL_BG_FACTOR(A##_AXIS))
#define CELL_INDEX(A,V) ((V - bilinear_start[_AXIS(A)]) * ABL_BG_FACTOR(_AXIS(A)))
/**
* Prepare a bilinear-leveled linear move on Cartesian,
@ -13107,7 +13107,7 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) {
return;
}
#define LINE_SEGMENT_END(A) (current_position[A ##_AXIS] + (destination[A ##_AXIS] - current_position[A ##_AXIS]) * normalized_dist)
#define LINE_SEGMENT_END(A) (current_position[_AXIS(A)] + (destination[_AXIS(A)] - current_position[_AXIS(A)]) * normalized_dist)
float normalized_dist, end[XYZE];
const int8_t gcx = max(cx1, cx2), gcy = max(cy1, cy2);

View File

@ -62,7 +62,7 @@
#if HAS_TRINAMIC
#include "stepper_indirection.h"
#include "tmc_util.h"
#define TMC_GET_PWMTHRS(P,Q) _tmc_thrs(stepper##Q.microsteps(), stepper##Q.TPWMTHRS(), planner.axis_steps_per_mm[P##_AXIS])
#define TMC_GET_PWMTHRS(A,Q) _tmc_thrs(stepper##Q.microsteps(), stepper##Q.TPWMTHRS(), planner.axis_steps_per_mm[_AXIS(A)])
#endif
#if ENABLED(AUTO_BED_LEVELING_UBL)
@ -1343,7 +1343,7 @@ void MarlinSettings::postprocess() {
#endif
#if ENABLED(HYBRID_THRESHOLD)
#define TMC_SET_PWMTHRS(P,Q) tmc_set_pwmthrs(stepper##Q, tmc_hybrid_threshold[TMC_##Q], planner.axis_steps_per_mm[P##_AXIS])
#define TMC_SET_PWMTHRS(A,Q) tmc_set_pwmthrs(stepper##Q, tmc_hybrid_threshold[TMC_##Q], planner.axis_steps_per_mm[_AXIS(A)])
uint32_t tmc_hybrid_threshold[TMC_AXES];
EEPROM_READ(tmc_hybrid_threshold);
if (!validating) {

View File

@ -181,7 +181,7 @@ void Endstops::report_state() {
#endif
#define _ENDSTOP_HIT_ECHO(A,C) do{ \
SERIAL_ECHOPAIR(" " STRINGIFY(A) ":", stepper.triggered_position_mm(A ##_AXIS)); \
SERIAL_ECHOPAIR(" " STRINGIFY(A) ":", stepper.triggered_position_mm(_AXIS(A))); \
_SET_STOP_CHAR(A,C); }while(0)
#define _ENDSTOP_HIT_TEST(A,C) \

View File

@ -30,7 +30,7 @@
#define XYZ 3
// For use in macros that take a single axis letter
#define _AXIS(AXIS) AXIS ##_AXIS
#define _AXIS(A) (A##_AXIS)
#define _XMIN_ 100
#define _YMIN_ 200

View File

@ -2188,11 +2188,11 @@ void Planner::buffer_segment(const float &a, const float &b, const float &c, con
// Always split the first move into two (if not homing or probing)
if (!has_blocks_queued()) {
#define _BETWEEN(A) (position[A##_AXIS] + target[A##_AXIS]) >> 1
#define _BETWEEN(A) (position[_AXIS(A)] + target[_AXIS(A)]) >> 1
const int32_t between[ABCE] = { _BETWEEN(A), _BETWEEN(B), _BETWEEN(C), _BETWEEN(E) };
#if HAS_POSITION_FLOAT
#define _BETWEEN_F(A) (position_float[A##_AXIS] + target_float[A##_AXIS]) * 0.5
#define _BETWEEN_F(A) (position_float[_AXIS(A)] + target_float[_AXIS(A)]) * 0.5
const float between_float[ABCE] = { _BETWEEN_F(A), _BETWEEN_F(B), _BETWEEN_F(C), _BETWEEN_F(E) };
#endif

View File

@ -167,20 +167,20 @@ volatile int32_t Stepper::endstops_trigsteps[XYZ];
#define LOCKED_X2_MOTOR locked_x2_motor
#define LOCKED_Y2_MOTOR locked_y2_motor
#define LOCKED_Z2_MOTOR locked_z2_motor
#define DUAL_ENDSTOP_APPLY_STEP(AXIS,v) \
#define DUAL_ENDSTOP_APPLY_STEP(A,V) \
if (performing_homing) { \
if (AXIS##_HOME_DIR < 0) { \
if (!(TEST(endstops.old_endstop_bits, AXIS##_MIN) && count_direction[AXIS##_AXIS] < 0) && !LOCKED_##AXIS##_MOTOR) AXIS##_STEP_WRITE(v); \
if (!(TEST(endstops.old_endstop_bits, AXIS##2_MIN) && count_direction[AXIS##_AXIS] < 0) && !LOCKED_##AXIS##2_MOTOR) AXIS##2_STEP_WRITE(v); \
if (A##_HOME_DIR < 0) { \
if (!(TEST(endstops.old_endstop_bits, A##_MIN) && count_direction[_AXIS(A)] < 0) && !LOCKED_##A##_MOTOR) A##_STEP_WRITE(V); \
if (!(TEST(endstops.old_endstop_bits, A##2_MIN) && count_direction[_AXIS(A)] < 0) && !LOCKED_##A##2_MOTOR) A##2_STEP_WRITE(V); \
} \
else { \
if (!(TEST(endstops.old_endstop_bits, AXIS##_MAX) && count_direction[AXIS##_AXIS] > 0) && !LOCKED_##AXIS##_MOTOR) AXIS##_STEP_WRITE(v); \
if (!(TEST(endstops.old_endstop_bits, AXIS##2_MAX) && count_direction[AXIS##_AXIS] > 0) && !LOCKED_##AXIS##2_MOTOR) AXIS##2_STEP_WRITE(v); \
if (!(TEST(endstops.old_endstop_bits, A##_MAX) && count_direction[_AXIS(A)] > 0) && !LOCKED_##A##_MOTOR) A##_STEP_WRITE(V); \
if (!(TEST(endstops.old_endstop_bits, A##2_MAX) && count_direction[_AXIS(A)] > 0) && !LOCKED_##A##2_MOTOR) A##2_STEP_WRITE(V); \
} \
} \
else { \
AXIS##_STEP_WRITE(v); \
AXIS##2_STEP_WRITE(v); \
A##_STEP_WRITE(V); \
A##2_STEP_WRITE(V); \
}
#endif
@ -331,13 +331,13 @@ void Stepper::wake_up() {
void Stepper::set_directions() {
#define SET_STEP_DIR(AXIS) \
if (motor_direction(AXIS ##_AXIS)) { \
if (motor_direction(_AXIS(AXIS))) { \
AXIS ##_APPLY_DIR(INVERT_## AXIS ##_DIR, false); \
count_direction[AXIS ##_AXIS] = -1; \
count_direction[_AXIS(AXIS)] = -1; \
} \
else { \
AXIS ##_APPLY_DIR(!INVERT_## AXIS ##_DIR, false); \
count_direction[AXIS ##_AXIS] = 1; \
count_direction[_AXIS(AXIS)] = 1; \
}
#if HAS_X_DIR