diff --git a/Marlin/src/Marlin.h b/Marlin/src/Marlin.h index 8a8fb644d0..cda7d0a7b4 100644 --- a/Marlin/src/Marlin.h +++ b/Marlin/src/Marlin.h @@ -156,8 +156,6 @@ void manage_inactivity(const bool ignore_stepper_queue=false); /** * The axis order in all axis related arrays is X, Y, Z, E */ -#define _AXIS(AXIS) AXIS ##_AXIS - void enable_all_steppers(); void disable_e_stepper(const uint8_t e); void disable_e_steppers(); diff --git a/Marlin/src/core/macros.h b/Marlin/src/core/macros.h index 23364a434d..96439b0902 100644 --- a/Marlin/src/core/macros.h +++ b/Marlin/src/core/macros.h @@ -29,6 +29,8 @@ #define ABC 3 #define XYZ 3 +#define _AXIS(A) (A##_AXIS) + #define _XMIN_ 100 #define _YMIN_ 200 #define _ZMIN_ 300 diff --git a/Marlin/src/feature/I2CPositionEncoder.cpp b/Marlin/src/feature/I2CPositionEncoder.cpp index 6a088d6760..32a598810c 100644 --- a/Marlin/src/feature/I2CPositionEncoder.cpp +++ b/Marlin/src/feature/I2CPositionEncoder.cpp @@ -293,7 +293,7 @@ int32_t I2CPositionEncoder::get_axis_error_steps(const bool report) { error = (encoderCountInStepperTicksScaled - target); //suppress discontinuities (might be caused by bad I2C readings...?) - bool suppressOutput = (ABS(error - errorPrev) > 100); + const bool suppressOutput = (ABS(error - errorPrev) > 100); if (report) { SERIAL_ECHO(axis_codes[encoderAxis]); diff --git a/Marlin/src/feature/bedlevel/abl/abl.cpp b/Marlin/src/feature/bedlevel/abl/abl.cpp index 28dcb5e512..bbc95d80eb 100644 --- a/Marlin/src/feature/bedlevel/abl/abl.cpp +++ b/Marlin/src/feature/bedlevel/abl/abl.cpp @@ -362,7 +362,7 @@ float bilinear_z_offset(const float raw[XYZ]) { #if IS_CARTESIAN && DISABLED(SEGMENT_LEVELED_MOVES) - #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, diff --git a/Marlin/src/gcode/feature/trinamic/M911-M915.cpp b/Marlin/src/gcode/feature/trinamic/M911-M915.cpp index fe44d156f9..b9899c8a51 100644 --- a/Marlin/src/gcode/feature/trinamic/M911-M915.cpp +++ b/Marlin/src/gcode/feature/trinamic/M911-M915.cpp @@ -151,8 +151,8 @@ void GcodeSuite::M912() { */ #if ENABLED(HYBRID_THRESHOLD) void GcodeSuite::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) diff --git a/Marlin/src/module/configuration_store.cpp b/Marlin/src/module/configuration_store.cpp index a250e2806b..4c7aa664f9 100644 --- a/Marlin/src/module/configuration_store.cpp +++ b/Marlin/src/module/configuration_store.cpp @@ -77,7 +77,7 @@ #if HAS_TRINAMIC #include "stepper_indirection.h" #include "../feature/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(FWRETRACT) @@ -1329,7 +1329,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/src/module/motion.cpp b/Marlin/src/module/motion.cpp index ae413d2077..e62c659b3e 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -1247,7 +1247,7 @@ 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 diff --git a/Marlin/src/module/motion.h b/Marlin/src/module/motion.h index 2535f07c98..e06474654d 100644 --- a/Marlin/src/module/motion.h +++ b/Marlin/src/module/motion.h @@ -189,7 +189,7 @@ void clean_up_after_endstop_or_probe_move(); void set_axis_is_at_home(const AxisEnum axis); void homeaxis(const AxisEnum axis); -#define HOMEAXIS(LETTER) homeaxis(LETTER##_AXIS) +#define HOMEAXIS(A) homeaxis(_AXIS(A)) #if ENABLED(SENSORLESS_HOMING) void sensorless_homing_per_axis(const AxisEnum axis, const bool enable=true); diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index a087ab9517..a8da978c85 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -2212,11 +2212,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/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index 7af6b2c94d..c4b6ed8329 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -182,20 +182,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