From bf0fcebfe634bf58a2137acfe758c789da908170 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 13 May 2018 03:25:31 -0500 Subject: [PATCH] Apply _AXIS macro --- Marlin/Marlin_main.cpp | 14 +++++++------- Marlin/configuration_store.cpp | 4 ++-- Marlin/endstops.cpp | 2 +- Marlin/macros.h | 2 +- Marlin/planner.cpp | 4 ++-- Marlin/stepper.cpp | 34 +++++++++++++++++----------------- 6 files changed, 30 insertions(+), 30 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index c30756033c..8e8d24eb5d 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -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); diff --git a/Marlin/configuration_store.cpp b/Marlin/configuration_store.cpp index 09d7539668..707513e109 100644 --- a/Marlin/configuration_store.cpp +++ b/Marlin/configuration_store.cpp @@ -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) { diff --git a/Marlin/endstops.cpp b/Marlin/endstops.cpp index f51a11b8af..93fbd9a5a8 100644 --- a/Marlin/endstops.cpp +++ b/Marlin/endstops.cpp @@ -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) \ diff --git a/Marlin/macros.h b/Marlin/macros.h index ec9e55c0bb..bb006fe486 100644 --- a/Marlin/macros.h +++ b/Marlin/macros.h @@ -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 diff --git a/Marlin/planner.cpp b/Marlin/planner.cpp index fbc66e2e0a..0e9f4fccf3 100644 --- a/Marlin/planner.cpp +++ b/Marlin/planner.cpp @@ -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 diff --git a/Marlin/stepper.cpp b/Marlin/stepper.cpp index 03cf80ee5b..57bef81a85 100644 --- a/Marlin/stepper.cpp +++ b/Marlin/stepper.cpp @@ -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) \ - 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); \ - } \ - 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); \ - } \ - } \ - else { \ - AXIS##_STEP_WRITE(v); \ - AXIS##2_STEP_WRITE(v); \ + #define DUAL_ENDSTOP_APPLY_STEP(A,V) \ + if (performing_homing) { \ + 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, 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 { \ + 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