Function-like macros

This commit is contained in:
Scott Lahteine 2020-01-19 20:01:22 -06:00
parent 707349d492
commit 37849969ad
3 changed files with 72 additions and 72 deletions

View file

@ -2049,96 +2049,96 @@ void Stepper::init() {
// Init Dir Pins // Init Dir Pins
#if HAS_X_DIR #if HAS_X_DIR
X_DIR_INIT; X_DIR_INIT();
#endif #endif
#if HAS_X2_DIR #if HAS_X2_DIR
X2_DIR_INIT; X2_DIR_INIT();
#endif #endif
#if HAS_Y_DIR #if HAS_Y_DIR
Y_DIR_INIT; Y_DIR_INIT();
#if ENABLED(Y_DUAL_STEPPER_DRIVERS) && HAS_Y2_DIR #if ENABLED(Y_DUAL_STEPPER_DRIVERS) && HAS_Y2_DIR
Y2_DIR_INIT; Y2_DIR_INIT();
#endif #endif
#endif #endif
#if HAS_Z_DIR #if HAS_Z_DIR
Z_DIR_INIT; Z_DIR_INIT();
#if Z_MULTI_STEPPER_DRIVERS && HAS_Z2_DIR #if Z_MULTI_STEPPER_DRIVERS && HAS_Z2_DIR
Z2_DIR_INIT; Z2_DIR_INIT();
#endif #endif
#if ENABLED(Z_TRIPLE_STEPPER_DRIVERS) && HAS_Z3_DIR #if ENABLED(Z_TRIPLE_STEPPER_DRIVERS) && HAS_Z3_DIR
Z3_DIR_INIT; Z3_DIR_INIT();
#endif #endif
#endif #endif
#if HAS_E0_DIR #if HAS_E0_DIR
E0_DIR_INIT; E0_DIR_INIT();
#endif #endif
#if HAS_E1_DIR #if HAS_E1_DIR
E1_DIR_INIT; E1_DIR_INIT();
#endif #endif
#if HAS_E2_DIR #if HAS_E2_DIR
E2_DIR_INIT; E2_DIR_INIT();
#endif #endif
#if HAS_E3_DIR #if HAS_E3_DIR
E3_DIR_INIT; E3_DIR_INIT();
#endif #endif
#if HAS_E4_DIR #if HAS_E4_DIR
E4_DIR_INIT; E4_DIR_INIT();
#endif #endif
#if HAS_E5_DIR #if HAS_E5_DIR
E5_DIR_INIT; E5_DIR_INIT();
#endif #endif
// Init Enable Pins - steppers default to disabled. // Init Enable Pins - steppers default to disabled.
#if HAS_X_ENABLE #if HAS_X_ENABLE
X_ENABLE_INIT; X_ENABLE_INIT();
if (!X_ENABLE_ON) X_ENABLE_WRITE(HIGH); if (!X_ENABLE_ON) X_ENABLE_WRITE(HIGH);
#if EITHER(DUAL_X_CARRIAGE, X_DUAL_STEPPER_DRIVERS) && HAS_X2_ENABLE #if EITHER(DUAL_X_CARRIAGE, X_DUAL_STEPPER_DRIVERS) && HAS_X2_ENABLE
X2_ENABLE_INIT; X2_ENABLE_INIT();
if (!X_ENABLE_ON) X2_ENABLE_WRITE(HIGH); if (!X_ENABLE_ON) X2_ENABLE_WRITE(HIGH);
#endif #endif
#endif #endif
#if HAS_Y_ENABLE #if HAS_Y_ENABLE
Y_ENABLE_INIT; Y_ENABLE_INIT();
if (!Y_ENABLE_ON) Y_ENABLE_WRITE(HIGH); if (!Y_ENABLE_ON) Y_ENABLE_WRITE(HIGH);
#if ENABLED(Y_DUAL_STEPPER_DRIVERS) && HAS_Y2_ENABLE #if ENABLED(Y_DUAL_STEPPER_DRIVERS) && HAS_Y2_ENABLE
Y2_ENABLE_INIT; Y2_ENABLE_INIT();
if (!Y_ENABLE_ON) Y2_ENABLE_WRITE(HIGH); if (!Y_ENABLE_ON) Y2_ENABLE_WRITE(HIGH);
#endif #endif
#endif #endif
#if HAS_Z_ENABLE #if HAS_Z_ENABLE
Z_ENABLE_INIT; Z_ENABLE_INIT();
if (!Z_ENABLE_ON) Z_ENABLE_WRITE(HIGH); if (!Z_ENABLE_ON) Z_ENABLE_WRITE(HIGH);
#if Z_MULTI_STEPPER_DRIVERS && HAS_Z2_ENABLE #if Z_MULTI_STEPPER_DRIVERS && HAS_Z2_ENABLE
Z2_ENABLE_INIT; Z2_ENABLE_INIT();
if (!Z_ENABLE_ON) Z2_ENABLE_WRITE(HIGH); if (!Z_ENABLE_ON) Z2_ENABLE_WRITE(HIGH);
#endif #endif
#if ENABLED(Z_TRIPLE_STEPPER_DRIVERS) && HAS_Z3_ENABLE #if ENABLED(Z_TRIPLE_STEPPER_DRIVERS) && HAS_Z3_ENABLE
Z3_ENABLE_INIT; Z3_ENABLE_INIT();
if (!Z_ENABLE_ON) Z3_ENABLE_WRITE(HIGH); if (!Z_ENABLE_ON) Z3_ENABLE_WRITE(HIGH);
#endif #endif
#endif #endif
#if HAS_E0_ENABLE #if HAS_E0_ENABLE
E0_ENABLE_INIT; E0_ENABLE_INIT();
if (!E_ENABLE_ON) E0_ENABLE_WRITE(HIGH); if (!E_ENABLE_ON) E0_ENABLE_WRITE(HIGH);
#endif #endif
#if HAS_E1_ENABLE #if HAS_E1_ENABLE
E1_ENABLE_INIT; E1_ENABLE_INIT();
if (!E_ENABLE_ON) E1_ENABLE_WRITE(HIGH); if (!E_ENABLE_ON) E1_ENABLE_WRITE(HIGH);
#endif #endif
#if HAS_E2_ENABLE #if HAS_E2_ENABLE
E2_ENABLE_INIT; E2_ENABLE_INIT();
if (!E_ENABLE_ON) E2_ENABLE_WRITE(HIGH); if (!E_ENABLE_ON) E2_ENABLE_WRITE(HIGH);
#endif #endif
#if HAS_E3_ENABLE #if HAS_E3_ENABLE
E3_ENABLE_INIT; E3_ENABLE_INIT();
if (!E_ENABLE_ON) E3_ENABLE_WRITE(HIGH); if (!E_ENABLE_ON) E3_ENABLE_WRITE(HIGH);
#endif #endif
#if HAS_E4_ENABLE #if HAS_E4_ENABLE
E4_ENABLE_INIT; E4_ENABLE_INIT();
if (!E_ENABLE_ON) E4_ENABLE_WRITE(HIGH); if (!E_ENABLE_ON) E4_ENABLE_WRITE(HIGH);
#endif #endif
#if HAS_E5_ENABLE #if HAS_E5_ENABLE
E5_ENABLE_INIT; E5_ENABLE_INIT();
if (!E_ENABLE_ON) E5_ENABLE_WRITE(HIGH); if (!E_ENABLE_ON) E5_ENABLE_WRITE(HIGH);
#endif #endif
@ -2156,7 +2156,7 @@ void Stepper::init() {
// Init Step Pins // Init Step Pins
#if HAS_X_STEP #if HAS_X_STEP
#if EITHER(X_DUAL_STEPPER_DRIVERS, DUAL_X_CARRIAGE) #if EITHER(X_DUAL_STEPPER_DRIVERS, DUAL_X_CARRIAGE)
X2_STEP_INIT; X2_STEP_INIT();
X2_STEP_WRITE(INVERT_X_STEP_PIN); X2_STEP_WRITE(INVERT_X_STEP_PIN);
#endif #endif
AXIS_INIT(X, X); AXIS_INIT(X, X);
@ -2164,7 +2164,7 @@ void Stepper::init() {
#if HAS_Y_STEP #if HAS_Y_STEP
#if ENABLED(Y_DUAL_STEPPER_DRIVERS) #if ENABLED(Y_DUAL_STEPPER_DRIVERS)
Y2_STEP_INIT; Y2_STEP_INIT();
Y2_STEP_WRITE(INVERT_Y_STEP_PIN); Y2_STEP_WRITE(INVERT_Y_STEP_PIN);
#endif #endif
AXIS_INIT(Y, Y); AXIS_INIT(Y, Y);
@ -2172,11 +2172,11 @@ void Stepper::init() {
#if HAS_Z_STEP #if HAS_Z_STEP
#if Z_MULTI_STEPPER_DRIVERS #if Z_MULTI_STEPPER_DRIVERS
Z2_STEP_INIT; Z2_STEP_INIT();
Z2_STEP_WRITE(INVERT_Z_STEP_PIN); Z2_STEP_WRITE(INVERT_Z_STEP_PIN);
#endif #endif
#if ENABLED(Z_TRIPLE_STEPPER_DRIVERS) #if ENABLED(Z_TRIPLE_STEPPER_DRIVERS)
Z3_STEP_INIT; Z3_STEP_INIT();
Z3_STEP_WRITE(INVERT_Z_STEP_PIN); Z3_STEP_WRITE(INVERT_Z_STEP_PIN);
#endif #endif
AXIS_INIT(Z, Z); AXIS_INIT(Z, Z);

View file

@ -58,11 +58,11 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
#define X_DIR_WRITE(STATE) WRITE(X_DIR_PIN,STATE) #define X_DIR_WRITE(STATE) WRITE(X_DIR_PIN,STATE)
#define X_DIR_READ() READ(X_DIR_PIN) #define X_DIR_READ() READ(X_DIR_PIN)
#endif #endif
#define X_STEP_INIT SET_OUTPUT(X_STEP_PIN) #define X_STEP_INIT() SET_OUTPUT(X_STEP_PIN)
#ifndef X_STEP_WRITE #ifndef X_STEP_WRITE
#define X_STEP_WRITE(STATE) WRITE(X_STEP_PIN,STATE) #define X_STEP_WRITE(STATE) WRITE(X_STEP_PIN,STATE)
#endif #endif
#define X_STEP_READ READ(X_STEP_PIN) #define X_STEP_READ() READ(X_STEP_PIN)
// Y Stepper // Y Stepper
#ifndef Y_ENABLE_INIT #ifndef Y_ENABLE_INIT
@ -75,11 +75,11 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
#define Y_DIR_WRITE(STATE) WRITE(Y_DIR_PIN,STATE) #define Y_DIR_WRITE(STATE) WRITE(Y_DIR_PIN,STATE)
#define Y_DIR_READ() READ(Y_DIR_PIN) #define Y_DIR_READ() READ(Y_DIR_PIN)
#endif #endif
#define Y_STEP_INIT SET_OUTPUT(Y_STEP_PIN) #define Y_STEP_INIT() SET_OUTPUT(Y_STEP_PIN)
#ifndef Y_STEP_WRITE #ifndef Y_STEP_WRITE
#define Y_STEP_WRITE(STATE) WRITE(Y_STEP_PIN,STATE) #define Y_STEP_WRITE(STATE) WRITE(Y_STEP_PIN,STATE)
#endif #endif
#define Y_STEP_READ READ(Y_STEP_PIN) #define Y_STEP_READ() READ(Y_STEP_PIN)
// Z Stepper // Z Stepper
#ifndef Z_ENABLE_INIT #ifndef Z_ENABLE_INIT
@ -92,11 +92,11 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
#define Z_DIR_WRITE(STATE) WRITE(Z_DIR_PIN,STATE) #define Z_DIR_WRITE(STATE) WRITE(Z_DIR_PIN,STATE)
#define Z_DIR_READ() READ(Z_DIR_PIN) #define Z_DIR_READ() READ(Z_DIR_PIN)
#endif #endif
#define Z_STEP_INIT SET_OUTPUT(Z_STEP_PIN) #define Z_STEP_INIT() SET_OUTPUT(Z_STEP_PIN)
#ifndef Z_STEP_WRITE #ifndef Z_STEP_WRITE
#define Z_STEP_WRITE(STATE) WRITE(Z_STEP_PIN,STATE) #define Z_STEP_WRITE(STATE) WRITE(Z_STEP_PIN,STATE)
#endif #endif
#define Z_STEP_READ READ(Z_STEP_PIN) #define Z_STEP_READ() READ(Z_STEP_PIN)
// X2 Stepper // X2 Stepper
#if HAS_X2_ENABLE #if HAS_X2_ENABLE
@ -110,11 +110,11 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
#define X2_DIR_WRITE(STATE) WRITE(X2_DIR_PIN,STATE) #define X2_DIR_WRITE(STATE) WRITE(X2_DIR_PIN,STATE)
#define X2_DIR_READ() READ(X2_DIR_PIN) #define X2_DIR_READ() READ(X2_DIR_PIN)
#endif #endif
#define X2_STEP_INIT SET_OUTPUT(X2_STEP_PIN) #define X2_STEP_INIT() SET_OUTPUT(X2_STEP_PIN)
#ifndef X2_STEP_WRITE #ifndef X2_STEP_WRITE
#define X2_STEP_WRITE(STATE) WRITE(X2_STEP_PIN,STATE) #define X2_STEP_WRITE(STATE) WRITE(X2_STEP_PIN,STATE)
#endif #endif
#define X2_STEP_READ READ(X2_STEP_PIN) #define X2_STEP_READ() READ(X2_STEP_PIN)
#endif #endif
// Y2 Stepper // Y2 Stepper
@ -129,11 +129,11 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
#define Y2_DIR_WRITE(STATE) WRITE(Y2_DIR_PIN,STATE) #define Y2_DIR_WRITE(STATE) WRITE(Y2_DIR_PIN,STATE)
#define Y2_DIR_READ() READ(Y2_DIR_PIN) #define Y2_DIR_READ() READ(Y2_DIR_PIN)
#endif #endif
#define Y2_STEP_INIT SET_OUTPUT(Y2_STEP_PIN) #define Y2_STEP_INIT() SET_OUTPUT(Y2_STEP_PIN)
#ifndef Y2_STEP_WRITE #ifndef Y2_STEP_WRITE
#define Y2_STEP_WRITE(STATE) WRITE(Y2_STEP_PIN,STATE) #define Y2_STEP_WRITE(STATE) WRITE(Y2_STEP_PIN,STATE)
#endif #endif
#define Y2_STEP_READ READ(Y2_STEP_PIN) #define Y2_STEP_READ() READ(Y2_STEP_PIN)
#else #else
#define Y2_DIR_WRITE(STATE) NOOP #define Y2_DIR_WRITE(STATE) NOOP
#endif #endif
@ -150,11 +150,11 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
#define Z2_DIR_WRITE(STATE) WRITE(Z2_DIR_PIN,STATE) #define Z2_DIR_WRITE(STATE) WRITE(Z2_DIR_PIN,STATE)
#define Z2_DIR_READ() READ(Z2_DIR_PIN) #define Z2_DIR_READ() READ(Z2_DIR_PIN)
#endif #endif
#define Z2_STEP_INIT SET_OUTPUT(Z2_STEP_PIN) #define Z2_STEP_INIT() SET_OUTPUT(Z2_STEP_PIN)
#ifndef Z2_STEP_WRITE #ifndef Z2_STEP_WRITE
#define Z2_STEP_WRITE(STATE) WRITE(Z2_STEP_PIN,STATE) #define Z2_STEP_WRITE(STATE) WRITE(Z2_STEP_PIN,STATE)
#endif #endif
#define Z2_STEP_READ READ(Z2_STEP_PIN) #define Z2_STEP_READ() READ(Z2_STEP_PIN)
#else #else
#define Z2_DIR_WRITE(STATE) NOOP #define Z2_DIR_WRITE(STATE) NOOP
#endif #endif
@ -171,11 +171,11 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
#define Z3_DIR_WRITE(STATE) WRITE(Z3_DIR_PIN,STATE) #define Z3_DIR_WRITE(STATE) WRITE(Z3_DIR_PIN,STATE)
#define Z3_DIR_READ() READ(Z3_DIR_PIN) #define Z3_DIR_READ() READ(Z3_DIR_PIN)
#endif #endif
#define Z3_STEP_INIT SET_OUTPUT(Z3_STEP_PIN) #define Z3_STEP_INIT() SET_OUTPUT(Z3_STEP_PIN)
#ifndef Z3_STEP_WRITE #ifndef Z3_STEP_WRITE
#define Z3_STEP_WRITE(STATE) WRITE(Z3_STEP_PIN,STATE) #define Z3_STEP_WRITE(STATE) WRITE(Z3_STEP_PIN,STATE)
#endif #endif
#define Z3_STEP_READ READ(Z3_STEP_PIN) #define Z3_STEP_READ() READ(Z3_STEP_PIN)
#else #else
#define Z3_DIR_WRITE(STATE) NOOP #define Z3_DIR_WRITE(STATE) NOOP
#endif #endif
@ -191,11 +191,11 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
#define E0_DIR_WRITE(STATE) WRITE(E0_DIR_PIN,STATE) #define E0_DIR_WRITE(STATE) WRITE(E0_DIR_PIN,STATE)
#define E0_DIR_READ() READ(E0_DIR_PIN) #define E0_DIR_READ() READ(E0_DIR_PIN)
#endif #endif
#define E0_STEP_INIT SET_OUTPUT(E0_STEP_PIN) #define E0_STEP_INIT() SET_OUTPUT(E0_STEP_PIN)
#ifndef E0_STEP_WRITE #ifndef E0_STEP_WRITE
#define E0_STEP_WRITE(STATE) WRITE(E0_STEP_PIN,STATE) #define E0_STEP_WRITE(STATE) WRITE(E0_STEP_PIN,STATE)
#endif #endif
#define E0_STEP_READ READ(E0_STEP_PIN) #define E0_STEP_READ() READ(E0_STEP_PIN)
// E1 Stepper // E1 Stepper
#ifndef E1_ENABLE_INIT #ifndef E1_ENABLE_INIT
@ -208,11 +208,11 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
#define E1_DIR_WRITE(STATE) WRITE(E1_DIR_PIN,STATE) #define E1_DIR_WRITE(STATE) WRITE(E1_DIR_PIN,STATE)
#define E1_DIR_READ() READ(E1_DIR_PIN) #define E1_DIR_READ() READ(E1_DIR_PIN)
#endif #endif
#define E1_STEP_INIT SET_OUTPUT(E1_STEP_PIN) #define E1_STEP_INIT() SET_OUTPUT(E1_STEP_PIN)
#ifndef E1_STEP_WRITE #ifndef E1_STEP_WRITE
#define E1_STEP_WRITE(STATE) WRITE(E1_STEP_PIN,STATE) #define E1_STEP_WRITE(STATE) WRITE(E1_STEP_PIN,STATE)
#endif #endif
#define E1_STEP_READ READ(E1_STEP_PIN) #define E1_STEP_READ() READ(E1_STEP_PIN)
// E2 Stepper // E2 Stepper
#ifndef E2_ENABLE_INIT #ifndef E2_ENABLE_INIT
@ -225,11 +225,11 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
#define E2_DIR_WRITE(STATE) WRITE(E2_DIR_PIN,STATE) #define E2_DIR_WRITE(STATE) WRITE(E2_DIR_PIN,STATE)
#define E2_DIR_READ() READ(E2_DIR_PIN) #define E2_DIR_READ() READ(E2_DIR_PIN)
#endif #endif
#define E2_STEP_INIT SET_OUTPUT(E2_STEP_PIN) #define E2_STEP_INIT() SET_OUTPUT(E2_STEP_PIN)
#ifndef E2_STEP_WRITE #ifndef E2_STEP_WRITE
#define E2_STEP_WRITE(STATE) WRITE(E2_STEP_PIN,STATE) #define E2_STEP_WRITE(STATE) WRITE(E2_STEP_PIN,STATE)
#endif #endif
#define E2_STEP_READ READ(E2_STEP_PIN) #define E2_STEP_READ() READ(E2_STEP_PIN)
// E3 Stepper // E3 Stepper
#ifndef E3_ENABLE_INIT #ifndef E3_ENABLE_INIT
@ -242,11 +242,11 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
#define E3_DIR_WRITE(STATE) WRITE(E3_DIR_PIN,STATE) #define E3_DIR_WRITE(STATE) WRITE(E3_DIR_PIN,STATE)
#define E3_DIR_READ() READ(E3_DIR_PIN) #define E3_DIR_READ() READ(E3_DIR_PIN)
#endif #endif
#define E3_STEP_INIT SET_OUTPUT(E3_STEP_PIN) #define E3_STEP_INIT() SET_OUTPUT(E3_STEP_PIN)
#ifndef E3_STEP_WRITE #ifndef E3_STEP_WRITE
#define E3_STEP_WRITE(STATE) WRITE(E3_STEP_PIN,STATE) #define E3_STEP_WRITE(STATE) WRITE(E3_STEP_PIN,STATE)
#endif #endif
#define E3_STEP_READ READ(E3_STEP_PIN) #define E3_STEP_READ() READ(E3_STEP_PIN)
// E4 Stepper // E4 Stepper
#ifndef E4_ENABLE_INIT #ifndef E4_ENABLE_INIT
@ -259,11 +259,11 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
#define E4_DIR_WRITE(STATE) WRITE(E4_DIR_PIN,STATE) #define E4_DIR_WRITE(STATE) WRITE(E4_DIR_PIN,STATE)
#define E4_DIR_READ() READ(E4_DIR_PIN) #define E4_DIR_READ() READ(E4_DIR_PIN)
#endif #endif
#define E4_STEP_INIT SET_OUTPUT(E4_STEP_PIN) #define E4_STEP_INIT() SET_OUTPUT(E4_STEP_PIN)
#ifndef E4_STEP_WRITE #ifndef E4_STEP_WRITE
#define E4_STEP_WRITE(STATE) WRITE(E4_STEP_PIN,STATE) #define E4_STEP_WRITE(STATE) WRITE(E4_STEP_PIN,STATE)
#endif #endif
#define E4_STEP_READ READ(E4_STEP_PIN) #define E4_STEP_READ() READ(E4_STEP_PIN)
// E5 Stepper // E5 Stepper
#ifndef E5_ENABLE_INIT #ifndef E5_ENABLE_INIT
@ -276,11 +276,11 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
#define E5_DIR_WRITE(STATE) WRITE(E5_DIR_PIN,STATE) #define E5_DIR_WRITE(STATE) WRITE(E5_DIR_PIN,STATE)
#define E5_DIR_READ() READ(E5_DIR_PIN) #define E5_DIR_READ() READ(E5_DIR_PIN)
#endif #endif
#define E5_STEP_INIT SET_OUTPUT(E5_STEP_PIN) #define E5_STEP_INIT() SET_OUTPUT(E5_STEP_PIN)
#ifndef E5_STEP_WRITE #ifndef E5_STEP_WRITE
#define E5_STEP_WRITE(STATE) WRITE(E5_STEP_PIN,STATE) #define E5_STEP_WRITE(STATE) WRITE(E5_STEP_PIN,STATE)
#endif #endif
#define E5_STEP_READ READ(E5_STEP_PIN) #define E5_STEP_READ() READ(E5_STEP_PIN)
/** /**
* Extruder indirection for the single E axis * Extruder indirection for the single E axis