From 82fcd5d625e54c583a5f4936036e1edb1a02684a Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 29 Apr 2022 15:21:15 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Base=20NUM=5FAXES=20on=20defined?= =?UTF-8?q?=20DRIVER=5FTYPEs=20(#24106)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration.h | 100 ++++----- Marlin/src/inc/Conditionals_LCD.h | 264 +++++++++++++++--------- Marlin/src/inc/Warnings.cpp | 4 + Marlin/src/libs/L64XX/L64XX_Marlin.cpp | 14 +- Marlin/src/module/motion.cpp | 18 +- Marlin/src/module/stepper.cpp | 20 +- Marlin/src/module/stepper/indirection.h | 168 +++++++-------- 7 files changed, 320 insertions(+), 268 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 5e58d5273237..04e1115728f4 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -150,20 +150,45 @@ //#define MACHINE_UUID "00000000-0000-0000-0000-000000000000" /** - * Define the number of coordinated axes. - * See https://github.com/DerAndere1/Marlin/wiki - * Each axis gets its own stepper control and endstop: + * Stepper Drivers + * + * These settings allow Marlin to tune stepper driver timing and enable advanced options for + * stepper drivers that support them. You may also override timing options in Configuration_adv.h. + * + * A4988 is assumed for unspecified drivers. * - * Steppers: *_STEP_PIN, *_ENABLE_PIN, *_DIR_PIN, *_ENABLE_ON - * Endstops: *_STOP_PIN, USE_*MIN_PLUG, USE_*MAX_PLUG - * Axes: *_MIN_POS, *_MAX_POS, INVERT_*_DIR - * Planner: DEFAULT_AXIS_STEPS_PER_UNIT, DEFAULT_MAX_FEEDRATE - * DEFAULT_MAX_ACCELERATION, AXIS_RELATIVE_MODES, - * MICROSTEP_MODES, MANUAL_FEEDRATE + * Use TMC2208/TMC2208_STANDALONE for TMC2225 drivers and TMC2209/TMC2209_STANDALONE for TMC2226 drivers. * - * :[3, 4, 5, 6, 7, 8, 9] + * Options: A4988, A5984, DRV8825, LV8729, L6470, L6474, POWERSTEP01, + * TB6560, TB6600, TMC2100, + * TMC2130, TMC2130_STANDALONE, TMC2160, TMC2160_STANDALONE, + * TMC2208, TMC2208_STANDALONE, TMC2209, TMC2209_STANDALONE, + * TMC26X, TMC26X_STANDALONE, TMC2660, TMC2660_STANDALONE, + * TMC5130, TMC5130_STANDALONE, TMC5160, TMC5160_STANDALONE + * :['A4988', 'A5984', 'DRV8825', 'LV8729', 'L6470', 'L6474', 'POWERSTEP01', 'TB6560', 'TB6600', 'TMC2100', 'TMC2130', 'TMC2130_STANDALONE', 'TMC2160', 'TMC2160_STANDALONE', 'TMC2208', 'TMC2208_STANDALONE', 'TMC2209', 'TMC2209_STANDALONE', 'TMC26X', 'TMC26X_STANDALONE', 'TMC2660', 'TMC2660_STANDALONE', 'TMC5130', 'TMC5130_STANDALONE', 'TMC5160', 'TMC5160_STANDALONE'] */ -//#define NUM_AXES 3 +#define X_DRIVER_TYPE A4988 +#define Y_DRIVER_TYPE A4988 +#define Z_DRIVER_TYPE A4988 +//#define X2_DRIVER_TYPE A4988 +//#define Y2_DRIVER_TYPE A4988 +//#define Z2_DRIVER_TYPE A4988 +//#define Z3_DRIVER_TYPE A4988 +//#define Z4_DRIVER_TYPE A4988 +//#define I_DRIVER_TYPE A4988 +//#define J_DRIVER_TYPE A4988 +//#define K_DRIVER_TYPE A4988 +//#define U_DRIVER_TYPE A4988 +//#define V_DRIVER_TYPE A4988 +//#define W_DRIVER_TYPE A4988 +#define E0_DRIVER_TYPE A4988 +//#define E1_DRIVER_TYPE A4988 +//#define E2_DRIVER_TYPE A4988 +//#define E3_DRIVER_TYPE A4988 +//#define E4_DRIVER_TYPE A4988 +//#define E5_DRIVER_TYPE A4988 +//#define E6_DRIVER_TYPE A4988 +//#define E7_DRIVER_TYPE A4988 /** * Additional Axis Settings @@ -182,27 +207,27 @@ * * Regardless of these settings the axes are internally named I, J, K, U, V, W. */ -#if NUM_AXES >= 4 +#ifdef I_DRIVER_TYPE #define AXIS4_NAME 'A' // :['A', 'B', 'C', 'U', 'V', 'W'] #define AXIS4_ROTATES #endif -#if NUM_AXES >= 5 +#ifdef J_DRIVER_TYPE #define AXIS5_NAME 'B' // :['B', 'C', 'U', 'V', 'W'] #define AXIS5_ROTATES #endif -#if NUM_AXES >= 6 +#ifdef K_DRIVER_TYPE #define AXIS6_NAME 'C' // :['C', 'U', 'V', 'W'] #define AXIS6_ROTATES #endif -#if NUM_AXES >= 7 +#ifdef U_DRIVER_TYPE #define AXIS7_NAME 'U' // :['U', 'V', 'W'] //#define AXIS7_ROTATES #endif -#if NUM_AXES >= 8 +#ifdef V_DRIVER_TYPE #define AXIS8_NAME 'V' // :['V', 'W'] //#define AXIS8_ROTATES #endif -#if NUM_AXES >= 9 +#ifdef W_DRIVER_TYPE #define AXIS9_NAME 'W' // :['W'] //#define AXIS9_ROTATES #endif @@ -941,47 +966,6 @@ #define W_MAX_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop. #define Z_MIN_PROBE_ENDSTOP_INVERTING false // Set to true to invert the logic of the probe. -/** - * Stepper Drivers - * - * These settings allow Marlin to tune stepper driver timing and enable advanced options for - * stepper drivers that support them. You may also override timing options in Configuration_adv.h. - * - * A4988 is assumed for unspecified drivers. - * - * Use TMC2208/TMC2208_STANDALONE for TMC2225 drivers and TMC2209/TMC2209_STANDALONE for TMC2226 drivers. - * - * Options: A4988, A5984, DRV8825, LV8729, L6470, L6474, POWERSTEP01, - * TB6560, TB6600, TMC2100, - * TMC2130, TMC2130_STANDALONE, TMC2160, TMC2160_STANDALONE, - * TMC2208, TMC2208_STANDALONE, TMC2209, TMC2209_STANDALONE, - * TMC26X, TMC26X_STANDALONE, TMC2660, TMC2660_STANDALONE, - * TMC5130, TMC5130_STANDALONE, TMC5160, TMC5160_STANDALONE - * :['A4988', 'A5984', 'DRV8825', 'LV8729', 'L6470', 'L6474', 'POWERSTEP01', 'TB6560', 'TB6600', 'TMC2100', 'TMC2130', 'TMC2130_STANDALONE', 'TMC2160', 'TMC2160_STANDALONE', 'TMC2208', 'TMC2208_STANDALONE', 'TMC2209', 'TMC2209_STANDALONE', 'TMC26X', 'TMC26X_STANDALONE', 'TMC2660', 'TMC2660_STANDALONE', 'TMC5130', 'TMC5130_STANDALONE', 'TMC5160', 'TMC5160_STANDALONE'] - */ -#define X_DRIVER_TYPE A4988 -#define Y_DRIVER_TYPE A4988 -#define Z_DRIVER_TYPE A4988 -//#define X2_DRIVER_TYPE A4988 -//#define Y2_DRIVER_TYPE A4988 -//#define Z2_DRIVER_TYPE A4988 -//#define Z3_DRIVER_TYPE A4988 -//#define Z4_DRIVER_TYPE A4988 -//#define I_DRIVER_TYPE A4988 -//#define J_DRIVER_TYPE A4988 -//#define K_DRIVER_TYPE A4988 -//#define U_DRIVER_TYPE A4988 -//#define V_DRIVER_TYPE A4988 -//#define W_DRIVER_TYPE A4988 -#define E0_DRIVER_TYPE A4988 -//#define E1_DRIVER_TYPE A4988 -//#define E2_DRIVER_TYPE A4988 -//#define E3_DRIVER_TYPE A4988 -//#define E4_DRIVER_TYPE A4988 -//#define E5_DRIVER_TYPE A4988 -//#define E6_DRIVER_TYPE A4988 -//#define E7_DRIVER_TYPE A4988 - // Enable this feature if all enabled endstop pins are interrupt-capable. // This will remove the need to poll the interrupt pins, saving many CPU cycles. //#define ENDSTOP_INTERRUPTS_FEATURE diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index 95647d100e25..2945bec4a563 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -679,8 +679,29 @@ * Number of Linear Axes (e.g., XYZIJKUVW) * All the logical axes except for the tool (E) axis */ -#ifndef NUM_AXES - #define NUM_AXES XYZ +#ifdef NUM_AXES + #undef NUM_AXES + #define NUM_AXES_WARNING 1 +#endif + +#ifdef W_DRIVER_TYPE + #define NUM_AXES 9 +#elif defined(V_DRIVER_TYPE) + #define NUM_AXES 8 +#elif defined(U_DRIVER_TYPE) + #define NUM_AXES 7 +#elif defined(K_DRIVER_TYPE) + #define NUM_AXES 6 +#elif defined(J_DRIVER_TYPE) + #define NUM_AXES 5 +#elif defined(I_DRIVER_TYPE) + #define NUM_AXES 4 +#elif defined(Z_DRIVER_TYPE) + #define NUM_AXES 3 +#elif defined(Y_DRIVER_TYPE) + #define NUM_AXES 2 +#else + #define NUM_AXES 1 #endif #if NUM_AXES >= XY #define HAS_Y_AXIS 1 @@ -707,6 +728,147 @@ #endif #endif +#if E_STEPPERS <= 0 + #undef E0_DRIVER_TYPE +#endif +#if E_STEPPERS <= 1 + #undef E1_DRIVER_TYPE +#endif +#if E_STEPPERS <= 2 + #undef E2_DRIVER_TYPE +#endif +#if E_STEPPERS <= 3 + #undef E3_DRIVER_TYPE +#endif +#if E_STEPPERS <= 4 + #undef E4_DRIVER_TYPE +#endif +#if E_STEPPERS <= 5 + #undef E5_DRIVER_TYPE +#endif +#if E_STEPPERS <= 6 + #undef E6_DRIVER_TYPE +#endif +#if E_STEPPERS <= 7 + #undef E7_DRIVER_TYPE +#endif + +#if !HAS_Y_AXIS + #undef ENDSTOPPULLUP_YMIN + #undef ENDSTOPPULLUP_YMAX + #undef Y_MIN_ENDSTOP_INVERTING + #undef Y_MAX_ENDSTOP_INVERTING + #undef Y2_DRIVER_TYPE + #undef Y_ENABLE_ON + #undef DISABLE_Y + #undef INVERT_Y_DIR + #undef Y_HOME_DIR + #undef Y_MIN_POS + #undef Y_MAX_POS + #undef MANUAL_Y_HOME_POS +#endif + +#if !HAS_Z_AXIS + #undef ENDSTOPPULLUP_ZMIN + #undef ENDSTOPPULLUP_ZMAX + #undef Z_MIN_ENDSTOP_INVERTING + #undef Z_MAX_ENDSTOP_INVERTING + #undef Z2_DRIVER_TYPE + #undef Z3_DRIVER_TYPE + #undef Z4_DRIVER_TYPE + #undef Z_ENABLE_ON + #undef DISABLE_Z + #undef INVERT_Z_DIR + #undef Z_HOME_DIR + #undef Z_MIN_POS + #undef Z_MAX_POS + #undef MANUAL_Z_HOME_POS +#endif + +#if !HAS_I_AXIS + #undef ENDSTOPPULLUP_IMIN + #undef ENDSTOPPULLUP_IMAX + #undef I_MIN_ENDSTOP_INVERTING + #undef I_MAX_ENDSTOP_INVERTING + #undef I_ENABLE_ON + #undef DISABLE_I + #undef INVERT_I_DIR + #undef I_HOME_DIR + #undef I_MIN_POS + #undef I_MAX_POS + #undef MANUAL_I_HOME_POS +#endif + +#if !HAS_J_AXIS + #undef ENDSTOPPULLUP_JMIN + #undef ENDSTOPPULLUP_JMAX + #undef J_MIN_ENDSTOP_INVERTING + #undef J_MAX_ENDSTOP_INVERTING + #undef J_ENABLE_ON + #undef DISABLE_J + #undef INVERT_J_DIR + #undef J_HOME_DIR + #undef J_MIN_POS + #undef J_MAX_POS + #undef MANUAL_J_HOME_POS +#endif + +#if !HAS_K_AXIS + #undef ENDSTOPPULLUP_KMIN + #undef ENDSTOPPULLUP_KMAX + #undef K_MIN_ENDSTOP_INVERTING + #undef K_MAX_ENDSTOP_INVERTING + #undef K_ENABLE_ON + #undef DISABLE_K + #undef INVERT_K_DIR + #undef K_HOME_DIR + #undef K_MIN_POS + #undef K_MAX_POS + #undef MANUAL_K_HOME_POS +#endif + +#if !HAS_U_AXIS + #undef ENDSTOPPULLUP_UMIN + #undef ENDSTOPPULLUP_UMAX + #undef U_MIN_ENDSTOP_INVERTING + #undef U_MAX_ENDSTOP_INVERTING + #undef U_ENABLE_ON + #undef DISABLE_U + #undef INVERT_U_DIR + #undef U_HOME_DIR + #undef U_MIN_POS + #undef U_MAX_POS + #undef MANUAL_U_HOME_POS +#endif + +#if !HAS_V_AXIS + #undef ENDSTOPPULLUP_VMIN + #undef ENDSTOPPULLUP_VMAX + #undef V_MIN_ENDSTOP_INVERTING + #undef V_MAX_ENDSTOP_INVERTING + #undef V_ENABLE_ON + #undef DISABLE_V + #undef INVERT_V_DIR + #undef V_HOME_DIR + #undef V_MIN_POS + #undef V_MAX_POS + #undef MANUAL_V_HOME_POS +#endif + +#if !HAS_W_AXIS + #undef ENDSTOPPULLUP_WMIN + #undef ENDSTOPPULLUP_WMAX + #undef W_MIN_ENDSTOP_INVERTING + #undef W_MAX_ENDSTOP_INVERTING + #undef W_ENABLE_ON + #undef DISABLE_W + #undef INVERT_W_DIR + #undef W_HOME_DIR + #undef W_MIN_POS + #undef W_MAX_POS + #undef MANUAL_W_HOME_POS +#endif + /** * Number of Primary Linear Axes (e.g., XYZ) * X, XY, or XYZ axes. Excluding duplicate axes (X2, Y2. Z2. Z3, Z4) @@ -1214,104 +1376,6 @@ #define HAS_ETHERNET 1 #endif -// Fallback Stepper Driver types that don't depend on Configuration_adv.h -#ifndef X_DRIVER_TYPE - #define X_DRIVER_TYPE A4988 -#endif -#ifndef X2_DRIVER_TYPE - #define X2_DRIVER_TYPE A4988 -#endif -#ifndef Y_DRIVER_TYPE - #define Y_DRIVER_TYPE A4988 -#endif -#ifndef Y2_DRIVER_TYPE - #define Y2_DRIVER_TYPE A4988 -#endif -#ifndef Z_DRIVER_TYPE - #define Z_DRIVER_TYPE A4988 -#endif -#ifndef Z2_DRIVER_TYPE - #define Z2_DRIVER_TYPE A4988 -#endif -#ifndef Z3_DRIVER_TYPE - #define Z3_DRIVER_TYPE A4988 -#endif -#ifndef Z4_DRIVER_TYPE - #define Z4_DRIVER_TYPE A4988 -#endif -#if E_STEPPERS <= 0 - #undef E0_DRIVER_TYPE -#elif !defined(E0_DRIVER_TYPE) - #define E0_DRIVER_TYPE A4988 -#endif -#if E_STEPPERS <= 1 - #undef E1_DRIVER_TYPE -#elif !defined(E1_DRIVER_TYPE) - #define E1_DRIVER_TYPE A4988 -#endif -#if E_STEPPERS <= 2 - #undef E2_DRIVER_TYPE -#elif !defined(E2_DRIVER_TYPE) - #define E2_DRIVER_TYPE A4988 -#endif -#if E_STEPPERS <= 3 - #undef E3_DRIVER_TYPE -#elif !defined(E3_DRIVER_TYPE) - #define E3_DRIVER_TYPE A4988 -#endif -#if E_STEPPERS <= 4 - #undef E4_DRIVER_TYPE -#elif !defined(E4_DRIVER_TYPE) - #define E4_DRIVER_TYPE A4988 -#endif -#if E_STEPPERS <= 5 - #undef E5_DRIVER_TYPE -#elif !defined(E5_DRIVER_TYPE) - #define E5_DRIVER_TYPE A4988 -#endif -#if E_STEPPERS <= 6 - #undef E6_DRIVER_TYPE -#elif !defined(E6_DRIVER_TYPE) - #define E6_DRIVER_TYPE A4988 -#endif -#if E_STEPPERS <= 7 - #undef E7_DRIVER_TYPE -#elif !defined(E7_DRIVER_TYPE) - #define E7_DRIVER_TYPE A4988 -#endif - -// Fallback axis inverting -#ifndef INVERT_X_DIR - #define INVERT_X_DIR false -#endif -#if HAS_Y_AXIS && !defined(INVERT_Y_DIR) - #define INVERT_Y_DIR false -#endif -#if HAS_Z_AXIS && !defined(INVERT_Z_DIR) - #define INVERT_Z_DIR false -#endif -#if HAS_I_AXIS && !defined(INVERT_I_DIR) - #define INVERT_I_DIR false -#endif -#if HAS_J_AXIS && !defined(INVERT_J_DIR) - #define INVERT_J_DIR false -#endif -#if HAS_K_AXIS && !defined(INVERT_K_DIR) - #define INVERT_K_DIR false -#endif -#if HAS_U_AXIS && !defined(INVERT_U_DIR) - #define INVERT_U_DIR false -#endif -#if HAS_V_AXIS && !defined(INVERT_V_DIR) - #define INVERT_V_DIR false -#endif -#if HAS_W_AXIS && !defined(INVERT_W_DIR) - #define INVERT_W_DIR false -#endif -#if HAS_EXTRUDERS && !defined(INVERT_E_DIR) - #define INVERT_E_DIR false -#endif - /** * This setting is also used by M109 when trying to calculate * a ballpark safe margin to prevent wait-forever situation. diff --git a/Marlin/src/inc/Warnings.cpp b/Marlin/src/inc/Warnings.cpp index 96f8dc7d54b2..6023247f9496 100644 --- a/Marlin/src/inc/Warnings.cpp +++ b/Marlin/src/inc/Warnings.cpp @@ -35,6 +35,10 @@ #warning "WARNING! Disable MARLIN_DEV_MODE for the final build!" #endif +#if NUM_AXES_WARNING + #warning "Note: NUM_AXES is now based on the *_DRIVER_TYPE settings so you can remove NUM_AXES from Configuration.h." +#endif + // Safety Features #if DISABLED(USE_WATCHDOG) #warning "Safety Alert! Enable USE_WATCHDOG for the final build!" diff --git a/Marlin/src/libs/L64XX/L64XX_Marlin.cpp b/Marlin/src/libs/L64XX/L64XX_Marlin.cpp index 30c837432440..8a20b8f58c8c 100644 --- a/Marlin/src/libs/L64XX/L64XX_Marlin.cpp +++ b/Marlin/src/libs/L64XX/L64XX_Marlin.cpp @@ -66,14 +66,14 @@ void echo_yes_no(const bool yes) { DEBUG_ECHOPGM_P(yes ? PSTR(" YES") : PSTR(" N uint8_t L64XX_Marlin::dir_commands[MAX_L64XX]; // array to hold direction command for each driver -#define _EN_ITEM(N) , INVERT_E##N##_DIR +#define _EN_ITEM(N) , ENABLED(INVERT_E##N##_DIR) const uint8_t L64XX_Marlin::index_to_dir[MAX_L64XX] = { - NUM_AXIS_LIST(INVERT_X_DIR, INVERT_Y_DIR, INVERT_Z_DIR, INVERT_I_DIR, INVERT_J_DIR, INVERT_K_DIR) - , (INVERT_X_DIR) ^ BOTH(X_DUAL_STEPPER_DRIVERS, INVERT_X2_VS_X_DIR) // X2 - , (INVERT_Y_DIR) ^ BOTH(Y_DUAL_STEPPER_DRIVERS, INVERT_Y2_VS_Y_DIR) // Y2 - , (INVERT_Z_DIR) ^ ENABLED(INVERT_Z2_VS_Z_DIR) // Z2 - , (INVERT_Z_DIR) ^ ENABLED(INVERT_Z3_VS_Z_DIR) // Z3 - , (INVERT_Z_DIR) ^ ENABLED(INVERT_Z4_VS_Z_DIR) // Z4 + NUM_AXIS_LIST(ENABLED(INVERT_X_DIR), ENABLED(INVERT_Y_DIR), ENABLED(INVERT_Z_DIR), ENABLED(INVERT_I_DIR), ENABLED(INVERT_J_DIR), ENABLED(INVERT_K_DIR), ENABLED(INVERT_U_DIR), ENABLED(INVERT_V_DIR), ENABLED(INVERT_W_DIR)) + , ENABLED(INVERT_X_DIR) ^ BOTH(X_DUAL_STEPPER_DRIVERS, INVERT_X2_VS_X_DIR) // X2 + , ENABLED(INVERT_Y_DIR) ^ BOTH(Y_DUAL_STEPPER_DRIVERS, INVERT_Y2_VS_Y_DIR) // Y2 + , ENABLED(INVERT_Z_DIR) ^ ENABLED(INVERT_Z2_VS_Z_DIR) // Z2 + , ENABLED(INVERT_Z_DIR) ^ ENABLED(INVERT_Z3_VS_Z_DIR) // Z3 + , ENABLED(INVERT_Z_DIR) ^ ENABLED(INVERT_Z4_VS_Z_DIR) // Z4 REPEAT(E_STEPPERS, _EN_ITEM) }; #undef _EN_ITEM diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index eab89f93ed6c..12b8bc312db1 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -1758,7 +1758,7 @@ void prepare_line_to_destination() { phasePerUStep = PHASE_PER_MICROSTEP(X); phaseCurrent = stepperX.get_microstep_counter(); effectorBackoutDir = -X_HOME_DIR; - stepperBackoutDir = INVERT_X_DIR ? effectorBackoutDir : -effectorBackoutDir; + stepperBackoutDir = IF_DISABLED(INVERT_X_DIR, -)effectorBackoutDir; break; #endif #ifdef Y_MICROSTEPS @@ -1766,7 +1766,7 @@ void prepare_line_to_destination() { phasePerUStep = PHASE_PER_MICROSTEP(Y); phaseCurrent = stepperY.get_microstep_counter(); effectorBackoutDir = -Y_HOME_DIR; - stepperBackoutDir = INVERT_Y_DIR ? effectorBackoutDir : -effectorBackoutDir; + stepperBackoutDir = IF_DISABLED(INVERT_Y_DIR, -)effectorBackoutDir; break; #endif #ifdef Z_MICROSTEPS @@ -1774,7 +1774,7 @@ void prepare_line_to_destination() { phasePerUStep = PHASE_PER_MICROSTEP(Z); phaseCurrent = stepperZ.get_microstep_counter(); effectorBackoutDir = -Z_HOME_DIR; - stepperBackoutDir = INVERT_Z_DIR ? effectorBackoutDir : -effectorBackoutDir; + stepperBackoutDir = IF_DISABLED(INVERT_Z_DIR, -)effectorBackoutDir; break; #endif #ifdef I_MICROSTEPS @@ -1782,7 +1782,7 @@ void prepare_line_to_destination() { phasePerUStep = PHASE_PER_MICROSTEP(I); phaseCurrent = stepperI.get_microstep_counter(); effectorBackoutDir = -I_HOME_DIR; - stepperBackoutDir = INVERT_I_DIR ? effectorBackoutDir : -effectorBackoutDir; + stepperBackoutDir = IF_DISABLED(INVERT_I_DIR, -)effectorBackoutDir; break; #endif #ifdef J_MICROSTEPS @@ -1790,7 +1790,7 @@ void prepare_line_to_destination() { phasePerUStep = PHASE_PER_MICROSTEP(J); phaseCurrent = stepperJ.get_microstep_counter(); effectorBackoutDir = -J_HOME_DIR; - stepperBackoutDir = INVERT_J_DIR ? effectorBackoutDir : -effectorBackoutDir; + stepperBackoutDir = IF_DISABLED(INVERT_J_DIR, -)effectorBackoutDir; break; #endif #ifdef K_MICROSTEPS @@ -1798,7 +1798,7 @@ void prepare_line_to_destination() { phasePerUStep = PHASE_PER_MICROSTEP(K); phaseCurrent = stepperK.get_microstep_counter(); effectorBackoutDir = -K_HOME_DIR; - stepperBackoutDir = INVERT_K_DIR ? effectorBackoutDir : -effectorBackoutDir; + stepperBackoutDir = IF_DISABLED(INVERT_K_DIR, -)effectorBackoutDir; break; #endif #ifdef U_MICROSTEPS @@ -1806,7 +1806,7 @@ void prepare_line_to_destination() { phasePerUStep = PHASE_PER_MICROSTEP(U); phaseCurrent = stepperU.get_microstep_counter(); effectorBackoutDir = -U_HOME_DIR; - stepperBackoutDir = INVERT_U_DIR ? effectorBackoutDir : -effectorBackoutDir; + stepperBackoutDir = IF_DISABLED(INVERT_U_DIR, -)effectorBackoutDir; break; #endif #ifdef V_MICROSTEPS @@ -1814,7 +1814,7 @@ void prepare_line_to_destination() { phasePerUStep = PHASE_PER_MICROSTEP(V); phaseCurrent = stepperV.get_microstep_counter(); effectorBackoutDir = -V_HOME_DIR; - stepperBackoutDir = INVERT_V_DIR ? effectorBackoutDir : -effectorBackoutDir; + stepperBackoutDir = IF_DISABLED(INVERT_V_DIR, -)effectorBackoutDir; break; #endif #ifdef W_MICROSTEPS @@ -1822,7 +1822,7 @@ void prepare_line_to_destination() { phasePerUStep = PHASE_PER_MICROSTEP(W); phaseCurrent = stepperW.get_microstep_counter(); effectorBackoutDir = -W_HOME_DIR; - stepperBackoutDir = INVERT_W_DIR ? effectorBackoutDir : -effectorBackoutDir; + stepperBackoutDir = IF_DISABLED(INVERT_W_DIR, -)effectorBackoutDir; break; #endif default: return; diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index 1140a6eb1e38..85b42f61bbbb 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -3058,7 +3058,7 @@ void Stepper::report_positions() { #define _ENABLE_AXIS(A) enable_axis(_AXIS(A)) #define _READ_DIR(AXIS) AXIS ##_DIR_READ() - #define _INVERT_DIR(AXIS) INVERT_## AXIS ##_DIR + #define _INVERT_DIR(AXIS) ENABLED(INVERT_## AXIS ##_DIR) #define _APPLY_DIR(AXIS, INVERT) AXIS ##_APPLY_DIR(INVERT, true) #if MINIMUM_STEPPER_PULSE @@ -3203,30 +3203,30 @@ void Stepper::report_positions() { U_DIR_READ(), V_DIR_READ(), W_DIR_READ() ); - X_DIR_WRITE(INVERT_X_DIR ^ z_direction); + X_DIR_WRITE(ENABLED(INVERT_X_DIR) ^ z_direction); #ifdef Y_DIR_WRITE - Y_DIR_WRITE(INVERT_Y_DIR ^ z_direction); + Y_DIR_WRITE(ENABLED(INVERT_Y_DIR) ^ z_direction); #endif #ifdef Z_DIR_WRITE - Z_DIR_WRITE(INVERT_Z_DIR ^ z_direction); + Z_DIR_WRITE(ENABLED(INVERT_Z_DIR) ^ z_direction); #endif #ifdef I_DIR_WRITE - I_DIR_WRITE(INVERT_I_DIR ^ z_direction); + I_DIR_WRITE(ENABLED(INVERT_I_DIR) ^ z_direction); #endif #ifdef J_DIR_WRITE - J_DIR_WRITE(INVERT_J_DIR ^ z_direction); + J_DIR_WRITE(ENABLED(INVERT_J_DIR) ^ z_direction); #endif #ifdef K_DIR_WRITE - K_DIR_WRITE(INVERT_K_DIR ^ z_direction); + K_DIR_WRITE(ENABLED(INVERT_K_DIR) ^ z_direction); #endif #ifdef U_DIR_WRITE - U_DIR_WRITE(INVERT_U_DIR ^ z_direction); + U_DIR_WRITE(ENABLED(INVERT_U_DIR) ^ z_direction); #endif #ifdef V_DIR_WRITE - V_DIR_WRITE(INVERT_V_DIR ^ z_direction); + V_DIR_WRITE(ENABLED(INVERT_V_DIR) ^ z_direction); #endif #ifdef W_DIR_WRITE - W_DIR_WRITE(INVERT_W_DIR ^ z_direction); + W_DIR_WRITE(ENABLED(INVERT_W_DIR) ^ z_direction); #endif DIR_WAIT_AFTER(); diff --git a/Marlin/src/module/stepper/indirection.h b/Marlin/src/module/stepper/indirection.h index 879185ca14ef..687a0f289628 100644 --- a/Marlin/src/module/stepper/indirection.h +++ b/Marlin/src/module/stepper/indirection.h @@ -462,91 +462,91 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #if EXTRUDERS > 7 #define E_STEP_WRITE(E,V) do{ if (E < 2) { E0_STEP_WRITE(V); } else if (E < 4) { E1_STEP_WRITE(V); } else if (E < 6) { E2_STEP_WRITE(V); } else { E3_STEP_WRITE(V); } }while(0) #define NORM_E_DIR(E) do{ switch (E) { \ - case 0: E0_DIR_WRITE(!INVERT_E0_DIR); break; case 1: E0_DIR_WRITE( INVERT_E0_DIR); break; \ - case 2: E1_DIR_WRITE(!INVERT_E1_DIR); break; case 3: E1_DIR_WRITE( INVERT_E1_DIR); break; \ - case 4: E2_DIR_WRITE(!INVERT_E2_DIR); break; case 5: E2_DIR_WRITE( INVERT_E2_DIR); break; \ - case 6: E3_DIR_WRITE( INVERT_E3_DIR); break; case 7: E3_DIR_WRITE( INVERT_E3_DIR); break; \ + case 0: E0_DIR_WRITE(DISABLED(INVERT_E0_DIR)); break; case 1: E0_DIR_WRITE( ENABLED(INVERT_E0_DIR)); break; \ + case 2: E1_DIR_WRITE(DISABLED(INVERT_E1_DIR)); break; case 3: E1_DIR_WRITE( ENABLED(INVERT_E1_DIR)); break; \ + case 4: E2_DIR_WRITE(DISABLED(INVERT_E2_DIR)); break; case 5: E2_DIR_WRITE( ENABLED(INVERT_E2_DIR)); break; \ + case 6: E3_DIR_WRITE( ENABLED(INVERT_E3_DIR)); break; case 7: E3_DIR_WRITE( ENABLED(INVERT_E3_DIR)); break; \ } }while(0) #define REV_E_DIR(E) do{ switch (E) { \ - case 0: E0_DIR_WRITE( INVERT_E0_DIR); break; case 1: E0_DIR_WRITE(!INVERT_E0_DIR); break; \ - case 2: E1_DIR_WRITE( INVERT_E1_DIR); break; case 3: E1_DIR_WRITE(!INVERT_E1_DIR); break; \ - case 4: E2_DIR_WRITE( INVERT_E2_DIR); break; case 5: E2_DIR_WRITE(!INVERT_E2_DIR); break; \ - case 6: E3_DIR_WRITE(!INVERT_E3_DIR); break; case 7: E3_DIR_WRITE(!INVERT_E3_DIR); break; \ + case 0: E0_DIR_WRITE( ENABLED(INVERT_E0_DIR)); break; case 1: E0_DIR_WRITE(DISABLED(INVERT_E0_DIR)); break; \ + case 2: E1_DIR_WRITE( ENABLED(INVERT_E1_DIR)); break; case 3: E1_DIR_WRITE(DISABLED(INVERT_E1_DIR)); break; \ + case 4: E2_DIR_WRITE( ENABLED(INVERT_E2_DIR)); break; case 5: E2_DIR_WRITE(DISABLED(INVERT_E2_DIR)); break; \ + case 6: E3_DIR_WRITE(DISABLED(INVERT_E3_DIR)); break; case 7: E3_DIR_WRITE(DISABLED(INVERT_E3_DIR)); break; \ } }while(0) #elif EXTRUDERS > 6 #define E_STEP_WRITE(E,V) do{ if (E < 2) { E0_STEP_WRITE(V); } else if (E < 4) { E1_STEP_WRITE(V); } else if (E < 6) { E2_STEP_WRITE(V); } else { E3_STEP_WRITE(V); } }while(0) #define NORM_E_DIR(E) do{ switch (E) { \ - case 0: E0_DIR_WRITE(!INVERT_E0_DIR); break; case 1: E0_DIR_WRITE( INVERT_E0_DIR); break; \ - case 2: E1_DIR_WRITE(!INVERT_E1_DIR); break; case 3: E1_DIR_WRITE( INVERT_E1_DIR); break; \ - case 4: E2_DIR_WRITE(!INVERT_E2_DIR); break; case 5: E2_DIR_WRITE( INVERT_E2_DIR); break; \ - case 6: E3_DIR_WRITE( INVERT_E3_DIR); break; \ + case 0: E0_DIR_WRITE(DISABLED(INVERT_E0_DIR)); break; case 1: E0_DIR_WRITE( ENABLED(INVERT_E0_DIR)); break; \ + case 2: E1_DIR_WRITE(DISABLED(INVERT_E1_DIR)); break; case 3: E1_DIR_WRITE( ENABLED(INVERT_E1_DIR)); break; \ + case 4: E2_DIR_WRITE(DISABLED(INVERT_E2_DIR)); break; case 5: E2_DIR_WRITE( ENABLED(INVERT_E2_DIR)); break; \ + case 6: E3_DIR_WRITE( ENABLED(INVERT_E3_DIR)); break; \ } }while(0) #define REV_E_DIR(E) do{ switch (E) { \ - case 0: E0_DIR_WRITE( INVERT_E0_DIR); break; case 1: E0_DIR_WRITE(!INVERT_E0_DIR); break; \ - case 2: E1_DIR_WRITE( INVERT_E1_DIR); break; case 3: E1_DIR_WRITE(!INVERT_E1_DIR); break; \ - case 4: E2_DIR_WRITE( INVERT_E2_DIR); break; case 5: E2_DIR_WRITE(!INVERT_E2_DIR); break; \ - case 6: E3_DIR_WRITE(!INVERT_E3_DIR); } }while(0) + case 0: E0_DIR_WRITE( ENABLED(INVERT_E0_DIR)); break; case 1: E0_DIR_WRITE(DISABLED(INVERT_E0_DIR)); break; \ + case 2: E1_DIR_WRITE( ENABLED(INVERT_E1_DIR)); break; case 3: E1_DIR_WRITE(DISABLED(INVERT_E1_DIR)); break; \ + case 4: E2_DIR_WRITE( ENABLED(INVERT_E2_DIR)); break; case 5: E2_DIR_WRITE(DISABLED(INVERT_E2_DIR)); break; \ + case 6: E3_DIR_WRITE(DISABLED(INVERT_E3_DIR)); } }while(0) #elif EXTRUDERS > 5 #define E_STEP_WRITE(E,V) do{ if (E < 2) { E0_STEP_WRITE(V); } else if (E < 4) { E1_STEP_WRITE(V); } else { E2_STEP_WRITE(V); } }while(0) #define NORM_E_DIR(E) do{ switch (E) { \ - case 0: E0_DIR_WRITE(!INVERT_E0_DIR); break; case 1: E0_DIR_WRITE( INVERT_E0_DIR); break; \ - case 2: E1_DIR_WRITE(!INVERT_E1_DIR); break; case 3: E1_DIR_WRITE( INVERT_E1_DIR); break; \ - case 4: E2_DIR_WRITE(!INVERT_E2_DIR); break; case 5: E2_DIR_WRITE( INVERT_E2_DIR); break; \ + case 0: E0_DIR_WRITE(DISABLED(INVERT_E0_DIR)); break; case 1: E0_DIR_WRITE( ENABLED(INVERT_E0_DIR)); break; \ + case 2: E1_DIR_WRITE(DISABLED(INVERT_E1_DIR)); break; case 3: E1_DIR_WRITE( ENABLED(INVERT_E1_DIR)); break; \ + case 4: E2_DIR_WRITE(DISABLED(INVERT_E2_DIR)); break; case 5: E2_DIR_WRITE( ENABLED(INVERT_E2_DIR)); break; \ } }while(0) #define REV_E_DIR(E) do{ switch (E) { \ - case 0: E0_DIR_WRITE( INVERT_E0_DIR); break; case 1: E0_DIR_WRITE(!INVERT_E0_DIR); break; \ - case 2: E1_DIR_WRITE( INVERT_E1_DIR); break; case 3: E1_DIR_WRITE(!INVERT_E1_DIR); break; \ - case 4: E2_DIR_WRITE( INVERT_E2_DIR); break; case 5: E2_DIR_WRITE(!INVERT_E2_DIR); break; \ + case 0: E0_DIR_WRITE( ENABLED(INVERT_E0_DIR)); break; case 1: E0_DIR_WRITE(DISABLED(INVERT_E0_DIR)); break; \ + case 2: E1_DIR_WRITE( ENABLED(INVERT_E1_DIR)); break; case 3: E1_DIR_WRITE(DISABLED(INVERT_E1_DIR)); break; \ + case 4: E2_DIR_WRITE( ENABLED(INVERT_E2_DIR)); break; case 5: E2_DIR_WRITE(DISABLED(INVERT_E2_DIR)); break; \ } }while(0) #elif EXTRUDERS > 4 #define E_STEP_WRITE(E,V) do{ if (E < 2) { E0_STEP_WRITE(V); } else if (E < 4) { E1_STEP_WRITE(V); } else { E2_STEP_WRITE(V); } }while(0) #define NORM_E_DIR(E) do{ switch (E) { \ - case 0: E0_DIR_WRITE(!INVERT_E0_DIR); break; case 1: E0_DIR_WRITE( INVERT_E0_DIR); break; \ - case 2: E1_DIR_WRITE(!INVERT_E1_DIR); break; case 3: E1_DIR_WRITE( INVERT_E1_DIR); break; \ - case 4: E2_DIR_WRITE(!INVERT_E2_DIR); break; \ + case 0: E0_DIR_WRITE(DISABLED(INVERT_E0_DIR)); break; case 1: E0_DIR_WRITE( ENABLED(INVERT_E0_DIR)); break; \ + case 2: E1_DIR_WRITE(DISABLED(INVERT_E1_DIR)); break; case 3: E1_DIR_WRITE( ENABLED(INVERT_E1_DIR)); break; \ + case 4: E2_DIR_WRITE(DISABLED(INVERT_E2_DIR)); break; \ } }while(0) #define REV_E_DIR(E) do{ switch (E) { \ - case 0: E0_DIR_WRITE( INVERT_E0_DIR); break; case 1: E0_DIR_WRITE(!INVERT_E0_DIR); break; \ - case 2: E1_DIR_WRITE( INVERT_E1_DIR); break; case 3: E1_DIR_WRITE(!INVERT_E1_DIR); break; \ - case 4: E2_DIR_WRITE( INVERT_E2_DIR); break; \ + case 0: E0_DIR_WRITE( ENABLED(INVERT_E0_DIR)); break; case 1: E0_DIR_WRITE(DISABLED(INVERT_E0_DIR)); break; \ + case 2: E1_DIR_WRITE( ENABLED(INVERT_E1_DIR)); break; case 3: E1_DIR_WRITE(DISABLED(INVERT_E1_DIR)); break; \ + case 4: E2_DIR_WRITE( ENABLED(INVERT_E2_DIR)); break; \ } }while(0) #elif EXTRUDERS > 3 #define E_STEP_WRITE(E,V) do{ if (E < 2) { E0_STEP_WRITE(V); } else { E1_STEP_WRITE(V); } }while(0) #define NORM_E_DIR(E) do{ switch (E) { \ - case 0: E0_DIR_WRITE(!INVERT_E0_DIR); break; case 1: E0_DIR_WRITE( INVERT_E0_DIR); break; \ - case 2: E1_DIR_WRITE(!INVERT_E1_DIR); break; case 3: E1_DIR_WRITE( INVERT_E1_DIR); break; \ + case 0: E0_DIR_WRITE(DISABLED(INVERT_E0_DIR)); break; case 1: E0_DIR_WRITE( ENABLED(INVERT_E0_DIR)); break; \ + case 2: E1_DIR_WRITE(DISABLED(INVERT_E1_DIR)); break; case 3: E1_DIR_WRITE( ENABLED(INVERT_E1_DIR)); break; \ } }while(0) #define REV_E_DIR(E) do{ switch (E) { \ - case 0: E0_DIR_WRITE( INVERT_E0_DIR); break; case 1: E0_DIR_WRITE(!INVERT_E0_DIR); break; \ - case 2: E1_DIR_WRITE( INVERT_E1_DIR); break; case 3: E1_DIR_WRITE(!INVERT_E1_DIR); break; \ + case 0: E0_DIR_WRITE( ENABLED(INVERT_E0_DIR)); break; case 1: E0_DIR_WRITE(DISABLED(INVERT_E0_DIR)); break; \ + case 2: E1_DIR_WRITE( ENABLED(INVERT_E1_DIR)); break; case 3: E1_DIR_WRITE(DISABLED(INVERT_E1_DIR)); break; \ } }while(0) #elif EXTRUDERS > 2 #define E_STEP_WRITE(E,V) do{ if (E < 2) { E0_STEP_WRITE(V); } else { E1_STEP_WRITE(V); } }while(0) #define NORM_E_DIR(E) do{ switch (E) { \ - case 0: E0_DIR_WRITE(!INVERT_E0_DIR); break; case 1: E0_DIR_WRITE( INVERT_E0_DIR); break; \ - case 2: E1_DIR_WRITE(!INVERT_E1_DIR); break; \ + case 0: E0_DIR_WRITE(DISABLED(INVERT_E0_DIR)); break; case 1: E0_DIR_WRITE( ENABLED(INVERT_E0_DIR)); break; \ + case 2: E1_DIR_WRITE(DISABLED(INVERT_E1_DIR)); break; \ } }while(0) #define REV_E_DIR(E) do{ switch (E) { \ - case 0: E0_DIR_WRITE( INVERT_E0_DIR); break; case 1: E0_DIR_WRITE(!INVERT_E0_DIR); break; \ - case 2: E1_DIR_WRITE( INVERT_E1_DIR); break; \ + case 0: E0_DIR_WRITE( ENABLED(INVERT_E0_DIR)); break; case 1: E0_DIR_WRITE(DISABLED(INVERT_E0_DIR)); break; \ + case 2: E1_DIR_WRITE( ENABLED(INVERT_E1_DIR)); break; \ } }while(0) #else #define E_STEP_WRITE(E,V) E0_STEP_WRITE(V) - #define NORM_E_DIR(E) do{ E0_DIR_WRITE(E ? INVERT_E0_DIR : !INVERT_E0_DIR); }while(0) - #define REV_E_DIR(E) do{ E0_DIR_WRITE(E ? !INVERT_E0_DIR : INVERT_E0_DIR); }while(0) + #define NORM_E_DIR(E) do{ E0_DIR_WRITE(E ? ENABLED(INVERT_E0_DIR) : DISABLED(INVERT_E0_DIR)); }while(0) + #define REV_E_DIR(E) do{ E0_DIR_WRITE(E ? DISABLED(INVERT_E0_DIR) : ENABLED(INVERT_E0_DIR)); }while(0) #endif #elif HAS_PRUSA_MMU2 // One multiplexed stepper driver #define E_STEP_WRITE(E,V) E0_STEP_WRITE(V) - #define NORM_E_DIR(E) E0_DIR_WRITE(!INVERT_E0_DIR) - #define REV_E_DIR(E) E0_DIR_WRITE( INVERT_E0_DIR) + #define NORM_E_DIR(E) E0_DIR_WRITE(DISABLED(INVERT_E0_DIR)) + #define REV_E_DIR(E) E0_DIR_WRITE( ENABLED(INVERT_E0_DIR)) #elif HAS_PRUSA_MMU1 // One multiplexed stepper driver, reversed on odd index #define E_STEP_WRITE(E,V) E0_STEP_WRITE(V) - #define NORM_E_DIR(E) do{ E0_DIR_WRITE(TEST(E, 0) ? !INVERT_E0_DIR: INVERT_E0_DIR); }while(0) - #define REV_E_DIR(E) do{ E0_DIR_WRITE(TEST(E, 0) ? INVERT_E0_DIR: !INVERT_E0_DIR); }while(0) + #define NORM_E_DIR(E) do{ E0_DIR_WRITE(TEST(E, 0) ? DISABLED(INVERT_E0_DIR): ENABLED(INVERT_E0_DIR)); }while(0) + #define REV_E_DIR(E) do{ E0_DIR_WRITE(TEST(E, 0) ? ENABLED(INVERT_E0_DIR): DISABLED(INVERT_E0_DIR)); }while(0) #elif E_STEPPERS > 1 @@ -557,16 +557,16 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset case 4: E4_STEP_WRITE(V); break; case 5: E5_STEP_WRITE(V); break; case 6: E6_STEP_WRITE(V); break; case 7: E7_STEP_WRITE(V); break; \ } }while(0) #define _NORM_E_DIR(E) do{ switch (E) { \ - case 0: E0_DIR_WRITE(!INVERT_E0_DIR); break; case 1: E1_DIR_WRITE(!INVERT_E1_DIR); break; \ - case 2: E2_DIR_WRITE(!INVERT_E2_DIR); break; case 3: E3_DIR_WRITE(!INVERT_E3_DIR); break; \ - case 4: E4_DIR_WRITE(!INVERT_E4_DIR); break; case 5: E5_DIR_WRITE(!INVERT_E5_DIR); break; \ - case 6: E6_DIR_WRITE(!INVERT_E6_DIR); break; case 7: E7_DIR_WRITE(!INVERT_E7_DIR); break; \ + case 0: E0_DIR_WRITE(DISABLED(INVERT_E0_DIR)); break; case 1: E1_DIR_WRITE(DISABLED(INVERT_E1_DIR)); break; \ + case 2: E2_DIR_WRITE(DISABLED(INVERT_E2_DIR)); break; case 3: E3_DIR_WRITE(DISABLED(INVERT_E3_DIR)); break; \ + case 4: E4_DIR_WRITE(DISABLED(INVERT_E4_DIR)); break; case 5: E5_DIR_WRITE(DISABLED(INVERT_E5_DIR)); break; \ + case 6: E6_DIR_WRITE(DISABLED(INVERT_E6_DIR)); break; case 7: E7_DIR_WRITE(DISABLED(INVERT_E7_DIR)); break; \ } }while(0) #define _REV_E_DIR(E) do{ switch (E) { \ - case 0: E0_DIR_WRITE( INVERT_E0_DIR); break; case 1: E1_DIR_WRITE( INVERT_E1_DIR); break; \ - case 2: E2_DIR_WRITE( INVERT_E2_DIR); break; case 3: E3_DIR_WRITE( INVERT_E3_DIR); break; \ - case 4: E4_DIR_WRITE( INVERT_E4_DIR); break; case 5: E5_DIR_WRITE( INVERT_E5_DIR); break; \ - case 6: E6_DIR_WRITE( INVERT_E6_DIR); break; case 7: E7_DIR_WRITE( INVERT_E7_DIR); break; \ + case 0: E0_DIR_WRITE( ENABLED(INVERT_E0_DIR)); break; case 1: E1_DIR_WRITE( ENABLED(INVERT_E1_DIR)); break; \ + case 2: E2_DIR_WRITE( ENABLED(INVERT_E2_DIR)); break; case 3: E3_DIR_WRITE( ENABLED(INVERT_E3_DIR)); break; \ + case 4: E4_DIR_WRITE( ENABLED(INVERT_E4_DIR)); break; case 5: E5_DIR_WRITE( ENABLED(INVERT_E5_DIR)); break; \ + case 6: E6_DIR_WRITE( ENABLED(INVERT_E6_DIR)); break; case 7: E7_DIR_WRITE( ENABLED(INVERT_E7_DIR)); break; \ } }while(0) #elif E_STEPPERS > 6 @@ -576,16 +576,16 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset case 4: E4_STEP_WRITE(V); break; case 5: E5_STEP_WRITE(V); break; case 6: E6_STEP_WRITE(V); break; \ } }while(0) #define _NORM_E_DIR(E) do{ switch (E) { \ - case 0: E0_DIR_WRITE(!INVERT_E0_DIR); break; case 1: E1_DIR_WRITE(!INVERT_E1_DIR); break; \ - case 2: E2_DIR_WRITE(!INVERT_E2_DIR); break; case 3: E3_DIR_WRITE(!INVERT_E3_DIR); break; \ - case 4: E4_DIR_WRITE(!INVERT_E4_DIR); break; case 5: E5_DIR_WRITE(!INVERT_E5_DIR); break; \ - case 6: E6_DIR_WRITE(!INVERT_E6_DIR); break; \ + case 0: E0_DIR_WRITE(DISABLED(INVERT_E0_DIR)); break; case 1: E1_DIR_WRITE(DISABLED(INVERT_E1_DIR)); break; \ + case 2: E2_DIR_WRITE(DISABLED(INVERT_E2_DIR)); break; case 3: E3_DIR_WRITE(DISABLED(INVERT_E3_DIR)); break; \ + case 4: E4_DIR_WRITE(DISABLED(INVERT_E4_DIR)); break; case 5: E5_DIR_WRITE(DISABLED(INVERT_E5_DIR)); break; \ + case 6: E6_DIR_WRITE(DISABLED(INVERT_E6_DIR)); break; \ } }while(0) #define _REV_E_DIR(E) do{ switch (E) { \ - case 0: E0_DIR_WRITE( INVERT_E0_DIR); break; case 1: E1_DIR_WRITE( INVERT_E1_DIR); break; \ - case 2: E2_DIR_WRITE( INVERT_E2_DIR); break; case 3: E3_DIR_WRITE( INVERT_E3_DIR); break; \ - case 4: E4_DIR_WRITE( INVERT_E4_DIR); break; case 5: E5_DIR_WRITE( INVERT_E5_DIR); break; \ - case 6: E6_DIR_WRITE( INVERT_E6_DIR); break; \ + case 0: E0_DIR_WRITE( ENABLED(INVERT_E0_DIR)); break; case 1: E1_DIR_WRITE( ENABLED(INVERT_E1_DIR)); break; \ + case 2: E2_DIR_WRITE( ENABLED(INVERT_E2_DIR)); break; case 3: E3_DIR_WRITE( ENABLED(INVERT_E3_DIR)); break; \ + case 4: E4_DIR_WRITE( ENABLED(INVERT_E4_DIR)); break; case 5: E5_DIR_WRITE( ENABLED(INVERT_E5_DIR)); break; \ + case 6: E6_DIR_WRITE( ENABLED(INVERT_E6_DIR)); break; \ } }while(0) #elif E_STEPPERS > 5 @@ -595,14 +595,14 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset case 4: E4_STEP_WRITE(V); break; case 5: E5_STEP_WRITE(V); break; \ } }while(0) #define _NORM_E_DIR(E) do{ switch (E) { \ - case 0: E0_DIR_WRITE(!INVERT_E0_DIR); break; case 1: E1_DIR_WRITE(!INVERT_E1_DIR); break; \ - case 2: E2_DIR_WRITE(!INVERT_E2_DIR); break; case 3: E3_DIR_WRITE(!INVERT_E3_DIR); break; \ - case 4: E4_DIR_WRITE(!INVERT_E4_DIR); break; case 5: E5_DIR_WRITE(!INVERT_E5_DIR); break; \ + case 0: E0_DIR_WRITE(DISABLED(INVERT_E0_DIR)); break; case 1: E1_DIR_WRITE(DISABLED(INVERT_E1_DIR)); break; \ + case 2: E2_DIR_WRITE(DISABLED(INVERT_E2_DIR)); break; case 3: E3_DIR_WRITE(DISABLED(INVERT_E3_DIR)); break; \ + case 4: E4_DIR_WRITE(DISABLED(INVERT_E4_DIR)); break; case 5: E5_DIR_WRITE(DISABLED(INVERT_E5_DIR)); break; \ } }while(0) #define _REV_E_DIR(E) do{ switch (E) { \ - case 0: E0_DIR_WRITE( INVERT_E0_DIR); break; case 1: E1_DIR_WRITE( INVERT_E1_DIR); break; \ - case 2: E2_DIR_WRITE( INVERT_E2_DIR); break; case 3: E3_DIR_WRITE( INVERT_E3_DIR); break; \ - case 4: E4_DIR_WRITE( INVERT_E4_DIR); break; case 5: E5_DIR_WRITE( INVERT_E5_DIR); break; \ + case 0: E0_DIR_WRITE( ENABLED(INVERT_E0_DIR)); break; case 1: E1_DIR_WRITE( ENABLED(INVERT_E1_DIR)); break; \ + case 2: E2_DIR_WRITE( ENABLED(INVERT_E2_DIR)); break; case 3: E3_DIR_WRITE( ENABLED(INVERT_E3_DIR)); break; \ + case 4: E4_DIR_WRITE( ENABLED(INVERT_E4_DIR)); break; case 5: E5_DIR_WRITE( ENABLED(INVERT_E5_DIR)); break; \ } }while(0) #elif E_STEPPERS > 4 @@ -612,14 +612,14 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset case 4: E4_STEP_WRITE(V); break; \ } }while(0) #define _NORM_E_DIR(E) do{ switch (E) { \ - case 0: E0_DIR_WRITE(!INVERT_E0_DIR); break; case 1: E1_DIR_WRITE(!INVERT_E1_DIR); break; \ - case 2: E2_DIR_WRITE(!INVERT_E2_DIR); break; case 3: E3_DIR_WRITE(!INVERT_E3_DIR); break; \ - case 4: E4_DIR_WRITE(!INVERT_E4_DIR); break; \ + case 0: E0_DIR_WRITE(DISABLED(INVERT_E0_DIR)); break; case 1: E1_DIR_WRITE(DISABLED(INVERT_E1_DIR)); break; \ + case 2: E2_DIR_WRITE(DISABLED(INVERT_E2_DIR)); break; case 3: E3_DIR_WRITE(DISABLED(INVERT_E3_DIR)); break; \ + case 4: E4_DIR_WRITE(DISABLED(INVERT_E4_DIR)); break; \ } }while(0) #define _REV_E_DIR(E) do{ switch (E) { \ - case 0: E0_DIR_WRITE( INVERT_E0_DIR); break; case 1: E1_DIR_WRITE( INVERT_E1_DIR); break; \ - case 2: E2_DIR_WRITE( INVERT_E2_DIR); break; case 3: E3_DIR_WRITE( INVERT_E3_DIR); break; \ - case 4: E4_DIR_WRITE( INVERT_E4_DIR); break; \ + case 0: E0_DIR_WRITE( ENABLED(INVERT_E0_DIR)); break; case 1: E1_DIR_WRITE( ENABLED(INVERT_E1_DIR)); break; \ + case 2: E2_DIR_WRITE( ENABLED(INVERT_E2_DIR)); break; case 3: E3_DIR_WRITE( ENABLED(INVERT_E3_DIR)); break; \ + case 4: E4_DIR_WRITE( ENABLED(INVERT_E4_DIR)); break; \ } }while(0) #elif E_STEPPERS > 3 @@ -628,25 +628,25 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset case 0: E0_STEP_WRITE(V); break; case 1: E1_STEP_WRITE(V); break; case 2: E2_STEP_WRITE(V); break; case 3: E3_STEP_WRITE(V); break; \ } }while(0) #define _NORM_E_DIR(E) do{ switch (E) { \ - case 0: E0_DIR_WRITE(!INVERT_E0_DIR); break; case 1: E1_DIR_WRITE(!INVERT_E1_DIR); break; \ - case 2: E2_DIR_WRITE(!INVERT_E2_DIR); break; case 3: E3_DIR_WRITE(!INVERT_E3_DIR); break; \ + case 0: E0_DIR_WRITE(DISABLED(INVERT_E0_DIR)); break; case 1: E1_DIR_WRITE(DISABLED(INVERT_E1_DIR)); break; \ + case 2: E2_DIR_WRITE(DISABLED(INVERT_E2_DIR)); break; case 3: E3_DIR_WRITE(DISABLED(INVERT_E3_DIR)); break; \ } }while(0) #define _REV_E_DIR(E) do{ switch (E) { \ - case 0: E0_DIR_WRITE( INVERT_E0_DIR); break; case 1: E1_DIR_WRITE( INVERT_E1_DIR); break; \ - case 2: E2_DIR_WRITE( INVERT_E2_DIR); break; case 3: E3_DIR_WRITE( INVERT_E3_DIR); break; \ + case 0: E0_DIR_WRITE( ENABLED(INVERT_E0_DIR)); break; case 1: E1_DIR_WRITE( ENABLED(INVERT_E1_DIR)); break; \ + case 2: E2_DIR_WRITE( ENABLED(INVERT_E2_DIR)); break; case 3: E3_DIR_WRITE( ENABLED(INVERT_E3_DIR)); break; \ } }while(0) #elif E_STEPPERS > 2 #define _E_STEP_WRITE(E,V) do{ switch (E) { case 0: E0_STEP_WRITE(V); break; case 1: E1_STEP_WRITE(V); break; case 2: E2_STEP_WRITE(V); } }while(0) - #define _NORM_E_DIR(E) do{ switch (E) { case 0: E0_DIR_WRITE(!INVERT_E0_DIR); break; case 1: E1_DIR_WRITE(!INVERT_E1_DIR); break; case 2: E2_DIR_WRITE(!INVERT_E2_DIR); } }while(0) - #define _REV_E_DIR(E) do{ switch (E) { case 0: E0_DIR_WRITE( INVERT_E0_DIR); break; case 1: E1_DIR_WRITE( INVERT_E1_DIR); break; case 2: E2_DIR_WRITE( INVERT_E2_DIR); } }while(0) + #define _NORM_E_DIR(E) do{ switch (E) { case 0: E0_DIR_WRITE(DISABLED(INVERT_E0_DIR)); break; case 1: E1_DIR_WRITE(DISABLED(INVERT_E1_DIR)); break; case 2: E2_DIR_WRITE(DISABLED(INVERT_E2_DIR)); } }while(0) + #define _REV_E_DIR(E) do{ switch (E) { case 0: E0_DIR_WRITE( ENABLED(INVERT_E0_DIR)); break; case 1: E1_DIR_WRITE( ENABLED(INVERT_E1_DIR)); break; case 2: E2_DIR_WRITE( ENABLED(INVERT_E2_DIR)); } }while(0) #else #define _E_STEP_WRITE(E,V) do{ if (E == 0) { E0_STEP_WRITE(V); } else { E1_STEP_WRITE(V); } }while(0) - #define _NORM_E_DIR(E) do{ if (E == 0) { E0_DIR_WRITE(!INVERT_E0_DIR); } else { E1_DIR_WRITE(!INVERT_E1_DIR); } }while(0) - #define _REV_E_DIR(E) do{ if (E == 0) { E0_DIR_WRITE( INVERT_E0_DIR); } else { E1_DIR_WRITE( INVERT_E1_DIR); } }while(0) + #define _NORM_E_DIR(E) do{ if (E == 0) { E0_DIR_WRITE(DISABLED(INVERT_E0_DIR)); } else { E1_DIR_WRITE(DISABLED(INVERT_E1_DIR)); } }while(0) + #define _REV_E_DIR(E) do{ if (E == 0) { E0_DIR_WRITE( ENABLED(INVERT_E0_DIR)); } else { E1_DIR_WRITE( ENABLED(INVERT_E1_DIR)); } }while(0) #endif #if HAS_DUPLICATION_MODE @@ -657,8 +657,8 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #define _DUPE(N,T,V) E##N##_##T##_WRITE(V) #endif - #define NDIR(N) _DUPE(N,DIR,!INVERT_E##N##_DIR) - #define RDIR(N) _DUPE(N,DIR, INVERT_E##N##_DIR) + #define NDIR(N) _DUPE(N,DIR,DISABLED(INVERT_E##N##_DIR)) + #define RDIR(N) _DUPE(N,DIR, ENABLED(INVERT_E##N##_DIR)) #define E_STEP_WRITE(E,V) do{ if (extruder_duplication_enabled) { DUPE(STEP,V); } else _E_STEP_WRITE(E,V); }while(0) @@ -704,13 +704,13 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #elif ENABLED(E_DUAL_STEPPER_DRIVERS) #define E_STEP_WRITE(E,V) do{ E0_STEP_WRITE(V); E1_STEP_WRITE(V); }while(0) - #define NORM_E_DIR(E) do{ E0_DIR_WRITE(!INVERT_E0_DIR); E1_DIR_WRITE(!INVERT_E0_DIR ^ ENABLED(INVERT_E1_VS_E0_DIR)); }while(0) - #define REV_E_DIR(E) do{ E0_DIR_WRITE( INVERT_E0_DIR); E1_DIR_WRITE( INVERT_E0_DIR ^ ENABLED(INVERT_E1_VS_E0_DIR)); }while(0) + #define NORM_E_DIR(E) do{ E0_DIR_WRITE(DISABLED(INVERT_E0_DIR)); E1_DIR_WRITE(DISABLED(INVERT_E0_DIR) ^ ENABLED(INVERT_E1_VS_E0_DIR)); }while(0) + #define REV_E_DIR(E) do{ E0_DIR_WRITE( ENABLED(INVERT_E0_DIR)); E1_DIR_WRITE( ENABLED(INVERT_E0_DIR) ^ ENABLED(INVERT_E1_VS_E0_DIR)); }while(0) #elif E_STEPPERS #define E_STEP_WRITE(E,V) E0_STEP_WRITE(V) - #define NORM_E_DIR(E) E0_DIR_WRITE(!INVERT_E0_DIR) - #define REV_E_DIR(E) E0_DIR_WRITE( INVERT_E0_DIR) + #define NORM_E_DIR(E) E0_DIR_WRITE(DISABLED(INVERT_E0_DIR)) + #define REV_E_DIR(E) E0_DIR_WRITE( ENABLED(INVERT_E0_DIR)) #else #define E_STEP_WRITE(E,V) NOOP