Add and apply REPEAT macro (#15829)

This commit is contained in:
Scott Lahteine
2019-11-09 17:59:04 -06:00
committed by GitHub
parent 8061836e74
commit 776632c503
11 changed files with 219 additions and 387 deletions

View File

@@ -286,7 +286,8 @@ void quickstop_stepper() {
}
void enable_e_steppers() {
enable_E0(); enable_E1(); enable_E2(); enable_E3(); enable_E4(); enable_E5();
#define _ENA_E(N) enable_E##N();
REPEAT(E_STEPPERS, _ENA_E)
}
void enable_all_steppers() {
@@ -300,17 +301,14 @@ void enable_all_steppers() {
}
void disable_e_steppers() {
disable_E0(); disable_E1(); disable_E2(); disable_E3(); disable_E4(); disable_E5();
#define _DIS_E(N) disable_E##N();
REPEAT(E_STEPPERS, _DIS_E)
}
void disable_e_stepper(const uint8_t e) {
#define _CASE_DIS_E(N) case N: disable_E##N(); break;
switch (e) {
case 0: disable_E0(); break;
case 1: disable_E1(); break;
case 2: disable_E2(); break;
case 3: disable_E3(); break;
case 4: disable_E4(); break;
case 5: disable_E5(); break;
REPEAT(EXTRUDERS, _CASE_DIS_E)
}
}
@@ -547,24 +545,11 @@ void manage_inactivity(const bool ignore_stepper_queue/*=false*/) {
#else // !SWITCHING_EXTRUDER
bool oldstatus;
switch (active_extruder) {
default: oldstatus = E0_ENABLE_READ(); enable_E0(); break;
#if E_STEPPERS > 1
case 1: oldstatus = E1_ENABLE_READ(); enable_E1(); break;
#if E_STEPPERS > 2
case 2: oldstatus = E2_ENABLE_READ(); enable_E2(); break;
#if E_STEPPERS > 3
case 3: oldstatus = E3_ENABLE_READ(); enable_E3(); break;
#if E_STEPPERS > 4
case 4: oldstatus = E4_ENABLE_READ(); enable_E4(); break;
#if E_STEPPERS > 5
case 5: oldstatus = E5_ENABLE_READ(); enable_E5(); break;
#endif // E_STEPPERS > 5
#endif // E_STEPPERS > 4
#endif // E_STEPPERS > 3
#endif // E_STEPPERS > 2
#endif // E_STEPPERS > 1
default:
#define _CASE_EN(N) case N: oldstatus = E##N_ENABLE_READ(); enable_E##N(); break;
REPEAT(E_STEPPERS, _CASE_EN);
}
#endif // !SWITCHING_EXTRUDER
#endif
const float olde = current_position.e;
current_position.e += EXTRUDER_RUNOUT_EXTRUDE;
@@ -585,22 +570,8 @@ void manage_inactivity(const bool ignore_stepper_queue/*=false*/) {
}
#else // !SWITCHING_EXTRUDER
switch (active_extruder) {
case 0: E0_ENABLE_WRITE(oldstatus); break;
#if E_STEPPERS > 1
case 1: E1_ENABLE_WRITE(oldstatus); break;
#if E_STEPPERS > 2
case 2: E2_ENABLE_WRITE(oldstatus); break;
#if E_STEPPERS > 3
case 3: E3_ENABLE_WRITE(oldstatus); break;
#if E_STEPPERS > 4
case 4: E4_ENABLE_WRITE(oldstatus); break;
#if E_STEPPERS > 5
case 5: E5_ENABLE_WRITE(oldstatus); break;
#endif // E_STEPPERS > 5
#endif // E_STEPPERS > 4
#endif // E_STEPPERS > 3
#endif // E_STEPPERS > 2
#endif // E_STEPPERS > 1
#define _CASE_RESTORE(N) case N: E##N##_ENABLE_WRITE(oldstatus); break;
REPEAT(E_STEPPERS, _CASE_RESTORE);
}
#endif // !SWITCHING_EXTRUDER