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
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 219 additions and 387 deletions

View file

@ -286,7 +286,8 @@ void quickstop_stepper() {
} }
void enable_e_steppers() { 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() { void enable_all_steppers() {
@ -300,17 +301,14 @@ void enable_all_steppers() {
} }
void disable_e_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) { void disable_e_stepper(const uint8_t e) {
#define _CASE_DIS_E(N) case N: disable_E##N(); break;
switch (e) { switch (e) {
case 0: disable_E0(); break; REPEAT(EXTRUDERS, _CASE_DIS_E)
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;
} }
} }
@ -547,24 +545,11 @@ void manage_inactivity(const bool ignore_stepper_queue/*=false*/) {
#else // !SWITCHING_EXTRUDER #else // !SWITCHING_EXTRUDER
bool oldstatus; bool oldstatus;
switch (active_extruder) { switch (active_extruder) {
default: oldstatus = E0_ENABLE_READ(); enable_E0(); break; default:
#if E_STEPPERS > 1 #define _CASE_EN(N) case N: oldstatus = E##N_ENABLE_READ(); enable_E##N(); break;
case 1: oldstatus = E1_ENABLE_READ(); enable_E1(); break; REPEAT(E_STEPPERS, _CASE_EN);
#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
} }
#endif // !SWITCHING_EXTRUDER #endif
const float olde = current_position.e; const float olde = current_position.e;
current_position.e += EXTRUDER_RUNOUT_EXTRUDE; current_position.e += EXTRUDER_RUNOUT_EXTRUDE;
@ -585,22 +570,8 @@ void manage_inactivity(const bool ignore_stepper_queue/*=false*/) {
} }
#else // !SWITCHING_EXTRUDER #else // !SWITCHING_EXTRUDER
switch (active_extruder) { switch (active_extruder) {
case 0: E0_ENABLE_WRITE(oldstatus); break; #define _CASE_RESTORE(N) case N: E##N##_ENABLE_WRITE(oldstatus); break;
#if E_STEPPERS > 1 REPEAT(E_STEPPERS, _CASE_RESTORE);
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
} }
#endif // !SWITCHING_EXTRUDER #endif // !SWITCHING_EXTRUDER

View file

@ -165,6 +165,7 @@
// Macros to support option testing // Macros to support option testing
#define _CAT(a,V...) a##V #define _CAT(a,V...) a##V
#define CAT(a,V...) _CAT(a,V)
#define SWITCH_ENABLED_false 0 #define SWITCH_ENABLED_false 0
#define SWITCH_ENABLED_true 1 #define SWITCH_ENABLED_true 1
#define SWITCH_ENABLED_0 0 #define SWITCH_ENABLED_0 0
@ -229,32 +230,6 @@
#define _JOIN_1(O) (O) #define _JOIN_1(O) (O)
#define JOIN_N(N,C,V...) (DO(JOIN,C,LIST_N(N,V))) #define JOIN_N(N,C,V...) (DO(JOIN,C,LIST_N(N,V)))
// Macros for adding
#define INC_0 1
#define INC_1 2
#define INC_2 3
#define INC_3 4
#define INC_4 5
#define INC_5 6
#define INC_6 7
#define INC_7 8
#define INC_8 9
#define INCREMENT_(n) INC_##n
#define INCREMENT(n) INCREMENT_(n)
// Macros for subtracting
#define DEC_1 0
#define DEC_2 1
#define DEC_3 2
#define DEC_4 3
#define DEC_5 4
#define DEC_6 5
#define DEC_7 6
#define DEC_8 7
#define DEC_9 8
#define DECREMENT_(n) DEC_##n
#define DECREMENT(n) DECREMENT_(n)
#define NOOP (void(0)) #define NOOP (void(0))
#define CEILING(x,y) (((x) + (y) - 1) / (y)) #define CEILING(x,y) (((x) + (y) - 1) / (y))
@ -346,3 +321,127 @@
#define _MAX(V...) _MAX_N(NUM_ARGS(V), V) #define _MAX(V...) _MAX_N(NUM_ARGS(V), V)
#endif #endif
// Macros for adding
#define INC_0 1
#define INC_1 2
#define INC_2 3
#define INC_3 4
#define INC_4 5
#define INC_5 6
#define INC_6 7
#define INC_7 8
#define INC_8 9
#define INCREMENT_(n) INC_##n
#define INCREMENT(n) INCREMENT_(n)
#define ADD0(N) N
#define ADD1(N) INCREMENT_(N)
#define ADD2(N) ADD1(ADD1(N))
#define ADD3(N) ADD1(ADD2(N))
#define ADD4(N) ADD2(ADD2(N))
#define ADD5(N) ADD2(ADD3(N))
#define ADD6(N) ADD3(ADD3(N))
#define ADD7(N) ADD3(ADD4(N))
#define ADD8(N) ADD4(ADD4(N))
#define ADD9(N) ADD4(ADD5(N))
#define ADD10(N) ADD5(ADD5(N))
// Macros for subtracting
#define DEC_0 0
#define DEC_1 0
#define DEC_2 1
#define DEC_3 2
#define DEC_4 3
#define DEC_5 4
#define DEC_6 5
#define DEC_7 6
#define DEC_8 7
#define DEC_9 8
#define DECREMENT_(n) DEC_##n
#define DECREMENT(n) DECREMENT_(n)
#define SUB0(N) N
#define SUB1(N) DECREMENT_(N)
#define SUB2(N) SUB1(SUB1(N))
#define SUB3(N) SUB1(SUB2(N))
#define SUB4(N) SUB2(SUB2(N))
#define SUB5(N) SUB2(SUB3(N))
#define SUB6(N) SUB3(SUB3(N))
#define SUB7(N) SUB3(SUB4(N))
#define SUB8(N) SUB4(SUB4(N))
#define SUB9(N) SUB4(SUB5(N))
#define SUB10(N) SUB5(SUB5(N))
//
// Primitives supporting precompiler REPEAT
//
#define FIRST(a,...) a
#define SECOND(a,b,...) b
// Defer expansion
#define EMPTY()
#define DEFER(M) M EMPTY()
#define DEFER2(M) M EMPTY EMPTY()()
#define DEFER3(M) M EMPTY EMPTY EMPTY()()()
#define DEFER4(M) M EMPTY EMPTY EMPTY EMPTY()()()()
// Force define expansion
#define EVAL(V...) EVAL16(V)
#define EVAL1024(V...) EVAL512(EVAL512(V))
#define EVAL512(V...) EVAL256(EVAL256(V))
#define EVAL256(V...) EVAL128(EVAL128(V))
#define EVAL128(V...) EVAL64(EVAL64(V))
#define EVAL64(V...) EVAL32(EVAL32(V))
#define EVAL32(V...) EVAL16(EVAL16(V))
#define EVAL16(V...) EVAL8(EVAL8(V))
#define EVAL8(V...) EVAL4(EVAL4(V))
#define EVAL4(V...) EVAL2(EVAL2(V))
#define EVAL2(V...) EVAL1(EVAL1(V))
#define EVAL1(V...) V
#define IS_PROBE(V...) SECOND(V, 0) // Get the second item passed, or 0
#define PROBE() ~, 1 // Second item will be 1 if this is passed
#define _NOT_0 PROBE()
#define NOT(x) IS_PROBE(_CAT(_NOT_, x)) // NOT('0') gets '1'. Anything else gets '0'.
#define _BOOL(x) NOT(NOT(x)) // NOT('0') gets '0'. Anything else gets '1'.
#define IF_ELSE(TF) _IF_ELSE(_BOOL(TF))
#define _IF_ELSE(TF) _CAT(_IF_, TF)
#define _IF_1(V...) V _IF_1_ELSE
#define _IF_0(...) _IF_0_ELSE
#define _IF_1_ELSE(...)
#define _IF_0_ELSE(V...) V
#define HAS_ARGS(V...) _BOOL(FIRST(_END_OF_ARGUMENTS_ V)())
#define _END_OF_ARGUMENTS_() 0
//
// REPEAT core macros. Recurse N times with ascending I.
//
// Call OP(I) N times with ascending counter.
#define _REPEAT(_RPT_I,_RPT_N,_RPT_OP) \
_RPT_OP(_RPT_I) \
IF_ELSE(SUB1(_RPT_N)) \
( DEFER2(__REPEAT)()(ADD1(_RPT_I),SUB1(_RPT_N),_RPT_OP) ) \
( /* Do nothing */ )
#define __REPEAT() _REPEAT
// Call OP(I, ...) N times with ascending counter.
#define _REPEAT2(_RPT_I,_RPT_N,_RPT_OP,V...) \
_RPT_OP(_RPT_I,V) \
IF_ELSE(SUB1(_RPT_N)) \
( DEFER2(__REPEAT2)()(ADD1(_RPT_I),SUB1(_RPT_N),_RPT_OP,V) ) \
( /* Do nothing */ )
#define __REPEAT2() _REPEAT2
// Repeat a macro passing S...N-1.
#define REPEAT_S(S,N,OP) EVAL(_REPEAT(S,SUB##S(N),OP))
#define REPEAT(N,OP) REPEAT_S(0,N,OP)
// Repeat a macro passing 0...N-1 plus additional arguments.
#define REPEAT2_S(S,N,OP,V...) EVAL(_REPEAT2(S,SUB##S(N),OP,V))
#define REPEAT2(N,OP,V...) REPEAT2_S(0,N,OP,V)

View file

@ -56,23 +56,9 @@ void controllerfan_update() {
|| Z3_ENABLE_READ() == Z_ENABLE_ON || Z3_ENABLE_READ() == Z_ENABLE_ON
#endif #endif
#if E_STEPPERS #if E_STEPPERS
|| E0_ENABLE_READ() == E_ENABLE_ON #define _OR_ENABLED_E(N) || E##N##_ENABLE_READ() == E_ENABLE_ON
#if E_STEPPERS > 1 REPEAT(E_STEPPERS, _OR_ENABLED_E)
|| E1_ENABLE_READ() == E_ENABLE_ON #endif
#if E_STEPPERS > 2
|| E2_ENABLE_READ() == E_ENABLE_ON
#if E_STEPPERS > 3
|| E3_ENABLE_READ() == E_ENABLE_ON
#if E_STEPPERS > 4
|| E4_ENABLE_READ() == E_ENABLE_ON
#if E_STEPPERS > 5
|| E5_ENABLE_READ() == E_ENABLE_ON
#endif // E_STEPPERS > 5
#endif // E_STEPPERS > 4
#endif // E_STEPPERS > 3
#endif // E_STEPPERS > 2
#endif // E_STEPPERS > 1
#endif // E_STEPPERS
) { ) {
lastMotorOn = ms; //... set time to NOW so the fan will turn on lastMotorOn = ms; //... set time to NOW so the fan will turn on
} }

View file

@ -59,33 +59,19 @@ bool Power::is_power_needed() {
#if HAS_HEATED_BED #if HAS_HEATED_BED
|| thermalManager.temp_bed.soft_pwm_amount > 0 || thermalManager.temp_bed.soft_pwm_amount > 0
#endif #endif
#if HAS_X2_ENABLE #if HAS_X2_ENABLE
|| X2_ENABLE_READ() == X_ENABLE_ON || X2_ENABLE_READ() == X_ENABLE_ON
#endif #endif
#if HAS_Y2_ENABLE #if HAS_Y2_ENABLE
|| Y2_ENABLE_READ() == Y_ENABLE_ON || Y2_ENABLE_READ() == Y_ENABLE_ON
#endif #endif
#if HAS_Z2_ENABLE #if HAS_Z2_ENABLE
|| Z2_ENABLE_READ() == Z_ENABLE_ON || Z2_ENABLE_READ() == Z_ENABLE_ON
#endif #endif
#if E_STEPPERS #if E_STEPPERS
|| E0_ENABLE_READ() == E_ENABLE_ON #define _OR_ENABLED_E(N) || E##N##_ENABLE_READ() == E_ENABLE_ON
#if E_STEPPERS > 1 REPEAT(E_STEPPERS, _OR_ENABLED_E)
|| E1_ENABLE_READ() == E_ENABLE_ON #endif
#if E_STEPPERS > 2
|| E2_ENABLE_READ() == E_ENABLE_ON
#if E_STEPPERS > 3
|| E3_ENABLE_READ() == E_ENABLE_ON
#if E_STEPPERS > 4
|| E4_ENABLE_READ() == E_ENABLE_ON
#if E_STEPPERS > 5
|| E5_ENABLE_READ() == E_ENABLE_ON
#endif // E_STEPPERS > 5
#endif // E_STEPPERS > 4
#endif // E_STEPPERS > 3
#endif // E_STEPPERS > 2
#endif // E_STEPPERS > 1
#endif // E_STEPPERS
) return true; ) return true;
HOTEND_LOOP() if (thermalManager.degTargetHotend(e) > 0) return true; HOTEND_LOOP() if (thermalManager.degTargetHotend(e) > 0) return true;

View file

@ -79,20 +79,7 @@ void GcodeSuite::M164() {
// Get mixing parameters from the GCode // Get mixing parameters from the GCode
// The total "must" be 1.0 (but it will be normalized) // The total "must" be 1.0 (but it will be normalized)
// If no mix factors are given, the old mix is preserved // If no mix factors are given, the old mix is preserved
const char mixing_codes[] = { 'A', 'B' const char mixing_codes[] = { LIST_N(MIXING_STEPPERS, 'A', 'B', 'C', 'D', 'H', 'I') };
#if MIXING_STEPPERS > 2
, 'C'
#if MIXING_STEPPERS > 3
, 'D'
#if MIXING_STEPPERS > 4
, 'H'
#if MIXING_STEPPERS > 5
, 'I'
#endif // MIXING_STEPPERS > 5
#endif // MIXING_STEPPERS > 4
#endif // MIXING_STEPPERS > 3
#endif // MIXING_STEPPERS > 2
};
uint8_t mix_bits = 0; uint8_t mix_bits = 0;
MIXER_STEPPER_LOOP(i) { MIXER_STEPPER_LOOP(i) {
if (parser.seenval(mixing_codes[i])) { if (parser.seenval(mixing_codes[i])) {

View file

@ -1017,7 +1017,7 @@
#define HAS_TEMP_ADC_BED HAS_ADC_TEST(BED) #define HAS_TEMP_ADC_BED HAS_ADC_TEST(BED)
#define HAS_TEMP_ADC_CHAMBER HAS_ADC_TEST(CHAMBER) #define HAS_TEMP_ADC_CHAMBER HAS_ADC_TEST(CHAMBER)
#define HAS_TEMP_HOTEND (HAS_TEMP_ADC_0 || ENABLED(HEATER_0_USES_MAX6675)) #define HAS_TEMP_HOTEND (HOTENDS > 0 && (HAS_TEMP_ADC_0 || ENABLED(HEATER_0_USES_MAX6675)))
#define HAS_TEMP_BED HAS_TEMP_ADC_BED #define HAS_TEMP_BED HAS_TEMP_ADC_BED
#define HAS_TEMP_CHAMBER HAS_TEMP_ADC_CHAMBER #define HAS_TEMP_CHAMBER HAS_TEMP_ADC_CHAMBER
#define HAS_HEATED_CHAMBER (HAS_TEMP_CHAMBER && PIN_EXISTS(HEATER_CHAMBER)) #define HAS_HEATED_CHAMBER (HAS_TEMP_CHAMBER && PIN_EXISTS(HEATER_CHAMBER))

View file

@ -85,22 +85,8 @@ bool TemperatureScreen::onTouchHeld(uint8_t tag) {
case 11: UI_INCREMENT(TargetFan_percent, FAN0); break; case 11: UI_INCREMENT(TargetFan_percent, FAN0); break;
#endif #endif
case 30: case 30:
setTargetTemp_celsius(0,E0); #define _HOTEND_OFF(N) setTargetTemp_celsius(0,E##N);
#if HOTENDS > 1 REPEAT(HOTENDS, _HOTEND_OFF);
setTargetTemp_celsius(0,E1);
#if HOTENDS > 2
setTargetTemp_celsius(0,E2);
#if HOTENDS > 3
setTargetTemp_celsius(0,E3);
#if HOTENDS > 4
setTargetTemp_celsius(0,E4);
#if HOTENDS > 5
setTargetTemp_celsius(0,E5);
#endif
#endif
#endif
#endif
#endif
#if HAS_HEATED_BED #if HAS_HEATED_BED
setTargetTemp_celsius(0,BED); setTargetTemp_celsius(0,BED);
#endif #endif

View file

@ -277,8 +277,10 @@ void menu_advanced_settings();
#if DISABLED(SLIM_LCD_MENUS) #if DISABLED(SLIM_LCD_MENUS)
void _menu_configuration_preheat_settings(const uint8_t material) { void _menu_configuration_preheat_settings(const uint8_t material) {
#define MINTEMP_ALL _MIN(LIST_N(HOTENDS, HEATER_0_MINTEMP, HEATER_1_MINTEMP, HEATER_2_MINTEMP, HEATER_3_MINTEMP, HEATER_4_MINTEMP, HEATER_5_MINTEMP), 999) #define _MINTEMP_ITEM(N) HEATER_##N##_MINTEMP,
#define MAXTEMP_ALL _MAX(LIST_N(HOTENDS, HEATER_0_MAXTEMP, HEATER_1_MAXTEMP, HEATER_2_MAXTEMP, HEATER_3_MAXTEMP, HEATER_4_MAXTEMP, HEATER_5_MAXTEMP), 0) #define _MAXTEMP_ITEM(N) HEATER_##N##_MAXTEMP,
#define MINTEMP_ALL _MIN(REPEAT(HOTENDS, _MINTEMP_ITEM) 999)
#define MAXTEMP_ALL _MAX(REPEAT(HOTENDS, _MAXTEMP_ITEM) 0)
START_MENU(); START_MENU();
BACK_ITEM(MSG_CONFIGURATION); BACK_ITEM(MSG_CONFIGURATION);
EDIT_ITEM(percent, MSG_FAN_SPEED, &ui.preheat_fan_speed[material], 0, 255); EDIT_ITEM(percent, MSG_FAN_SPEED, &ui.preheat_fan_speed[material], 0, 255);

View file

@ -158,10 +158,11 @@ void lcd_mixer_mix_edit() {
#if CHANNEL_MIX_EDITING #if CHANNEL_MIX_EDITING
#define EDIT_COLOR(N) EDIT_ITEM_FAST(float52, MSG_MIX_COMPONENT_##N, &mixer.collector[N-1], 0, 10);
START_MENU(); START_MENU();
BACK_ITEM(MSG_MIXER); BACK_ITEM(MSG_MIXER);
#define EDIT_COLOR(N) EDIT_ITEM_FAST(float52, MSG_MIX_COMPONENT_##N, &mixer.collector[N-1], 0, 10);
EDIT_COLOR(1); EDIT_COLOR(1);
EDIT_COLOR(2); EDIT_COLOR(2);
#if MIXING_STEPPERS > 2 #if MIXING_STEPPERS > 2
@ -176,6 +177,7 @@ void lcd_mixer_mix_edit() {
#endif #endif
#endif #endif
#endif #endif
ACTION_ITEM(MSG_CYCLE_MIX, _lcd_mixer_cycle_mix); ACTION_ITEM(MSG_CYCLE_MIX, _lcd_mixer_cycle_mix);
ACTION_ITEM(MSG_COMMIT_VTOOL, _lcd_mixer_commit_vtool); ACTION_ITEM(MSG_COMMIT_VTOOL, _lcd_mixer_commit_vtool);
END_MENU(); END_MENU();

View file

@ -1924,121 +1924,32 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
#if ENABLED(DISABLE_INACTIVE_EXTRUDER) // Enable only the selected extruder #if ENABLED(DISABLE_INACTIVE_EXTRUDER) // Enable only the selected extruder
#define DISABLE_IDLE_E(N) if (!g_uc_extruder_last_move[N]) disable_E##N();
for (uint8_t i = 0; i < EXTRUDERS; i++) for (uint8_t i = 0; i < EXTRUDERS; i++)
if (g_uc_extruder_last_move[i] > 0) g_uc_extruder_last_move[i]--; if (g_uc_extruder_last_move[i] > 0) g_uc_extruder_last_move[i]--;
switch (extruder) { #if HAS_DUPLICATION_MODE
case 0: if (extruder_duplication_enabled && extruder == 0) {
#if EXTRUDERS > 1 enable_E1();
DISABLE_IDLE_E(1); g_uc_extruder_last_move[1] = (BLOCK_BUFFER_SIZE) * 2;
#if EXTRUDERS > 2 }
DISABLE_IDLE_E(2); #endif
#if EXTRUDERS > 3
DISABLE_IDLE_E(3); #define ENABLE_ONE_E(N) do{ \
#if EXTRUDERS > 4 if (extruder == N) { \
DISABLE_IDLE_E(4); enable_E##N(); \
#if EXTRUDERS > 5 g_uc_extruder_last_move[N] = (BLOCK_BUFFER_SIZE) * 2; \
DISABLE_IDLE_E(5); } \
#endif // EXTRUDERS > 5 else if (!g_uc_extruder_last_move[N]) \
#endif // EXTRUDERS > 4 disable_E##N(); \
#endif // EXTRUDERS > 3 }while(0);
#endif // EXTRUDERS > 2
#endif // EXTRUDERS > 1
enable_E0();
g_uc_extruder_last_move[0] = (BLOCK_BUFFER_SIZE) * 2;
#if HAS_DUPLICATION_MODE
if (extruder_duplication_enabled) {
enable_E1();
g_uc_extruder_last_move[1] = (BLOCK_BUFFER_SIZE) * 2;
}
#endif
break;
#if EXTRUDERS > 1
case 1:
DISABLE_IDLE_E(0);
#if EXTRUDERS > 2
DISABLE_IDLE_E(2);
#if EXTRUDERS > 3
DISABLE_IDLE_E(3);
#if EXTRUDERS > 4
DISABLE_IDLE_E(4);
#if EXTRUDERS > 5
DISABLE_IDLE_E(5);
#endif // EXTRUDERS > 5
#endif // EXTRUDERS > 4
#endif // EXTRUDERS > 3
#endif // EXTRUDERS > 2
enable_E1();
g_uc_extruder_last_move[1] = (BLOCK_BUFFER_SIZE) * 2;
break;
#if EXTRUDERS > 2
case 2:
DISABLE_IDLE_E(0);
DISABLE_IDLE_E(1);
#if EXTRUDERS > 3
DISABLE_IDLE_E(3);
#if EXTRUDERS > 4
DISABLE_IDLE_E(4);
#if EXTRUDERS > 5
DISABLE_IDLE_E(5);
#endif
#endif
#endif
enable_E2();
g_uc_extruder_last_move[2] = (BLOCK_BUFFER_SIZE) * 2;
break;
#if EXTRUDERS > 3
case 3:
DISABLE_IDLE_E(0);
DISABLE_IDLE_E(1);
DISABLE_IDLE_E(2);
#if EXTRUDERS > 4
DISABLE_IDLE_E(4);
#if EXTRUDERS > 5
DISABLE_IDLE_E(5);
#endif
#endif
enable_E3();
g_uc_extruder_last_move[3] = (BLOCK_BUFFER_SIZE) * 2;
break;
#if EXTRUDERS > 4
case 4:
DISABLE_IDLE_E(0);
DISABLE_IDLE_E(1);
DISABLE_IDLE_E(2);
DISABLE_IDLE_E(3);
#if EXTRUDERS > 5
DISABLE_IDLE_E(5);
#endif
enable_E4();
g_uc_extruder_last_move[4] = (BLOCK_BUFFER_SIZE) * 2;
break;
#if EXTRUDERS > 5
case 5:
DISABLE_IDLE_E(0);
DISABLE_IDLE_E(1);
DISABLE_IDLE_E(2);
DISABLE_IDLE_E(3);
DISABLE_IDLE_E(4);
enable_E5();
g_uc_extruder_last_move[5] = (BLOCK_BUFFER_SIZE) * 2;
break;
#endif // EXTRUDERS > 5
#endif // EXTRUDERS > 4
#endif // EXTRUDERS > 3
#endif // EXTRUDERS > 2
#endif // EXTRUDERS > 1
}
#else #else
enable_E0();
enable_E1(); #define ENABLE_ONE_E(N) enable_E##N();
enable_E2();
enable_E3();
enable_E4();
enable_E5();
#endif #endif
REPEAT(EXTRUDERS, ENABLE_ONE_E);
} }
#endif // EXTRUDERS #endif // EXTRUDERS

View file

@ -628,31 +628,31 @@ int16_t Temperature::getHeaterPower(const heater_ind_t heater_id) {
#define CHAMBER_FAN_INDEX HOTENDS #define CHAMBER_FAN_INDEX HOTENDS
void Temperature::checkExtruderAutoFans() { void Temperature::checkExtruderAutoFans() {
#define _EFAN(A,B) _EFANOVERLAP(A,B) ? B : #define _EFAN(B,A) _EFANOVERLAP(A,B) ? B :
static const uint8_t fanBit[] PROGMEM = { static const uint8_t fanBit[] PROGMEM = {
0 0
#if HOTENDS > 1 #if HOTENDS > 1
, _EFAN(1,0) 1 , REPEAT2(1,_EFAN,1) 1
#endif #if HOTENDS > 2
#if HOTENDS > 2 , REPEAT2(2,_EFAN,2) 2
, _EFAN(2,0) _EFAN(2,1) 2 #if HOTENDS > 3
#endif , REPEAT2(3,_EFAN,3) 3
#if HOTENDS > 3 #if HOTENDS > 4
, _EFAN(3,0) _EFAN(3,1) _EFAN(3,2) 3 , REPEAT2(4,_EFAN,4) 4
#endif #if HOTENDS > 5
#if HOTENDS > 4 , REPEAT2(5,_EFAN,5) 5
, _EFAN(4,0) _EFAN(4,1) _EFAN(4,2) _EFAN(4,3) 4 #endif
#endif #endif
#if HOTENDS > 5 #endif
, _EFAN(5,0) _EFAN(5,1) _EFAN(5,2) _EFAN(5,3) _EFAN(5,4) 5 #endif
#endif #endif
#if HAS_AUTO_CHAMBER_FAN #if HAS_AUTO_CHAMBER_FAN
#define _CFAN(B) _FANOVERLAP(CHAMBER,B) ? B : #define _CFAN(B) _FANOVERLAP(CHAMBER,B) ? B :
, _CFAN(0) _CFAN(1) _CFAN(2) _CFAN(3) _CFAN(4) _CFAN(5) 6 , REPEAT(HOTENDS,_CFAN) (HOTENDS)
#endif #endif
}; };
uint8_t fanState = 0;
uint8_t fanState = 0;
HOTEND_LOOP() HOTEND_LOOP()
if (temp_hotend[e].celsius >= EXTRUDER_AUTO_FAN_TEMPERATURE) if (temp_hotend[e].celsius >= EXTRUDER_AUTO_FAN_TEMPERATURE)
SBI(fanState, pgm_read_byte(&fanBit[e])); SBI(fanState, pgm_read_byte(&fanBit[e]));
@ -1953,22 +1953,7 @@ void Temperature::disable_all_heaters() {
} }
#if HAS_TEMP_HOTEND #if HAS_TEMP_HOTEND
DISABLE_HEATER(0); REPEAT(HOTENDS, DISABLE_HEATER);
#if HOTENDS > 1
DISABLE_HEATER(1);
#if HOTENDS > 2
DISABLE_HEATER(2);
#if HOTENDS > 3
DISABLE_HEATER(3);
#if HOTENDS > 4
DISABLE_HEATER(4);
#if HOTENDS > 5
DISABLE_HEATER(5);
#endif // HOTENDS > 5
#endif // HOTENDS > 4
#endif // HOTENDS > 3
#endif // HOTENDS > 2
#endif // HOTENDS > 1
#endif #endif
#if HAS_HEATED_BED #if HAS_HEATED_BED
@ -2223,22 +2208,14 @@ void Temperature::readings_ready() {
TEMPDIR(0) TEMPDIR(0)
#endif #endif
#if HOTENDS > 1 #if HOTENDS > 1
#define _TEMPDIR(N) , TEMPDIR(N)
#if ENABLED(HEATER_1_USES_MAX6675) #if ENABLED(HEATER_1_USES_MAX6675)
, 0 , 0
#else #else
, TEMPDIR(1) _TEMPDIR(1)
#endif #endif
#if HOTENDS > 2 #if HOTENDS > 2
, TEMPDIR(2) REPEAT_S(2, HOTENDS, _TEMPDIR)
#if HOTENDS > 3
, TEMPDIR(3)
#if HOTENDS > 4
, TEMPDIR(4)
#if HOTENDS > 5
, TEMPDIR(5)
#endif // HOTENDS > 5
#endif // HOTENDS > 4
#endif // HOTENDS > 3
#endif // HOTENDS > 2 #endif // HOTENDS > 2
#endif // HOTENDS > 1 #endif // HOTENDS > 1
}; };
@ -2391,24 +2368,9 @@ void Temperature::isr() {
pwm_count_tmp -= 127; pwm_count_tmp -= 127;
#if HOTENDS #if HOTENDS
#define _PWM_MOD_E(N) _PWM_MOD(N,soft_pwm_hotend[N],temp_hotend[N]) #define _PWM_MOD_E(N) _PWM_MOD(N,soft_pwm_hotend[N],temp_hotend[N]);
_PWM_MOD_E(0); REPEAT(HOTENDS, _PWM_MOD_E);
#if HOTENDS > 1 #endif
_PWM_MOD_E(1);
#if HOTENDS > 2
_PWM_MOD_E(2);
#if HOTENDS > 3
_PWM_MOD_E(3);
#if HOTENDS > 4
_PWM_MOD_E(4);
#if HOTENDS > 5
_PWM_MOD_E(5);
#endif // HOTENDS > 5
#endif // HOTENDS > 4
#endif // HOTENDS > 3
#endif // HOTENDS > 2
#endif // HOTENDS > 1
#endif // HOTENDS
#if HAS_HEATED_BED #if HAS_HEATED_BED
_PWM_MOD(BED,soft_pwm_bed,temp_bed); _PWM_MOD(BED,soft_pwm_bed,temp_bed);
@ -2438,24 +2400,9 @@ void Temperature::isr() {
else { else {
#define _PWM_LOW(N,S) do{ if (S.count <= pwm_count_tmp) WRITE_HEATER_##N(LOW); }while(0) #define _PWM_LOW(N,S) do{ if (S.count <= pwm_count_tmp) WRITE_HEATER_##N(LOW); }while(0)
#if HOTENDS #if HOTENDS
#define _PWM_LOW_E(N) _PWM_LOW(N, soft_pwm_hotend[N]) #define _PWM_LOW_E(N) _PWM_LOW(N, soft_pwm_hotend[N]);
_PWM_LOW_E(0); REPEAT(HOTENDS, _PWM_LOW_E);
#if HOTENDS > 1 #endif
_PWM_LOW_E(1);
#if HOTENDS > 2
_PWM_LOW_E(2);
#if HOTENDS > 3
_PWM_LOW_E(3);
#if HOTENDS > 4
_PWM_LOW_E(4);
#if HOTENDS > 5
_PWM_LOW_E(5);
#endif // HOTENDS > 5
#endif // HOTENDS > 4
#endif // HOTENDS > 3
#endif // HOTENDS > 2
#endif // HOTENDS > 1
#endif // HOTENDS
#if HAS_HEATED_BED #if HAS_HEATED_BED
_PWM_LOW(BED, soft_pwm_bed); _PWM_LOW(BED, soft_pwm_bed);
@ -2504,24 +2451,9 @@ void Temperature::isr() {
if (slow_pwm_count == 0) { if (slow_pwm_count == 0) {
#if HOTENDS #if HOTENDS
#define _SLOW_PWM_E(N) _SLOW_PWM(N, soft_pwm_hotend[N], temp_hotend[N]) #define _SLOW_PWM_E(N) _SLOW_PWM(N, soft_pwm_hotend[N], temp_hotend[N]);
_SLOW_PWM_E(0); REPEAT(HOTENDS, _SLOW_PWM_E);
#if HOTENDS > 1 #endif
_SLOW_PWM_E(1);
#if HOTENDS > 2
_SLOW_PWM_E(2);
#if HOTENDS > 3
_SLOW_PWM_E(3);
#if HOTENDS > 4
_SLOW_PWM_E(4);
#if HOTENDS > 5
_SLOW_PWM_E(5);
#endif // HOTENDS > 5
#endif // HOTENDS > 4
#endif // HOTENDS > 3
#endif // HOTENDS > 2
#endif // HOTENDS > 1
#endif // HOTENDS
#if HAS_HEATED_BED #if HAS_HEATED_BED
_SLOW_PWM(BED, soft_pwm_bed, temp_bed); _SLOW_PWM(BED, soft_pwm_bed, temp_bed);
@ -2531,23 +2463,8 @@ void Temperature::isr() {
#if HOTENDS #if HOTENDS
#define _PWM_OFF_E(N) _PWM_OFF(N, soft_pwm_hotend[N]); #define _PWM_OFF_E(N) _PWM_OFF(N, soft_pwm_hotend[N]);
_PWM_OFF_E(0); REPEAT(HOTENDS, _PWM_OFF_E);
#if HOTENDS > 1 #endif
_PWM_OFF_E(1);
#if HOTENDS > 2
_PWM_OFF_E(2);
#if HOTENDS > 3
_PWM_OFF_E(3);
#if HOTENDS > 4
_PWM_OFF_E(4);
#if HOTENDS > 5
_PWM_OFF_E(5);
#endif // HOTENDS > 5
#endif // HOTENDS > 4
#endif // HOTENDS > 3
#endif // HOTENDS > 2
#endif // HOTENDS > 1
#endif // HOTENDS
#if HAS_HEATED_BED #if HAS_HEATED_BED
_PWM_OFF(BED, soft_pwm_bed); _PWM_OFF(BED, soft_pwm_bed);
@ -2598,23 +2515,8 @@ void Temperature::isr() {
slow_pwm_count &= 0x7F; slow_pwm_count &= 0x7F;
#if HOTENDS #if HOTENDS
soft_pwm_hotend[0].dec(); HOTEND_LOOP() soft_pwm_hotend[e].dec();
#if HOTENDS > 1 #endif
soft_pwm_hotend[1].dec();
#if HOTENDS > 2
soft_pwm_hotend[2].dec();
#if HOTENDS > 3
soft_pwm_hotend[3].dec();
#if HOTENDS > 4
soft_pwm_hotend[4].dec();
#if HOTENDS > 5
soft_pwm_hotend[5].dec();
#endif // HOTENDS > 5
#endif // HOTENDS > 4
#endif // HOTENDS > 3
#endif // HOTENDS > 2
#endif // HOTENDS > 1
#endif // HOTENDS
#if HAS_HEATED_BED #if HAS_HEATED_BED
soft_pwm_bed.dec(); soft_pwm_bed.dec();
#endif #endif