Simplify stepper macros by renaming enable/disable macros

This commit is contained in:
Scott Lahteine 2017-04-11 11:10:26 -05:00
parent e02a5a6371
commit 68773f4486
4 changed files with 139 additions and 138 deletions

View file

@ -60,36 +60,36 @@ void manage_inactivity(bool ignore_stepper_queue = false);
#endif
#if HAS_X2_ENABLE
#define enable_x() do{ X_ENABLE_WRITE( X_ENABLE_ON); X2_ENABLE_WRITE( X_ENABLE_ON); }while(0)
#define disable_x() do{ X_ENABLE_WRITE(!X_ENABLE_ON); X2_ENABLE_WRITE(!X_ENABLE_ON); axis_known_position[X_AXIS] = false; }while(0)
#define enable_X() do{ X_ENABLE_WRITE( X_ENABLE_ON); X2_ENABLE_WRITE( X_ENABLE_ON); }while(0)
#define disable_X() do{ X_ENABLE_WRITE(!X_ENABLE_ON); X2_ENABLE_WRITE(!X_ENABLE_ON); axis_known_position[X_AXIS] = false; }while(0)
#elif HAS_X_ENABLE
#define enable_x() X_ENABLE_WRITE( X_ENABLE_ON)
#define disable_x() do{ X_ENABLE_WRITE(!X_ENABLE_ON); axis_known_position[X_AXIS] = false; }while(0)
#define enable_X() X_ENABLE_WRITE( X_ENABLE_ON)
#define disable_X() do{ X_ENABLE_WRITE(!X_ENABLE_ON); axis_known_position[X_AXIS] = false; }while(0)
#else
#define enable_x() NOOP
#define disable_x() NOOP
#define enable_X() NOOP
#define disable_X() NOOP
#endif
#if HAS_Y2_ENABLE
#define enable_y() do{ Y_ENABLE_WRITE( Y_ENABLE_ON); Y2_ENABLE_WRITE(Y_ENABLE_ON); }while(0)
#define disable_y() do{ Y_ENABLE_WRITE(!Y_ENABLE_ON); Y2_ENABLE_WRITE(!Y_ENABLE_ON); axis_known_position[Y_AXIS] = false; }while(0)
#define enable_Y() do{ Y_ENABLE_WRITE( Y_ENABLE_ON); Y2_ENABLE_WRITE(Y_ENABLE_ON); }while(0)
#define disable_Y() do{ Y_ENABLE_WRITE(!Y_ENABLE_ON); Y2_ENABLE_WRITE(!Y_ENABLE_ON); axis_known_position[Y_AXIS] = false; }while(0)
#elif HAS_Y_ENABLE
#define enable_y() Y_ENABLE_WRITE( Y_ENABLE_ON)
#define disable_y() do{ Y_ENABLE_WRITE(!Y_ENABLE_ON); axis_known_position[Y_AXIS] = false; }while(0)
#define enable_Y() Y_ENABLE_WRITE( Y_ENABLE_ON)
#define disable_Y() do{ Y_ENABLE_WRITE(!Y_ENABLE_ON); axis_known_position[Y_AXIS] = false; }while(0)
#else
#define enable_y() NOOP
#define disable_y() NOOP
#define enable_Y() NOOP
#define disable_Y() NOOP
#endif
#if HAS_Z2_ENABLE
#define enable_z() do{ Z_ENABLE_WRITE( Z_ENABLE_ON); Z2_ENABLE_WRITE(Z_ENABLE_ON); }while(0)
#define disable_z() do{ Z_ENABLE_WRITE(!Z_ENABLE_ON); Z2_ENABLE_WRITE(!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; }while(0)
#define enable_Z() do{ Z_ENABLE_WRITE( Z_ENABLE_ON); Z2_ENABLE_WRITE(Z_ENABLE_ON); }while(0)
#define disable_Z() do{ Z_ENABLE_WRITE(!Z_ENABLE_ON); Z2_ENABLE_WRITE(!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; }while(0)
#elif HAS_Z_ENABLE
#define enable_z() Z_ENABLE_WRITE( Z_ENABLE_ON)
#define disable_z() do{ Z_ENABLE_WRITE(!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; }while(0)
#define enable_Z() Z_ENABLE_WRITE( Z_ENABLE_ON)
#define disable_Z() do{ Z_ENABLE_WRITE(!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; }while(0)
#else
#define enable_z() NOOP
#define disable_z() NOOP
#define enable_Z() NOOP
#define disable_Z() NOOP
#endif
#if ENABLED(MIXING_EXTRUDER)
@ -98,64 +98,64 @@ void manage_inactivity(bool ignore_stepper_queue = false);
* Mixing steppers synchronize their enable (and direction) together
*/
#if MIXING_STEPPERS > 3
#define enable_e0() { E0_ENABLE_WRITE( E_ENABLE_ON); E1_ENABLE_WRITE( E_ENABLE_ON); E2_ENABLE_WRITE( E_ENABLE_ON); E3_ENABLE_WRITE( E_ENABLE_ON); }
#define disable_e0() { E0_ENABLE_WRITE(!E_ENABLE_ON); E1_ENABLE_WRITE(!E_ENABLE_ON); E2_ENABLE_WRITE(!E_ENABLE_ON); E3_ENABLE_WRITE(!E_ENABLE_ON); }
#define enable_E0() { E0_ENABLE_WRITE( E_ENABLE_ON); E1_ENABLE_WRITE( E_ENABLE_ON); E2_ENABLE_WRITE( E_ENABLE_ON); E3_ENABLE_WRITE( E_ENABLE_ON); }
#define disable_E0() { E0_ENABLE_WRITE(!E_ENABLE_ON); E1_ENABLE_WRITE(!E_ENABLE_ON); E2_ENABLE_WRITE(!E_ENABLE_ON); E3_ENABLE_WRITE(!E_ENABLE_ON); }
#elif MIXING_STEPPERS > 2
#define enable_e0() { E0_ENABLE_WRITE( E_ENABLE_ON); E1_ENABLE_WRITE( E_ENABLE_ON); E2_ENABLE_WRITE( E_ENABLE_ON); }
#define disable_e0() { E0_ENABLE_WRITE(!E_ENABLE_ON); E1_ENABLE_WRITE(!E_ENABLE_ON); E2_ENABLE_WRITE(!E_ENABLE_ON); }
#define enable_E0() { E0_ENABLE_WRITE( E_ENABLE_ON); E1_ENABLE_WRITE( E_ENABLE_ON); E2_ENABLE_WRITE( E_ENABLE_ON); }
#define disable_E0() { E0_ENABLE_WRITE(!E_ENABLE_ON); E1_ENABLE_WRITE(!E_ENABLE_ON); E2_ENABLE_WRITE(!E_ENABLE_ON); }
#else
#define enable_e0() { E0_ENABLE_WRITE( E_ENABLE_ON); E1_ENABLE_WRITE( E_ENABLE_ON); }
#define disable_e0() { E0_ENABLE_WRITE(!E_ENABLE_ON); E1_ENABLE_WRITE(!E_ENABLE_ON); }
#define enable_E0() { E0_ENABLE_WRITE( E_ENABLE_ON); E1_ENABLE_WRITE( E_ENABLE_ON); }
#define disable_E0() { E0_ENABLE_WRITE(!E_ENABLE_ON); E1_ENABLE_WRITE(!E_ENABLE_ON); }
#endif
#define enable_e1() NOOP
#define disable_e1() NOOP
#define enable_e2() NOOP
#define disable_e2() NOOP
#define enable_e3() NOOP
#define disable_e3() NOOP
#define enable_e4() NOOP
#define disable_e4() NOOP
#define enable_E1() NOOP
#define disable_E1() NOOP
#define enable_E2() NOOP
#define disable_E2() NOOP
#define enable_E3() NOOP
#define disable_E3() NOOP
#define enable_E4() NOOP
#define disable_E4() NOOP
#else // !MIXING_EXTRUDER
#if HAS_E0_ENABLE
#define enable_e0() E0_ENABLE_WRITE( E_ENABLE_ON)
#define disable_e0() E0_ENABLE_WRITE(!E_ENABLE_ON)
#define enable_E0() E0_ENABLE_WRITE( E_ENABLE_ON)
#define disable_E0() E0_ENABLE_WRITE(!E_ENABLE_ON)
#else
#define enable_e0() NOOP
#define disable_e0() NOOP
#define enable_E0() NOOP
#define disable_E0() NOOP
#endif
#if E_STEPPERS > 1 && HAS_E1_ENABLE
#define enable_e1() E1_ENABLE_WRITE( E_ENABLE_ON)
#define disable_e1() E1_ENABLE_WRITE(!E_ENABLE_ON)
#define enable_E1() E1_ENABLE_WRITE( E_ENABLE_ON)
#define disable_E1() E1_ENABLE_WRITE(!E_ENABLE_ON)
#else
#define enable_e1() NOOP
#define disable_e1() NOOP
#define enable_E1() NOOP
#define disable_E1() NOOP
#endif
#if E_STEPPERS > 2 && HAS_E2_ENABLE
#define enable_e2() E2_ENABLE_WRITE( E_ENABLE_ON)
#define disable_e2() E2_ENABLE_WRITE(!E_ENABLE_ON)
#define enable_E2() E2_ENABLE_WRITE( E_ENABLE_ON)
#define disable_E2() E2_ENABLE_WRITE(!E_ENABLE_ON)
#else
#define enable_e2() NOOP
#define disable_e2() NOOP
#define enable_E2() NOOP
#define disable_E2() NOOP
#endif
#if E_STEPPERS > 3 && HAS_E3_ENABLE
#define enable_e3() E3_ENABLE_WRITE( E_ENABLE_ON)
#define disable_e3() E3_ENABLE_WRITE(!E_ENABLE_ON)
#define enable_E3() E3_ENABLE_WRITE( E_ENABLE_ON)
#define disable_E3() E3_ENABLE_WRITE(!E_ENABLE_ON)
#else
#define enable_e3() NOOP
#define disable_e3() NOOP
#define enable_E3() NOOP
#define disable_E3() NOOP
#endif
#if E_STEPPERS > 4 && HAS_E4_ENABLE
#define enable_e4() E4_ENABLE_WRITE( E_ENABLE_ON)
#define disable_e4() E4_ENABLE_WRITE(!E_ENABLE_ON)
#define enable_E4() E4_ENABLE_WRITE( E_ENABLE_ON)
#define disable_E4() E4_ENABLE_WRITE(!E_ENABLE_ON)
#else
#define enable_e4() NOOP
#define disable_e4() NOOP
#define enable_E4() NOOP
#define disable_E4() NOOP
#endif
#endif // !MIXING_EXTRUDER

View file

@ -6489,9 +6489,9 @@ inline void gcode_M18_M84() {
}
else {
stepper.synchronize();
if (code_seen('X')) disable_x();
if (code_seen('Y')) disable_y();
if (code_seen('Z')) disable_z();
if (code_seen('X')) disable_X();
if (code_seen('Y')) disable_Y();
if (code_seen('Z')) disable_Z();
#if ((E0_ENABLE_PIN != X_ENABLE_PIN) && (E1_ENABLE_PIN != Y_ENABLE_PIN)) // Only enable on boards that have seperate ENABLE_PINS
if (code_seen('E')) disable_e_steppers();
#endif
@ -10888,28 +10888,28 @@ void calculate_volumetric_multipliers() {
}
void enable_all_steppers() {
enable_x();
enable_y();
enable_z();
enable_e0();
enable_e1();
enable_e2();
enable_e3();
enable_e4();
enable_X();
enable_Y();
enable_Z();
enable_E0();
enable_E1();
enable_E2();
enable_E3();
enable_E4();
}
void disable_e_steppers() {
disable_e0();
disable_e1();
disable_e2();
disable_e3();
disable_e4();
disable_E0();
disable_E1();
disable_E2();
disable_E3();
disable_E4();
}
void disable_all_steppers() {
disable_x();
disable_y();
disable_z();
disable_X();
disable_Y();
disable_Z();
disable_e_steppers();
}
@ -11011,13 +11011,13 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) {
if (M600_TEST && stepper_inactive_time && ELAPSED(ms, previous_cmd_ms + stepper_inactive_time)
&& !ignore_stepper_queue && !planner.blocks_queued()) {
#if ENABLED(DISABLE_INACTIVE_X)
disable_x();
disable_X();
#endif
#if ENABLED(DISABLE_INACTIVE_Y)
disable_y();
disable_Y();
#endif
#if ENABLED(DISABLE_INACTIVE_Z)
disable_z();
disable_Z();
#endif
#if ENABLED(DISABLE_INACTIVE_E)
disable_e_steppers();
@ -11080,32 +11080,32 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) {
bool oldstatus;
#if ENABLED(SWITCHING_EXTRUDER)
oldstatus = E0_ENABLE_READ;
enable_e0();
enable_E0();
#else // !SWITCHING_EXTRUDER
switch (active_extruder) {
case 0:
oldstatus = E0_ENABLE_READ;
enable_e0();
enable_E0();
break;
#if E_STEPPERS > 1
case 1:
oldstatus = E1_ENABLE_READ;
enable_e1();
enable_E1();
break;
#if E_STEPPERS > 2
case 2:
oldstatus = E2_ENABLE_READ;
enable_e2();
enable_E2();
break;
#if E_STEPPERS > 3
case 3:
oldstatus = E3_ENABLE_READ;
enable_e3();
enable_E3();
break;
#if E_STEPPERS > 4
case 4:
oldstatus = E4_ENABLE_READ;
enable_e4();
enable_E4();
break;
#endif // E_STEPPERS > 4
#endif // E_STEPPERS > 3

View file

@ -441,13 +441,13 @@ void Planner::check_axes_activity() {
}
}
#if ENABLED(DISABLE_X)
if (!axis_active[X_AXIS]) disable_x();
if (!axis_active[X_AXIS]) disable_X();
#endif
#if ENABLED(DISABLE_Y)
if (!axis_active[Y_AXIS]) disable_y();
if (!axis_active[Y_AXIS]) disable_Y();
#endif
#if ENABLED(DISABLE_Z)
if (!axis_active[Z_AXIS]) disable_z();
if (!axis_active[Z_AXIS]) disable_Z();
#endif
#if ENABLED(DISABLE_E)
if (!axis_active[E_AXIS]) disable_e_steppers();
@ -832,29 +832,29 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
//enable active axes
#if CORE_IS_XY
if (block->steps[A_AXIS] || block->steps[B_AXIS]) {
enable_x();
enable_y();
enable_X();
enable_Y();
}
#if DISABLED(Z_LATE_ENABLE)
if (block->steps[Z_AXIS]) enable_z();
if (block->steps[Z_AXIS]) enable_Z();
#endif
#elif CORE_IS_XZ
if (block->steps[A_AXIS] || block->steps[C_AXIS]) {
enable_x();
enable_z();
enable_X();
enable_Z();
}
if (block->steps[Y_AXIS]) enable_y();
if (block->steps[Y_AXIS]) enable_Y();
#elif CORE_IS_YZ
if (block->steps[B_AXIS] || block->steps[C_AXIS]) {
enable_y();
enable_z();
enable_Y();
enable_Z();
}
if (block->steps[X_AXIS]) enable_x();
if (block->steps[X_AXIS]) enable_X();
#else
if (block->steps[X_AXIS]) enable_x();
if (block->steps[Y_AXIS]) enable_y();
if (block->steps[X_AXIS]) enable_X();
if (block->steps[Y_AXIS]) enable_Y();
#if DISABLED(Z_LATE_ENABLE)
if (block->steps[Z_AXIS]) enable_z();
if (block->steps[Z_AXIS]) enable_Z();
#endif
#endif
@ -868,22 +868,22 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
switch(extruder) {
case 0:
enable_e0();
enable_E0();
#if ENABLED(DUAL_X_CARRIAGE)
if (extruder_duplication_enabled) {
enable_e1();
enable_E1();
g_uc_extruder_last_move[1] = (BLOCK_BUFFER_SIZE) * 2;
}
#endif
g_uc_extruder_last_move[0] = (BLOCK_BUFFER_SIZE) * 2;
#if EXTRUDERS > 1
if (g_uc_extruder_last_move[1] == 0) disable_e1();
if (g_uc_extruder_last_move[1] == 0) disable_E1();
#if EXTRUDERS > 2
if (g_uc_extruder_last_move[2] == 0) disable_e2();
if (g_uc_extruder_last_move[2] == 0) disable_E2();
#if EXTRUDERS > 3
if (g_uc_extruder_last_move[3] == 0) disable_e3();
if (g_uc_extruder_last_move[3] == 0) disable_E3();
#if EXTRUDERS > 4
if (g_uc_extruder_last_move[4] == 0) disable_e4();
if (g_uc_extruder_last_move[4] == 0) disable_E4();
#endif // EXTRUDERS > 4
#endif // EXTRUDERS > 3
#endif // EXTRUDERS > 2
@ -891,51 +891,51 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
break;
#if EXTRUDERS > 1
case 1:
enable_e1();
enable_E1();
g_uc_extruder_last_move[1] = (BLOCK_BUFFER_SIZE) * 2;
if (g_uc_extruder_last_move[0] == 0) disable_e0();
if (g_uc_extruder_last_move[0] == 0) disable_E0();
#if EXTRUDERS > 2
if (g_uc_extruder_last_move[2] == 0) disable_e2();
if (g_uc_extruder_last_move[2] == 0) disable_E2();
#if EXTRUDERS > 3
if (g_uc_extruder_last_move[3] == 0) disable_e3();
if (g_uc_extruder_last_move[3] == 0) disable_E3();
#if EXTRUDERS > 4
if (g_uc_extruder_last_move[4] == 0) disable_e4();
if (g_uc_extruder_last_move[4] == 0) disable_E4();
#endif // EXTRUDERS > 4
#endif // EXTRUDERS > 3
#endif // EXTRUDERS > 2
break;
#if EXTRUDERS > 2
case 2:
enable_e2();
enable_E2();
g_uc_extruder_last_move[2] = (BLOCK_BUFFER_SIZE) * 2;
if (g_uc_extruder_last_move[0] == 0) disable_e0();
if (g_uc_extruder_last_move[1] == 0) disable_e1();
if (g_uc_extruder_last_move[0] == 0) disable_E0();
if (g_uc_extruder_last_move[1] == 0) disable_E1();
#if EXTRUDERS > 3
if (g_uc_extruder_last_move[3] == 0) disable_e3();
if (g_uc_extruder_last_move[3] == 0) disable_E3();
#if EXTRUDERS > 4
if (g_uc_extruder_last_move[4] == 0) disable_e4();
if (g_uc_extruder_last_move[4] == 0) disable_E4();
#endif
#endif
break;
#if EXTRUDERS > 3
case 3:
enable_e3();
enable_E3();
g_uc_extruder_last_move[3] = (BLOCK_BUFFER_SIZE) * 2;
if (g_uc_extruder_last_move[0] == 0) disable_e0();
if (g_uc_extruder_last_move[1] == 0) disable_e1();
if (g_uc_extruder_last_move[2] == 0) disable_e2();
if (g_uc_extruder_last_move[0] == 0) disable_E0();
if (g_uc_extruder_last_move[1] == 0) disable_E1();
if (g_uc_extruder_last_move[2] == 0) disable_E2();
#if EXTRUDERS > 4
if (g_uc_extruder_last_move[4] == 0) disable_e4();
if (g_uc_extruder_last_move[4] == 0) disable_E4();
#endif
break;
#if EXTRUDERS > 4
case 4:
enable_e4();
enable_E4();
g_uc_extruder_last_move[4] = (BLOCK_BUFFER_SIZE) * 2;
if (g_uc_extruder_last_move[0] == 0) disable_e0();
if (g_uc_extruder_last_move[1] == 0) disable_e1();
if (g_uc_extruder_last_move[2] == 0) disable_e2();
if (g_uc_extruder_last_move[3] == 0) disable_e3();
if (g_uc_extruder_last_move[0] == 0) disable_E0();
if (g_uc_extruder_last_move[1] == 0) disable_E1();
if (g_uc_extruder_last_move[2] == 0) disable_E2();
if (g_uc_extruder_last_move[3] == 0) disable_E3();
break;
#endif // EXTRUDERS > 4
#endif // EXTRUDERS > 3
@ -943,11 +943,11 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
#endif // EXTRUDERS > 1
}
#else
enable_e0();
enable_e1();
enable_e2();
enable_e3();
enable_e4();
enable_E0();
enable_E1();
enable_E2();
enable_E3();
enable_E4();
#endif
}

View file

@ -428,7 +428,7 @@ void Stepper::isr() {
#if ENABLED(Z_LATE_ENABLE)
if (current_block->steps[Z_AXIS] > 0) {
enable_z();
enable_Z();
_NEXT_ISR(2000); // Run at slow speed - 1 KHz
_ENABLE_ISRs(); // re-enable ISRs
return;
@ -986,14 +986,14 @@ void Stepper::init() {
#define _STEP_INIT(AXIS) AXIS ##_STEP_INIT
#define _WRITE_STEP(AXIS, HIGHLOW) AXIS ##_STEP_WRITE(HIGHLOW)
#define _DISABLE(axis) disable_## axis()
#define _DISABLE(AXIS) disable_## AXIS()
#define AXIS_INIT(axis, AXIS, PIN) \
#define AXIS_INIT(AXIS, PIN) \
_STEP_INIT(AXIS); \
_WRITE_STEP(AXIS, _INVERT_STEP_PIN(PIN)); \
_DISABLE(axis)
_DISABLE(AXIS)
#define E_AXIS_INIT(NUM) AXIS_INIT(e## NUM, E## NUM, E)
#define E_AXIS_INIT(NUM) AXIS_INIT(E## NUM, E)
// Init Step Pins
#if HAS_X_STEP
@ -1001,7 +1001,7 @@ void Stepper::init() {
X2_STEP_INIT;
X2_STEP_WRITE(INVERT_X_STEP_PIN);
#endif
AXIS_INIT(x, X, X);
AXIS_INIT(X, X);
#endif
#if HAS_Y_STEP
@ -1009,7 +1009,7 @@ void Stepper::init() {
Y2_STEP_INIT;
Y2_STEP_WRITE(INVERT_Y_STEP_PIN);
#endif
AXIS_INIT(y, Y, Y);
AXIS_INIT(Y, Y);
#endif
#if HAS_Z_STEP
@ -1017,7 +1017,7 @@ void Stepper::init() {
Z2_STEP_INIT;
Z2_STEP_WRITE(INVERT_Z_STEP_PIN);
#endif
AXIS_INIT(z, Z, Z);
AXIS_INIT(Z, Z);
#endif
#if HAS_E0_STEP
@ -1237,7 +1237,7 @@ void Stepper::report_positions() {
#define CYCLES_EATEN_BY_BABYSTEP 60
#define _ENABLE(axis) enable_## axis()
#define _ENABLE(AXIS) enable_## AXIS()
#define _READ_DIR(AXIS) AXIS ##_DIR_READ
#define _INVERT_DIR(AXIS) INVERT_## AXIS ##_DIR
#define _APPLY_DIR(AXIS, INVERT) AXIS ##_APPLY_DIR(INVERT, true)
@ -1298,9 +1298,10 @@ void Stepper::report_positions() {
bool z_direction = direction ^ BABYSTEP_INVERT_Z;
enable_x();
enable_y();
enable_z();
enable_X();
enable_Y();
enable_Z();
uint8_t old_x_dir_pin = X_DIR_READ,
old_y_dir_pin = Y_DIR_READ,
old_z_dir_pin = Z_DIR_READ;