Apply REPEAT, RREPEAT, and loop macros (#16757)

This commit is contained in:
Scott Lahteine 2020-02-01 21:00:53 -06:00 committed by GitHub
parent 0e72c315a0
commit 4716dac874
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 82 additions and 221 deletions

View File

@ -457,3 +457,21 @@
// Repeat a macro passing 0...N-1 plus additional arguments. // 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_S(S,N,OP,V...) EVAL(_REPEAT2(S,SUB##S(N),OP,V))
#define REPEAT2(N,OP,V...) REPEAT2_S(0,N,OP,V) #define REPEAT2(N,OP,V...) REPEAT2_S(0,N,OP,V)
// Use RREPEAT macros with REPEAT macros for nesting
#define _RREPEAT(_RPT_I,_RPT_N,_RPT_OP) \
_RPT_OP(_RPT_I) \
IF_ELSE(SUB1(_RPT_N)) \
( DEFER2(__RREPEAT)()(ADD1(_RPT_I),SUB1(_RPT_N),_RPT_OP) ) \
( /* Do nothing */ )
#define __RREPEAT() _RREPEAT
#define _RREPEAT2(_RPT_I,_RPT_N,_RPT_OP,V...) \
_RPT_OP(_RPT_I,V) \
IF_ELSE(SUB1(_RPT_N)) \
( DEFER2(__RREPEAT2)()(ADD1(_RPT_I),SUB1(_RPT_N),_RPT_OP,V) ) \
( /* Do nothing */ )
#define __RREPEAT2() _RREPEAT2
#define RREPEAT_S(S,N,OP) EVAL(_RREPEAT(S,SUB##S(N),OP))
#define RREPEAT(N,OP) RREPEAT_S(0,N,OP)
#define RREPEAT2_S(S,N,OP,V...) EVAL(_RREPEAT2(S,SUB##S(N),OP,V))
#define RREPEAT2(N,OP,V...) RREPEAT2_S(0,N,OP,V)

View File

@ -139,56 +139,28 @@ class FilamentSensorBase {
#define INIT_RUNOUT_PIN(P) SET_INPUT(P) #define INIT_RUNOUT_PIN(P) SET_INPUT(P)
#endif #endif
INIT_RUNOUT_PIN(FIL_RUNOUT_PIN); #define _INIT_RUNOUT(N) INIT_RUNOUT_PIN(FIL_RUNOUT##N##_PIN);
#if NUM_RUNOUT_SENSORS > 1 REPEAT_S(1, INCREMENT(NUM_RUNOUT_SENSORS), _INIT_RUNOUT)
INIT_RUNOUT_PIN(FIL_RUNOUT2_PIN); #undef _INIT_RUNOUT
#if NUM_RUNOUT_SENSORS > 2
INIT_RUNOUT_PIN(FIL_RUNOUT3_PIN);
#if NUM_RUNOUT_SENSORS > 3
INIT_RUNOUT_PIN(FIL_RUNOUT4_PIN);
#if NUM_RUNOUT_SENSORS > 4
INIT_RUNOUT_PIN(FIL_RUNOUT5_PIN);
#if NUM_RUNOUT_SENSORS > 5
INIT_RUNOUT_PIN(FIL_RUNOUT6_PIN);
#endif
#endif
#endif
#endif
#endif
} }
// Return a bitmask of runout pin states // Return a bitmask of runout pin states
static inline uint8_t poll_runout_pins() { static inline uint8_t poll_runout_pins() {
return ( #define _OR_RUNOUT(N) | (READ(FIL_RUNOUT##N##_PIN) ? _BV((N) - 1) : 0)
(READ(FIL_RUNOUT_PIN ) ? _BV(0) : 0) return (0 REPEAT_S(1, INCREMENT(NUM_RUNOUT_SENSORS), _OR_RUNOUT));
#if NUM_RUNOUT_SENSORS > 1 #undef _OR_RUNOUT
| (READ(FIL_RUNOUT2_PIN) ? _BV(1) : 0)
#if NUM_RUNOUT_SENSORS > 2
| (READ(FIL_RUNOUT3_PIN) ? _BV(2) : 0)
#if NUM_RUNOUT_SENSORS > 3
| (READ(FIL_RUNOUT4_PIN) ? _BV(3) : 0)
#if NUM_RUNOUT_SENSORS > 4
| (READ(FIL_RUNOUT5_PIN) ? _BV(4) : 0)
#if NUM_RUNOUT_SENSORS > 5
| (READ(FIL_RUNOUT6_PIN) ? _BV(5) : 0)
#endif
#endif
#endif
#endif
#endif
);
} }
// Return a bitmask of runout flag states (1 bits always indicates runout) // Return a bitmask of runout flag states (1 bits always indicates runout)
static inline uint8_t poll_runout_states() { static inline uint8_t poll_runout_states() {
return poll_runout_pins() ^ uint8_t( return (poll_runout_pins()
#if DISABLED(FIL_RUNOUT_INVERTING) #if DISABLED(FIL_RUNOUT_INVERTING)
_BV(NUM_RUNOUT_SENSORS) - 1 ^ uint8_t(_BV(NUM_RUNOUT_SENSORS) - 1)
#else
0
#endif #endif
); );
} }
#undef INIT_RUNOUT_PIN
}; };
#if ENABLED(FILAMENT_MOTION_SENSOR) #if ENABLED(FILAMENT_MOTION_SENSOR)

View File

@ -94,13 +94,8 @@
SERIAL_ECHOPAIR(" Y2:", endstops.y2_endstop_adj); SERIAL_ECHOPAIR(" Y2:", endstops.y2_endstop_adj);
#endif #endif
#if ENABLED(Z_MULTI_ENDSTOPS) #if ENABLED(Z_MULTI_ENDSTOPS)
SERIAL_ECHOPAIR(" Z2:", endstops.z2_endstop_adj); #define _ECHO_ZADJ(N) SERIAL_ECHOPAIR(" Z" STRINGIFY(N) ":", endstops.z##N##_endstop_adj);
#if NUM_Z_STEPPER_DRIVERS >= 3 REPEAT_S(2, INCREMENT(NUM_Z_STEPPER_DRIVERS), _ECHO_ZADJ)
SERIAL_ECHOPAIR(" Z3:", endstops.z3_endstop_adj);
#if NUM_Z_STEPPER_DRIVERS >= 4
SERIAL_ECHOPAIR(" Z4:", endstops.z4_endstop_adj);
#endif
#endif
#endif #endif
SERIAL_EOL(); SERIAL_EOL();
} }

View File

@ -68,7 +68,7 @@ void GcodeSuite::M301() {
SERIAL_ECHO_START(); SERIAL_ECHO_START();
#if ENABLED(PID_PARAMS_PER_HOTEND) #if ENABLED(PID_PARAMS_PER_HOTEND)
SERIAL_ECHOPAIR(" e:", e); // specify extruder in serial output SERIAL_ECHOPAIR(" e:", e); // specify extruder in serial output
#endif // PID_PARAMS_PER_HOTEND #endif
SERIAL_ECHOPAIR(" p:", PID_PARAM(Kp, e), SERIAL_ECHOPAIR(" p:", PID_PARAM(Kp, e),
" i:", unscalePID_i(PID_PARAM(Ki, e)), " i:", unscalePID_i(PID_PARAM(Ki, e)),
" d:", unscalePID_d(PID_PARAM(Kd, e))); " d:", unscalePID_d(PID_PARAM(Kd, e)));

View File

@ -228,35 +228,17 @@ void menu_cancelobject();
#if ENABLED(PID_AUTOTUNE_MENU) #if ENABLED(PID_AUTOTUNE_MENU)
#define DEFINE_PIDTEMP_FUNCS(N) \ #define DEFINE_PIDTEMP_FUNCS(N) \
_DEFINE_PIDTEMP_BASE_FUNCS(N); \ _DEFINE_PIDTEMP_BASE_FUNCS(N); \
void lcd_autotune_callback_E##N() { _lcd_autotune(N); } // void lcd_autotune_callback_E##N() { _lcd_autotune(N); }
#else #else
#define DEFINE_PIDTEMP_FUNCS(N) _DEFINE_PIDTEMP_BASE_FUNCS(N); // #define DEFINE_PIDTEMP_FUNCS(N) _DEFINE_PIDTEMP_BASE_FUNCS(N);
#endif #endif
#if HOTENDS #if HOTENDS
DEFINE_PIDTEMP_FUNCS(0); DEFINE_PIDTEMP_FUNCS(0);
#if HOTENDS > 1 && ENABLED(PID_PARAMS_PER_HOTEND) #if HOTENDS > 1 && ENABLED(PID_PARAMS_PER_HOTEND)
DEFINE_PIDTEMP_FUNCS(1); REPEAT_S(1, HOTENDS, DEFINE_PIDTEMP_FUNCS)
#if HOTENDS > 2 #endif
DEFINE_PIDTEMP_FUNCS(2); #endif
#if HOTENDS > 3
DEFINE_PIDTEMP_FUNCS(3);
#if HOTENDS > 4
DEFINE_PIDTEMP_FUNCS(4);
#if HOTENDS > 5
DEFINE_PIDTEMP_FUNCS(5);
#if HOTENDS > 6
DEFINE_PIDTEMP_FUNCS(6);
#if HOTENDS > 7
DEFINE_PIDTEMP_FUNCS(7);
#endif // HOTENDS > 7
#endif // HOTENDS > 6
#endif // HOTENDS > 5
#endif // HOTENDS > 4
#endif // HOTENDS > 3
#endif // HOTENDS > 2
#endif // HOTENDS > 1 && PID_PARAMS_PER_HOTEND
#endif // HOTENDS
#define SHOW_MENU_ADVANCED_TEMPERATURE ((ENABLED(AUTOTEMP) && HAS_TEMP_HOTEND) || EITHER(PID_AUTOTUNE_MENU, PID_EDIT_MENU)) #define SHOW_MENU_ADVANCED_TEMPERATURE ((ENABLED(AUTOTEMP) && HAS_TEMP_HOTEND) || EITHER(PID_AUTOTUNE_MENU, PID_EDIT_MENU))
@ -320,33 +302,15 @@ void menu_cancelobject();
#if ENABLED(PID_AUTOTUNE_MENU) #if ENABLED(PID_AUTOTUNE_MENU)
#define PID_EDIT_MENU_ITEMS(N) \ #define PID_EDIT_MENU_ITEMS(N) \
_PID_EDIT_MENU_ITEMS(N); \ _PID_EDIT_MENU_ITEMS(N); \
EDIT_ITEM_FAST_N(int3, N, MSG_PID_AUTOTUNE_E, &autotune_temp[N], 150, heater_maxtemp[N] - 15, []{ _lcd_autotune(MenuItemBase::itemIndex); }) EDIT_ITEM_FAST_N(int3, N, MSG_PID_AUTOTUNE_E, &autotune_temp[N], 150, heater_maxtemp[N] - 15, []{ _lcd_autotune(MenuItemBase::itemIndex); });
#else #else
#define PID_EDIT_MENU_ITEMS(N) _PID_EDIT_MENU_ITEMS(N) #define PID_EDIT_MENU_ITEMS(N) _PID_EDIT_MENU_ITEMS(N);
#endif #endif
PID_EDIT_MENU_ITEMS(0); PID_EDIT_MENU_ITEMS(0);
#if HOTENDS > 1 && ENABLED(PID_PARAMS_PER_HOTEND) #if HOTENDS > 1 && ENABLED(PID_PARAMS_PER_HOTEND)
PID_EDIT_MENU_ITEMS(1); REPEAT_S(1, HOTENDS, PID_EDIT_MENU_ITEMS)
#if HOTENDS > 2 #endif
PID_EDIT_MENU_ITEMS(2);
#if HOTENDS > 3
PID_EDIT_MENU_ITEMS(3);
#if HOTENDS > 4
PID_EDIT_MENU_ITEMS(4);
#if HOTENDS > 5
PID_EDIT_MENU_ITEMS(5);
#if HOTENDS > 6
PID_EDIT_MENU_ITEMS(6);
#if HOTENDS > 7
PID_EDIT_MENU_ITEMS(7);
#endif // HOTENDS > 7
#endif // HOTENDS > 6
#endif // HOTENDS > 5
#endif // HOTENDS > 4
#endif // HOTENDS > 3
#endif // HOTENDS > 2
#endif // HOTENDS > 1 && PID_PARAMS_PER_HOTEND
END_MENU(); END_MENU();
} }

View File

@ -2667,7 +2667,7 @@ void MarlinSettings::reset() {
false false
#endif #endif
; ;
for (uint8_t q = 0; q < COUNT(planner.filament_size); q++) LOOP_L_N(q, COUNT(planner.filament_size))
planner.filament_size[q] = DEFAULT_NOMINAL_FILAMENT_DIA; planner.filament_size[q] = DEFAULT_NOMINAL_FILAMENT_DIA;
#endif #endif
@ -2730,7 +2730,7 @@ void MarlinSettings::reset() {
// //
#if ENABLED(ADVANCED_PAUSE_FEATURE) #if ENABLED(ADVANCED_PAUSE_FEATURE)
for (uint8_t e = 0; e < EXTRUDERS; e++) { LOOP_L_N(e, EXTRUDERS) {
fc_settings[e].unload_length = FILAMENT_CHANGE_UNLOAD_LENGTH; fc_settings[e].unload_length = FILAMENT_CHANGE_UNLOAD_LENGTH;
fc_settings[e].load_length = FILAMENT_CHANGE_FAST_LOAD_LENGTH; fc_settings[e].load_length = FILAMENT_CHANGE_FAST_LOAD_LENGTH;
} }
@ -2842,36 +2842,17 @@ void MarlinSettings::reset() {
SERIAL_ECHOLNPGM(" Disabled"); SERIAL_ECHOLNPGM(" Disabled");
} }
CONFIG_ECHO_START(); #if EXTRUDERS == 1
SERIAL_ECHOLNPAIR(" M200 D", LINEAR_UNIT(planner.filament_size[0]));
#if EXTRUDERS > 1
CONFIG_ECHO_START(); CONFIG_ECHO_START();
SERIAL_ECHOLNPAIR(" M200 T1 D", LINEAR_UNIT(planner.filament_size[1])); SERIAL_ECHOLNPAIR(" M200 D", LINEAR_UNIT(planner.filament_size[0]));
#if EXTRUDERS > 2 #elif EXTRUDERS
LOOP_L_N(i, EXTRUDERS) {
CONFIG_ECHO_START(); CONFIG_ECHO_START();
SERIAL_ECHOLNPAIR(" M200 T2 D", LINEAR_UNIT(planner.filament_size[2])); SERIAL_ECHOPGM(" M200");
#if EXTRUDERS > 3 if (i) SERIAL_ECHOPAIR_P(SP_T_STR, int(i));
CONFIG_ECHO_START(); SERIAL_ECHOLNPAIR(" D", LINEAR_UNIT(planner.filament_size[i]));
SERIAL_ECHOLNPAIR(" M200 T3 D", LINEAR_UNIT(planner.filament_size[3])); }
#if EXTRUDERS > 4 #endif
CONFIG_ECHO_START();
SERIAL_ECHOLNPAIR(" M200 T4 D", LINEAR_UNIT(planner.filament_size[4]));
#if EXTRUDERS > 5
CONFIG_ECHO_START();
SERIAL_ECHOLNPAIR(" M200 T5 D", LINEAR_UNIT(planner.filament_size[5]));
#if EXTRUDERS > 6
CONFIG_ECHO_START();
SERIAL_ECHOLNPAIR(" M200 T6 D", LINEAR_UNIT(planner.filament_size[6]));
#if EXTRUDERS > 7
CONFIG_ECHO_START();
SERIAL_ECHOLNPAIR(" M200 T7 D", LINEAR_UNIT(planner.filament_size[7]));
#endif // EXTRUDERS > 7
#endif // EXTRUDERS > 6
#endif // EXTRUDERS > 5
#endif // EXTRUDERS > 4
#endif // EXTRUDERS > 3
#endif // EXTRUDERS > 2
#endif // EXTRUDERS > 1
if (!parser.volumetric_enabled) if (!parser.volumetric_enabled)
CONFIG_ECHO_MSG(" M200 D0"); CONFIG_ECHO_MSG(" M200 D0");
@ -2893,7 +2874,7 @@ void MarlinSettings::reset() {
); );
#if ENABLED(DISTINCT_E_FACTORS) #if ENABLED(DISTINCT_E_FACTORS)
CONFIG_ECHO_START(); CONFIG_ECHO_START();
for (uint8_t i = 0; i < E_STEPPERS; i++) { LOOP_L_N(i, E_STEPPERS) {
SERIAL_ECHOLNPAIR_P( SERIAL_ECHOLNPAIR_P(
PSTR(" M203 T"), (int)i PSTR(" M203 T"), (int)i
, SP_E_STR, VOLUMETRIC_UNIT(planner.settings.max_feedrate_mm_s[E_AXIS_N(i)]) , SP_E_STR, VOLUMETRIC_UNIT(planner.settings.max_feedrate_mm_s[E_AXIS_N(i)])
@ -2913,7 +2894,7 @@ void MarlinSettings::reset() {
); );
#if ENABLED(DISTINCT_E_FACTORS) #if ENABLED(DISTINCT_E_FACTORS)
CONFIG_ECHO_START(); CONFIG_ECHO_START();
for (uint8_t i = 0; i < E_STEPPERS; i++) LOOP_L_N(i, E_STEPPERS)
SERIAL_ECHOLNPAIR_P( SERIAL_ECHOLNPAIR_P(
PSTR(" M201 T"), (int)i PSTR(" M201 T"), (int)i
, SP_E_STR, VOLUMETRIC_UNIT(planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(i)]) , SP_E_STR, VOLUMETRIC_UNIT(planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(i)])
@ -3022,8 +3003,8 @@ void MarlinSettings::reset() {
#if ENABLED(MESH_BED_LEVELING) #if ENABLED(MESH_BED_LEVELING)
if (leveling_is_valid()) { if (leveling_is_valid()) {
for (uint8_t py = 0; py < GRID_MAX_POINTS_Y; py++) { LOOP_L_N(py, GRID_MAX_POINTS_Y) {
for (uint8_t px = 0; px < GRID_MAX_POINTS_X; px++) { LOOP_L_N(px, GRID_MAX_POINTS_X) {
CONFIG_ECHO_START(); CONFIG_ECHO_START();
SERIAL_ECHOPAIR_P(PSTR(" G29 S3 I"), (int)px, PSTR(" J"), (int)py); SERIAL_ECHOPAIR_P(PSTR(" G29 S3 I"), (int)px, PSTR(" J"), (int)py);
SERIAL_ECHOLNPAIR_F_P(SP_Z_STR, LINEAR_UNIT(mbl.z_values[px][py]), 5); SERIAL_ECHOLNPAIR_F_P(SP_Z_STR, LINEAR_UNIT(mbl.z_values[px][py]), 5);
@ -3047,8 +3028,8 @@ void MarlinSettings::reset() {
#elif ENABLED(AUTO_BED_LEVELING_BILINEAR) #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
if (leveling_is_valid()) { if (leveling_is_valid()) {
for (uint8_t py = 0; py < GRID_MAX_POINTS_Y; py++) { LOOP_L_N(py, GRID_MAX_POINTS_Y) {
for (uint8_t px = 0; px < GRID_MAX_POINTS_X; px++) { LOOP_L_N(px, GRID_MAX_POINTS_X) {
CONFIG_ECHO_START(); CONFIG_ECHO_START();
SERIAL_ECHOPAIR(" G29 W I", (int)px, " J", (int)py); SERIAL_ECHOPAIR(" G29 W I", (int)px, " J", (int)py);
SERIAL_ECHOLNPAIR_F_P(SP_Z_STR, LINEAR_UNIT(z_values[px][py]), 5); SERIAL_ECHOLNPAIR_F_P(SP_Z_STR, LINEAR_UNIT(z_values[px][py]), 5);
@ -3063,7 +3044,7 @@ void MarlinSettings::reset() {
#if ENABLED(EDITABLE_SERVO_ANGLES) #if ENABLED(EDITABLE_SERVO_ANGLES)
CONFIG_ECHO_HEADING("Servo Angles:"); CONFIG_ECHO_HEADING("Servo Angles:");
for (uint8_t i = 0; i < NUM_SERVOS; i++) { LOOP_L_N(i, NUM_SERVOS) {
switch (i) { switch (i) {
#if ENABLED(SWITCHING_EXTRUDER) #if ENABLED(SWITCHING_EXTRUDER)
case SWITCHING_EXTRUDER_SERVO_NR: case SWITCHING_EXTRUDER_SERVO_NR:
@ -3146,7 +3127,7 @@ void MarlinSettings::reset() {
#if HOTENDS && HAS_LCD_MENU #if HOTENDS && HAS_LCD_MENU
CONFIG_ECHO_HEADING("Material heatup parameters:"); CONFIG_ECHO_HEADING("Material heatup parameters:");
for (uint8_t i = 0; i < COUNT(ui.preheat_hotend_temp); i++) { LOOP_L_N(i, COUNT(ui.preheat_hotend_temp)) {
CONFIG_ECHO_START(); CONFIG_ECHO_START();
SERIAL_ECHOLNPAIR( SERIAL_ECHOLNPAIR(
" M145 S", (int)i " M145 S", (int)i
@ -3200,7 +3181,7 @@ void MarlinSettings::reset() {
#if HAS_USER_THERMISTORS #if HAS_USER_THERMISTORS
CONFIG_ECHO_HEADING("User thermistors:"); CONFIG_ECHO_HEADING("User thermistors:");
for (uint8_t i = 0; i < USER_THERMISTORS; i++) LOOP_L_N(i, USER_THERMISTORS)
thermalManager.log_user_thermistor(i, true); thermalManager.log_user_thermistor(i, true);
#endif #endif
@ -3596,29 +3577,10 @@ void MarlinSettings::reset() {
say_M603(forReplay); say_M603(forReplay);
SERIAL_ECHOLNPAIR("L", LINEAR_UNIT(fc_settings[0].load_length), " U", LINEAR_UNIT(fc_settings[0].unload_length)); SERIAL_ECHOLNPAIR("L", LINEAR_UNIT(fc_settings[0].load_length), " U", LINEAR_UNIT(fc_settings[0].unload_length));
#else #else
#define _ECHO_603(N) do{ say_M603(forReplay); SERIAL_ECHOLNPAIR("T" STRINGIFY(N) " L", LINEAR_UNIT(fc_settings[N].load_length), " U", LINEAR_UNIT(fc_settings[N].unload_length)); }while(0) #define _ECHO_603(N) do{ say_M603(forReplay); SERIAL_ECHOLNPAIR("T" STRINGIFY(N) " L", LINEAR_UNIT(fc_settings[N].load_length), " U", LINEAR_UNIT(fc_settings[N].unload_length)); }while(0);
_ECHO_603(0); REPEAT(EXTRUDERS, _ECHO_603)
_ECHO_603(1); #endif
#if EXTRUDERS > 2 #endif
_ECHO_603(2);
#if EXTRUDERS > 3
_ECHO_603(3);
#if EXTRUDERS > 4
_ECHO_603(4);
#if EXTRUDERS > 5
_ECHO_603(5);
#if EXTRUDERS > 6
_ECHO_603(6);
#if EXTRUDERS > 7
_ECHO_603(7);
#endif // EXTRUDERS > 7
#endif // EXTRUDERS > 6
#endif // EXTRUDERS > 5
#endif // EXTRUDERS > 4
#endif // EXTRUDERS > 3
#endif // EXTRUDERS > 2
#endif // EXTRUDERS == 1
#endif // ADVANCED_PAUSE_FEATURE
#if EXTRUDERS > 1 #if EXTRUDERS > 1
CONFIG_ECHO_HEADING("Tool-changing:"); CONFIG_ECHO_HEADING("Tool-changing:");

View File

@ -480,35 +480,18 @@ void _O2 Endstops::report_states() {
#if NUM_RUNOUT_SENSORS == 1 #if NUM_RUNOUT_SENSORS == 1
print_es_state(READ(FIL_RUNOUT_PIN) != FIL_RUNOUT_INVERTING, PSTR(MSG_FILAMENT_RUNOUT_SENSOR)); print_es_state(READ(FIL_RUNOUT_PIN) != FIL_RUNOUT_INVERTING, PSTR(MSG_FILAMENT_RUNOUT_SENSOR));
#else #else
#define _CASE_RUNOUT(N) case N: pin = FIL_RUNOUT##N##_PIN; break;
for (uint8_t i = 1; i <= NUM_RUNOUT_SENSORS; i++) { for (uint8_t i = 1; i <= NUM_RUNOUT_SENSORS; i++) {
pin_t pin; pin_t pin;
switch (i) { switch (i) {
default: continue; default: continue;
case 1: pin = FIL_RUNOUT_PIN; break; REPEAT_S(1, INCREMENT(NUM_RUNOUT_SENSORS), _CASE_RUNOUT)
case 2: pin = FIL_RUNOUT2_PIN; break;
#if NUM_RUNOUT_SENSORS >= 3
case 3: pin = FIL_RUNOUT3_PIN; break;
#if NUM_RUNOUT_SENSORS >= 4
case 4: pin = FIL_RUNOUT4_PIN; break;
#if NUM_RUNOUT_SENSORS >= 5
case 5: pin = FIL_RUNOUT5_PIN; break;
#if NUM_RUNOUT_SENSORS >= 6
case 6: pin = FIL_RUNOUT6_PIN; break;
#if NUM_RUNOUT_SENSORS >= 7
case 7: pin = FIL_RUNOUT7_PIN; break;
#if NUM_RUNOUT_SENSORS >= 8
case 8: pin = FIL_RUNOUT8_PIN; break;
#endif
#endif
#endif
#endif
#endif
#endif
} }
SERIAL_ECHOPGM(MSG_FILAMENT_RUNOUT_SENSOR); SERIAL_ECHOPGM(MSG_FILAMENT_RUNOUT_SENSOR);
if (i > 1) SERIAL_CHAR(' ', '0' + i); if (i > 1) SERIAL_CHAR(' ', '0' + i);
print_es_state(extDigitalRead(pin) != FIL_RUNOUT_INVERTING); print_es_state(extDigitalRead(pin) != FIL_RUNOUT_INVERTING);
} }
#undef _CASE_RUNOUT
#endif #endif
#endif #endif
#if ENABLED(BLTOUCH) #if ENABLED(BLTOUCH)

View File

@ -855,34 +855,14 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
// //
#if ENABLED(MIXING_EXTRUDER) #if ENABLED(MIXING_EXTRUDER)
/** /**
* Mixing steppers keep all their enable (and direction) states synchronized * Mixing steppers keep all their enable (and direction) states synchronized
*/ */
#if MIXING_STEPPERS > 7 #define _CALL_ENA_E(N) ENABLE_STEPPER_E##N () ;
#define ENABLE_AXIS_E0() { ENABLE_STEPPER_E0(); ENABLE_STEPPER_E1(); ENABLE_STEPPER_E2(); ENABLE_STEPPER_E3(); ENABLE_STEPPER_E4(); ENABLE_STEPPER_E5(); ENABLE_STEPPER_E6(); ENABLE_STEPPER_E7(); } #define _CALL_DIS_E(N) DISABLE_STEPPER_E##N () ;
#define DISABLE_AXIS_E0() { DISABLE_STEPPER_E0(); DISABLE_STEPPER_E1(); DISABLE_STEPPER_E2(); DISABLE_STEPPER_E3(); DISABLE_STEPPER_E4(); DISABLE_STEPPER_E5(); DISABLE_STEPPER_E6(); DISABLE_STEPPER_E7(); } #define ENABLE_AXIS_E0() { RREPEAT(MIXING_STEPPERS, _CALL_ENA_E) }
#elif MIXING_STEPPERS > 6 #define DISABLE_AXIS_E0() { RREPEAT(MIXING_STEPPERS, _CALL_DIS_E) }
#define ENABLE_AXIS_E0() { ENABLE_STEPPER_E0(); ENABLE_STEPPER_E1(); ENABLE_STEPPER_E2(); ENABLE_STEPPER_E3(); ENABLE_STEPPER_E4(); ENABLE_STEPPER_E5(); ENABLE_STEPPER_E6(); } #endif
#define DISABLE_AXIS_E0() { DISABLE_STEPPER_E0(); DISABLE_STEPPER_E1(); DISABLE_STEPPER_E2(); DISABLE_STEPPER_E3(); DISABLE_STEPPER_E4(); DISABLE_STEPPER_E5(); DISABLE_STEPPER_E6(); }
#elif MIXING_STEPPERS > 5
#define ENABLE_AXIS_E0() { ENABLE_STEPPER_E0(); ENABLE_STEPPER_E1(); ENABLE_STEPPER_E2(); ENABLE_STEPPER_E3(); ENABLE_STEPPER_E4(); ENABLE_STEPPER_E5(); }
#define DISABLE_AXIS_E0() { DISABLE_STEPPER_E0(); DISABLE_STEPPER_E1(); DISABLE_STEPPER_E2(); DISABLE_STEPPER_E3(); DISABLE_STEPPER_E4(); DISABLE_STEPPER_E5(); }
#elif MIXING_STEPPERS > 4
#define ENABLE_AXIS_E0() { ENABLE_STEPPER_E0(); ENABLE_STEPPER_E1(); ENABLE_STEPPER_E2(); ENABLE_STEPPER_E3(); ENABLE_STEPPER_E4(); }
#define DISABLE_AXIS_E0() { DISABLE_STEPPER_E0(); DISABLE_STEPPER_E1(); DISABLE_STEPPER_E2(); DISABLE_STEPPER_E3(); DISABLE_STEPPER_E4(); }
#elif MIXING_STEPPERS > 3
#define ENABLE_AXIS_E0() { ENABLE_STEPPER_E0(); ENABLE_STEPPER_E1(); ENABLE_STEPPER_E2(); ENABLE_STEPPER_E3(); }
#define DISABLE_AXIS_E0() { DISABLE_STEPPER_E0(); DISABLE_STEPPER_E1(); DISABLE_STEPPER_E2(); DISABLE_STEPPER_E3(); }
#elif MIXING_STEPPERS > 2
#define ENABLE_AXIS_E0() { ENABLE_STEPPER_E0(); ENABLE_STEPPER_E1(); ENABLE_STEPPER_E2(); }
#define DISABLE_AXIS_E0() { DISABLE_STEPPER_E0(); DISABLE_STEPPER_E1(); DISABLE_STEPPER_E2(); }
#else
#define ENABLE_AXIS_E0() { ENABLE_STEPPER_E0(); ENABLE_STEPPER_E1(); }
#define DISABLE_AXIS_E0() { DISABLE_STEPPER_E0(); DISABLE_STEPPER_E1(); }
#endif
#endif // !MIXING_EXTRUDER
#ifndef ENABLE_AXIS_E0 #ifndef ENABLE_AXIS_E0
#if E_STEPPERS > 0 && HAS_E0_ENABLE #if E_STEPPERS > 0 && HAS_E0_ENABLE

View File

@ -679,25 +679,8 @@ int16_t Temperature::getHeaterPower(const heater_ind_t heater_id) {
static const uint8_t fanBit[] PROGMEM = { static const uint8_t fanBit[] PROGMEM = {
0 0
#if HOTENDS > 1 #if HOTENDS > 1
, REPEAT2(1,_EFAN,1) 1 #define _NEXT_FAN(N) , REPEAT2(N,_EFAN,N) N
#if HOTENDS > 2 RREPEAT_S(1, HOTENDS, _NEXT_FAN)
, REPEAT2(2,_EFAN,2) 2
#if HOTENDS > 3
, REPEAT2(3,_EFAN,3) 3
#if HOTENDS > 4
, REPEAT2(4,_EFAN,4) 4
#if HOTENDS > 5
, REPEAT2(5,_EFAN,5) 5
#if HOTENDS > 6
, REPEAT2(6,_EFAN,6) 6
#if HOTENDS > 7
, REPEAT2(7,_EFAN,7) 7
#endif
#endif
#endif
#endif
#endif
#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 :
@ -2116,10 +2099,10 @@ void Temperature::disable_all_heaters() {
pause(false); pause(false);
#endif #endif
#define DISABLE_HEATER(NR) { \ #define DISABLE_HEATER(N) { \
setTargetHotend(0, NR); \ setTargetHotend(0, N); \
temp_hotend[NR].soft_pwm_amount = 0; \ temp_hotend[N].soft_pwm_amount = 0; \
WRITE_HEATER_ ##NR (LOW); \ WRITE_HEATER_##N(LOW); \
} }
#if HAS_TEMP_HOTEND #if HAS_TEMP_HOTEND

View File

@ -1115,6 +1115,10 @@
#define Z_MIN_PIN -1 #define Z_MIN_PIN -1
#endif #endif
#if HAS_FILAMENT_SENSOR
#define FIL_RUNOUT1_PIN FIL_RUNOUT_PIN
#endif
#ifndef LCD_PINS_D4 #ifndef LCD_PINS_D4
#define LCD_PINS_D4 -1 #define LCD_PINS_D4 -1
#endif #endif