소스 검색

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

Scott Lahteine 4 년 전
부모
커밋
4716dac874
No account linked to committer's email address

+ 18
- 0
Marlin/src/core/macros.h 파일 보기

@@ -457,3 +457,21 @@
457 457
 // Repeat a macro passing 0...N-1 plus additional arguments.
458 458
 #define REPEAT2_S(S,N,OP,V...)  EVAL(_REPEAT2(S,SUB##S(N),OP,V))
459 459
 #define REPEAT2(N,OP,V...)      REPEAT2_S(0,N,OP,V)
460
+
461
+// Use RREPEAT macros with REPEAT macros for nesting
462
+#define _RREPEAT(_RPT_I,_RPT_N,_RPT_OP)                           \
463
+  _RPT_OP(_RPT_I)                                                 \
464
+  IF_ELSE(SUB1(_RPT_N))                                           \
465
+    ( DEFER2(__RREPEAT)()(ADD1(_RPT_I),SUB1(_RPT_N),_RPT_OP) )    \
466
+    ( /* Do nothing */ )
467
+#define __RREPEAT() _RREPEAT
468
+#define _RREPEAT2(_RPT_I,_RPT_N,_RPT_OP,V...)                     \
469
+  _RPT_OP(_RPT_I,V)                                               \
470
+  IF_ELSE(SUB1(_RPT_N))                                           \
471
+    ( DEFER2(__RREPEAT2)()(ADD1(_RPT_I),SUB1(_RPT_N),_RPT_OP,V) ) \
472
+    ( /* Do nothing */ )
473
+#define __RREPEAT2() _RREPEAT2
474
+#define RREPEAT_S(S,N,OP)        EVAL(_RREPEAT(S,SUB##S(N),OP))
475
+#define RREPEAT(N,OP)            RREPEAT_S(0,N,OP)
476
+#define RREPEAT2_S(S,N,OP,V...)  EVAL(_RREPEAT2(S,SUB##S(N),OP,V))
477
+#define RREPEAT2(N,OP,V...)      RREPEAT2_S(0,N,OP,V)

+ 10
- 38
Marlin/src/feature/runout.h 파일 보기

@@ -139,56 +139,28 @@ class FilamentSensorBase {
139 139
         #define INIT_RUNOUT_PIN(P) SET_INPUT(P)
140 140
       #endif
141 141
 
142
-      INIT_RUNOUT_PIN(FIL_RUNOUT_PIN);
143
-      #if NUM_RUNOUT_SENSORS > 1
144
-        INIT_RUNOUT_PIN(FIL_RUNOUT2_PIN);
145
-        #if NUM_RUNOUT_SENSORS > 2
146
-          INIT_RUNOUT_PIN(FIL_RUNOUT3_PIN);
147
-          #if NUM_RUNOUT_SENSORS > 3
148
-            INIT_RUNOUT_PIN(FIL_RUNOUT4_PIN);
149
-            #if NUM_RUNOUT_SENSORS > 4
150
-              INIT_RUNOUT_PIN(FIL_RUNOUT5_PIN);
151
-              #if NUM_RUNOUT_SENSORS > 5
152
-                INIT_RUNOUT_PIN(FIL_RUNOUT6_PIN);
153
-              #endif
154
-            #endif
155
-          #endif
156
-        #endif
157
-      #endif
142
+      #define _INIT_RUNOUT(N) INIT_RUNOUT_PIN(FIL_RUNOUT##N##_PIN);
143
+      REPEAT_S(1, INCREMENT(NUM_RUNOUT_SENSORS), _INIT_RUNOUT)
144
+      #undef _INIT_RUNOUT
158 145
     }
159 146
 
160 147
     // Return a bitmask of runout pin states
161 148
     static inline uint8_t poll_runout_pins() {
162
-      return (
163
-        (READ(FIL_RUNOUT_PIN ) ? _BV(0) : 0)
164
-        #if NUM_RUNOUT_SENSORS > 1
165
-          | (READ(FIL_RUNOUT2_PIN) ? _BV(1) : 0)
166
-          #if NUM_RUNOUT_SENSORS > 2
167
-            | (READ(FIL_RUNOUT3_PIN) ? _BV(2) : 0)
168
-            #if NUM_RUNOUT_SENSORS > 3
169
-              | (READ(FIL_RUNOUT4_PIN) ? _BV(3) : 0)
170
-              #if NUM_RUNOUT_SENSORS > 4
171
-                | (READ(FIL_RUNOUT5_PIN) ? _BV(4) : 0)
172
-                #if NUM_RUNOUT_SENSORS > 5
173
-                  | (READ(FIL_RUNOUT6_PIN) ? _BV(5) : 0)
174
-                #endif
175
-              #endif
176
-            #endif
177
-          #endif
178
-        #endif
179
-      );
149
+      #define _OR_RUNOUT(N) | (READ(FIL_RUNOUT##N##_PIN) ? _BV((N) - 1) : 0)
150
+      return (0 REPEAT_S(1, INCREMENT(NUM_RUNOUT_SENSORS), _OR_RUNOUT));
151
+      #undef _OR_RUNOUT
180 152
     }
181 153
 
182 154
     // Return a bitmask of runout flag states (1 bits always indicates runout)
183 155
     static inline uint8_t poll_runout_states() {
184
-      return poll_runout_pins() ^ uint8_t(
156
+      return (poll_runout_pins()
185 157
         #if DISABLED(FIL_RUNOUT_INVERTING)
186
-          _BV(NUM_RUNOUT_SENSORS) - 1
187
-        #else
188
-          0
158
+          ^ uint8_t(_BV(NUM_RUNOUT_SENSORS) - 1)
189 159
         #endif
190 160
       );
191 161
     }
162
+
163
+  #undef INIT_RUNOUT_PIN
192 164
 };
193 165
 
194 166
 #if ENABLED(FILAMENT_MOTION_SENSOR)

+ 2
- 7
Marlin/src/gcode/calibrate/M666.cpp 파일 보기

@@ -94,13 +94,8 @@
94 94
         SERIAL_ECHOPAIR(" Y2:", endstops.y2_endstop_adj);
95 95
       #endif
96 96
       #if ENABLED(Z_MULTI_ENDSTOPS)
97
-        SERIAL_ECHOPAIR(" Z2:", endstops.z2_endstop_adj);
98
-        #if NUM_Z_STEPPER_DRIVERS >= 3
99
-          SERIAL_ECHOPAIR(" Z3:", endstops.z3_endstop_adj);
100
-          #if NUM_Z_STEPPER_DRIVERS >= 4
101
-            SERIAL_ECHOPAIR(" Z4:", endstops.z4_endstop_adj);
102
-          #endif
103
-        #endif
97
+        #define _ECHO_ZADJ(N) SERIAL_ECHOPAIR(" Z" STRINGIFY(N) ":", endstops.z##N##_endstop_adj);
98
+        REPEAT_S(2, INCREMENT(NUM_Z_STEPPER_DRIVERS), _ECHO_ZADJ)
104 99
       #endif
105 100
       SERIAL_EOL();
106 101
     }

+ 1
- 1
Marlin/src/gcode/config/M301.cpp 파일 보기

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

+ 9
- 45
Marlin/src/lcd/menu/menu_advanced.cpp 파일 보기

@@ -228,35 +228,17 @@ void menu_cancelobject();
228 228
 #if ENABLED(PID_AUTOTUNE_MENU)
229 229
   #define DEFINE_PIDTEMP_FUNCS(N) \
230 230
     _DEFINE_PIDTEMP_BASE_FUNCS(N); \
231
-    void lcd_autotune_callback_E##N() { _lcd_autotune(N); } //
231
+    void lcd_autotune_callback_E##N() { _lcd_autotune(N); }
232 232
 #else
233
-  #define DEFINE_PIDTEMP_FUNCS(N) _DEFINE_PIDTEMP_BASE_FUNCS(N); //
233
+  #define DEFINE_PIDTEMP_FUNCS(N) _DEFINE_PIDTEMP_BASE_FUNCS(N);
234 234
 #endif
235 235
 
236 236
 #if HOTENDS
237 237
   DEFINE_PIDTEMP_FUNCS(0);
238 238
   #if HOTENDS > 1 && ENABLED(PID_PARAMS_PER_HOTEND)
239
-    DEFINE_PIDTEMP_FUNCS(1);
240
-    #if HOTENDS > 2
241
-      DEFINE_PIDTEMP_FUNCS(2);
242
-      #if HOTENDS > 3
243
-        DEFINE_PIDTEMP_FUNCS(3);
244
-        #if HOTENDS > 4
245
-          DEFINE_PIDTEMP_FUNCS(4);
246
-          #if HOTENDS > 5
247
-            DEFINE_PIDTEMP_FUNCS(5);
248
-            #if HOTENDS > 6
249
-              DEFINE_PIDTEMP_FUNCS(6);
250
-              #if HOTENDS > 7
251
-                DEFINE_PIDTEMP_FUNCS(7);
252
-              #endif // HOTENDS > 7
253
-            #endif // HOTENDS > 6
254
-          #endif // HOTENDS > 5
255
-        #endif // HOTENDS > 4
256
-      #endif // HOTENDS > 3
257
-    #endif // HOTENDS > 2
258
-  #endif // HOTENDS > 1 && PID_PARAMS_PER_HOTEND
259
-#endif // HOTENDS
239
+    REPEAT_S(1, HOTENDS, DEFINE_PIDTEMP_FUNCS)
240
+  #endif
241
+#endif
260 242
 
261 243
 #define SHOW_MENU_ADVANCED_TEMPERATURE ((ENABLED(AUTOTEMP) && HAS_TEMP_HOTEND) || EITHER(PID_AUTOTUNE_MENU, PID_EDIT_MENU))
262 244
 
@@ -320,33 +302,15 @@ void menu_cancelobject();
320 302
     #if ENABLED(PID_AUTOTUNE_MENU)
321 303
       #define PID_EDIT_MENU_ITEMS(N) \
322 304
         _PID_EDIT_MENU_ITEMS(N); \
323
-        EDIT_ITEM_FAST_N(int3, N, MSG_PID_AUTOTUNE_E, &autotune_temp[N], 150, heater_maxtemp[N] - 15, []{ _lcd_autotune(MenuItemBase::itemIndex); })
305
+        EDIT_ITEM_FAST_N(int3, N, MSG_PID_AUTOTUNE_E, &autotune_temp[N], 150, heater_maxtemp[N] - 15, []{ _lcd_autotune(MenuItemBase::itemIndex); });
324 306
     #else
325
-      #define PID_EDIT_MENU_ITEMS(N) _PID_EDIT_MENU_ITEMS(N)
307
+      #define PID_EDIT_MENU_ITEMS(N) _PID_EDIT_MENU_ITEMS(N);
326 308
     #endif
327 309
 
328 310
     PID_EDIT_MENU_ITEMS(0);
329 311
     #if HOTENDS > 1 && ENABLED(PID_PARAMS_PER_HOTEND)
330
-      PID_EDIT_MENU_ITEMS(1);
331
-      #if HOTENDS > 2
332
-        PID_EDIT_MENU_ITEMS(2);
333
-        #if HOTENDS > 3
334
-          PID_EDIT_MENU_ITEMS(3);
335
-          #if HOTENDS > 4
336
-            PID_EDIT_MENU_ITEMS(4);
337
-            #if HOTENDS > 5
338
-              PID_EDIT_MENU_ITEMS(5);
339
-              #if HOTENDS > 6
340
-                PID_EDIT_MENU_ITEMS(6);
341
-                #if HOTENDS > 7
342
-                  PID_EDIT_MENU_ITEMS(7);
343
-                #endif // HOTENDS > 7
344
-              #endif // HOTENDS > 6
345
-            #endif // HOTENDS > 5
346
-          #endif // HOTENDS > 4
347
-        #endif // HOTENDS > 3
348
-      #endif // HOTENDS > 2
349
-    #endif // HOTENDS > 1 && PID_PARAMS_PER_HOTEND
312
+      REPEAT_S(1, HOTENDS, PID_EDIT_MENU_ITEMS)
313
+    #endif
350 314
 
351 315
     END_MENU();
352 316
   }

+ 24
- 62
Marlin/src/module/configuration_store.cpp 파일 보기

@@ -2667,7 +2667,7 @@ void MarlinSettings::reset() {
2667 2667
         false
2668 2668
       #endif
2669 2669
     ;
2670
-    for (uint8_t q = 0; q < COUNT(planner.filament_size); q++)
2670
+    LOOP_L_N(q, COUNT(planner.filament_size))
2671 2671
       planner.filament_size[q] = DEFAULT_NOMINAL_FILAMENT_DIA;
2672 2672
 
2673 2673
   #endif
@@ -2730,7 +2730,7 @@ void MarlinSettings::reset() {
2730 2730
   //
2731 2731
 
2732 2732
   #if ENABLED(ADVANCED_PAUSE_FEATURE)
2733
-    for (uint8_t e = 0; e < EXTRUDERS; e++) {
2733
+    LOOP_L_N(e, EXTRUDERS) {
2734 2734
       fc_settings[e].unload_length = FILAMENT_CHANGE_UNLOAD_LENGTH;
2735 2735
       fc_settings[e].load_length = FILAMENT_CHANGE_FAST_LOAD_LENGTH;
2736 2736
     }
@@ -2842,36 +2842,17 @@ void MarlinSettings::reset() {
2842 2842
           SERIAL_ECHOLNPGM(" Disabled");
2843 2843
       }
2844 2844
 
2845
-      CONFIG_ECHO_START();
2846
-      SERIAL_ECHOLNPAIR("  M200 D", LINEAR_UNIT(planner.filament_size[0]));
2847
-      #if EXTRUDERS > 1
2845
+      #if EXTRUDERS == 1
2848 2846
         CONFIG_ECHO_START();
2849
-        SERIAL_ECHOLNPAIR("  M200 T1 D", LINEAR_UNIT(planner.filament_size[1]));
2850
-        #if EXTRUDERS > 2
2847
+        SERIAL_ECHOLNPAIR("  M200 D", LINEAR_UNIT(planner.filament_size[0]));
2848
+      #elif EXTRUDERS
2849
+        LOOP_L_N(i, EXTRUDERS) {
2851 2850
           CONFIG_ECHO_START();
2852
-          SERIAL_ECHOLNPAIR("  M200 T2 D", LINEAR_UNIT(planner.filament_size[2]));
2853
-          #if EXTRUDERS > 3
2854
-            CONFIG_ECHO_START();
2855
-            SERIAL_ECHOLNPAIR("  M200 T3 D", LINEAR_UNIT(planner.filament_size[3]));
2856
-            #if EXTRUDERS > 4
2857
-              CONFIG_ECHO_START();
2858
-              SERIAL_ECHOLNPAIR("  M200 T4 D", LINEAR_UNIT(planner.filament_size[4]));
2859
-              #if EXTRUDERS > 5
2860
-                CONFIG_ECHO_START();
2861
-                SERIAL_ECHOLNPAIR("  M200 T5 D", LINEAR_UNIT(planner.filament_size[5]));
2862
-                #if EXTRUDERS > 6
2863
-                  CONFIG_ECHO_START();
2864
-                  SERIAL_ECHOLNPAIR("  M200 T6 D", LINEAR_UNIT(planner.filament_size[6]));
2865
-                  #if EXTRUDERS > 7
2866
-                    CONFIG_ECHO_START();
2867
-                    SERIAL_ECHOLNPAIR("  M200 T7 D", LINEAR_UNIT(planner.filament_size[7]));
2868
-                  #endif // EXTRUDERS > 7
2869
-                #endif // EXTRUDERS > 6
2870
-              #endif // EXTRUDERS > 5
2871
-            #endif // EXTRUDERS > 4
2872
-          #endif // EXTRUDERS > 3
2873
-        #endif // EXTRUDERS > 2
2874
-      #endif // EXTRUDERS > 1
2851
+          SERIAL_ECHOPGM("  M200");
2852
+          if (i) SERIAL_ECHOPAIR_P(SP_T_STR, int(i));
2853
+          SERIAL_ECHOLNPAIR(" D", LINEAR_UNIT(planner.filament_size[i]));
2854
+        }
2855
+      #endif
2875 2856
 
2876 2857
       if (!parser.volumetric_enabled)
2877 2858
         CONFIG_ECHO_MSG("  M200 D0");
@@ -2893,7 +2874,7 @@ void MarlinSettings::reset() {
2893 2874
     );
2894 2875
     #if ENABLED(DISTINCT_E_FACTORS)
2895 2876
       CONFIG_ECHO_START();
2896
-      for (uint8_t i = 0; i < E_STEPPERS; i++) {
2877
+      LOOP_L_N(i, E_STEPPERS) {
2897 2878
         SERIAL_ECHOLNPAIR_P(
2898 2879
             PSTR("  M203 T"), (int)i
2899 2880
           , SP_E_STR, VOLUMETRIC_UNIT(planner.settings.max_feedrate_mm_s[E_AXIS_N(i)])
@@ -2913,7 +2894,7 @@ void MarlinSettings::reset() {
2913 2894
     );
2914 2895
     #if ENABLED(DISTINCT_E_FACTORS)
2915 2896
       CONFIG_ECHO_START();
2916
-      for (uint8_t i = 0; i < E_STEPPERS; i++)
2897
+      LOOP_L_N(i, E_STEPPERS)
2917 2898
         SERIAL_ECHOLNPAIR_P(
2918 2899
             PSTR("  M201 T"), (int)i
2919 2900
           , SP_E_STR, VOLUMETRIC_UNIT(planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(i)])
@@ -3022,8 +3003,8 @@ void MarlinSettings::reset() {
3022 3003
       #if ENABLED(MESH_BED_LEVELING)
3023 3004
 
3024 3005
         if (leveling_is_valid()) {
3025
-          for (uint8_t py = 0; py < GRID_MAX_POINTS_Y; py++) {
3026
-            for (uint8_t px = 0; px < GRID_MAX_POINTS_X; px++) {
3006
+          LOOP_L_N(py, GRID_MAX_POINTS_Y) {
3007
+            LOOP_L_N(px, GRID_MAX_POINTS_X) {
3027 3008
               CONFIG_ECHO_START();
3028 3009
               SERIAL_ECHOPAIR_P(PSTR("  G29 S3 I"), (int)px, PSTR(" J"), (int)py);
3029 3010
               SERIAL_ECHOLNPAIR_F_P(SP_Z_STR, LINEAR_UNIT(mbl.z_values[px][py]), 5);
@@ -3047,8 +3028,8 @@ void MarlinSettings::reset() {
3047 3028
       #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
3048 3029
 
3049 3030
         if (leveling_is_valid()) {
3050
-          for (uint8_t py = 0; py < GRID_MAX_POINTS_Y; py++) {
3051
-            for (uint8_t px = 0; px < GRID_MAX_POINTS_X; px++) {
3031
+          LOOP_L_N(py, GRID_MAX_POINTS_Y) {
3032
+            LOOP_L_N(px, GRID_MAX_POINTS_X) {
3052 3033
               CONFIG_ECHO_START();
3053 3034
               SERIAL_ECHOPAIR("  G29 W I", (int)px, " J", (int)py);
3054 3035
               SERIAL_ECHOLNPAIR_F_P(SP_Z_STR, LINEAR_UNIT(z_values[px][py]), 5);
@@ -3063,7 +3044,7 @@ void MarlinSettings::reset() {
3063 3044
     #if ENABLED(EDITABLE_SERVO_ANGLES)
3064 3045
 
3065 3046
       CONFIG_ECHO_HEADING("Servo Angles:");
3066
-      for (uint8_t i = 0; i < NUM_SERVOS; i++) {
3047
+      LOOP_L_N(i, NUM_SERVOS) {
3067 3048
         switch (i) {
3068 3049
           #if ENABLED(SWITCHING_EXTRUDER)
3069 3050
             case SWITCHING_EXTRUDER_SERVO_NR:
@@ -3146,7 +3127,7 @@ void MarlinSettings::reset() {
3146 3127
     #if HOTENDS && HAS_LCD_MENU
3147 3128
 
3148 3129
       CONFIG_ECHO_HEADING("Material heatup parameters:");
3149
-      for (uint8_t i = 0; i < COUNT(ui.preheat_hotend_temp); i++) {
3130
+      LOOP_L_N(i, COUNT(ui.preheat_hotend_temp)) {
3150 3131
         CONFIG_ECHO_START();
3151 3132
         SERIAL_ECHOLNPAIR(
3152 3133
             "  M145 S", (int)i
@@ -3200,7 +3181,7 @@ void MarlinSettings::reset() {
3200 3181
 
3201 3182
     #if HAS_USER_THERMISTORS
3202 3183
       CONFIG_ECHO_HEADING("User thermistors:");
3203
-      for (uint8_t i = 0; i < USER_THERMISTORS; i++)
3184
+      LOOP_L_N(i, USER_THERMISTORS)
3204 3185
         thermalManager.log_user_thermistor(i, true);
3205 3186
     #endif
3206 3187
 
@@ -3596,29 +3577,10 @@ void MarlinSettings::reset() {
3596 3577
         say_M603(forReplay);
3597 3578
         SERIAL_ECHOLNPAIR("L", LINEAR_UNIT(fc_settings[0].load_length), " U", LINEAR_UNIT(fc_settings[0].unload_length));
3598 3579
       #else
3599
-        #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)
3600
-        _ECHO_603(0);
3601
-        _ECHO_603(1);
3602
-        #if EXTRUDERS > 2
3603
-          _ECHO_603(2);
3604
-          #if EXTRUDERS > 3
3605
-            _ECHO_603(3);
3606
-            #if EXTRUDERS > 4
3607
-              _ECHO_603(4);
3608
-              #if EXTRUDERS > 5
3609
-                _ECHO_603(5);
3610
-                #if EXTRUDERS > 6
3611
-                  _ECHO_603(6);
3612
-                  #if EXTRUDERS > 7
3613
-                    _ECHO_603(7);
3614
-                  #endif // EXTRUDERS > 7
3615
-                #endif // EXTRUDERS > 6
3616
-              #endif // EXTRUDERS > 5
3617
-            #endif // EXTRUDERS > 4
3618
-          #endif // EXTRUDERS > 3
3619
-        #endif // EXTRUDERS > 2
3620
-      #endif // EXTRUDERS == 1
3621
-    #endif // ADVANCED_PAUSE_FEATURE
3580
+        #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);
3581
+        REPEAT(EXTRUDERS, _ECHO_603)
3582
+      #endif
3583
+    #endif
3622 3584
 
3623 3585
     #if EXTRUDERS > 1
3624 3586
       CONFIG_ECHO_HEADING("Tool-changing:");

+ 3
- 20
Marlin/src/module/endstops.cpp 파일 보기

@@ -480,35 +480,18 @@ void _O2 Endstops::report_states() {
480 480
     #if NUM_RUNOUT_SENSORS == 1
481 481
       print_es_state(READ(FIL_RUNOUT_PIN) != FIL_RUNOUT_INVERTING, PSTR(MSG_FILAMENT_RUNOUT_SENSOR));
482 482
     #else
483
+      #define _CASE_RUNOUT(N) case N: pin = FIL_RUNOUT##N##_PIN; break;
483 484
       for (uint8_t i = 1; i <= NUM_RUNOUT_SENSORS; i++) {
484 485
         pin_t pin;
485 486
         switch (i) {
486 487
           default: continue;
487
-          case 1: pin = FIL_RUNOUT_PIN; break;
488
-          case 2: pin = FIL_RUNOUT2_PIN; break;
489
-          #if NUM_RUNOUT_SENSORS >= 3
490
-            case 3: pin = FIL_RUNOUT3_PIN; break;
491
-            #if NUM_RUNOUT_SENSORS >= 4
492
-              case 4: pin = FIL_RUNOUT4_PIN; break;
493
-              #if NUM_RUNOUT_SENSORS >= 5
494
-                case 5: pin = FIL_RUNOUT5_PIN; break;
495
-                #if NUM_RUNOUT_SENSORS >= 6
496
-                  case 6: pin = FIL_RUNOUT6_PIN; break;
497
-                  #if NUM_RUNOUT_SENSORS >= 7
498
-                    case 7: pin = FIL_RUNOUT7_PIN; break;
499
-                    #if NUM_RUNOUT_SENSORS >= 8
500
-                      case 8: pin = FIL_RUNOUT8_PIN; break;
501
-                    #endif
502
-                  #endif
503
-                #endif
504
-              #endif
505
-            #endif
506
-          #endif
488
+          REPEAT_S(1, INCREMENT(NUM_RUNOUT_SENSORS), _CASE_RUNOUT)
507 489
         }
508 490
         SERIAL_ECHOPGM(MSG_FILAMENT_RUNOUT_SENSOR);
509 491
         if (i > 1) SERIAL_CHAR(' ', '0' + i);
510 492
         print_es_state(extDigitalRead(pin) != FIL_RUNOUT_INVERTING);
511 493
       }
494
+      #undef _CASE_RUNOUT
512 495
     #endif
513 496
   #endif
514 497
   #if ENABLED(BLTOUCH)

+ 5
- 25
Marlin/src/module/stepper/indirection.h 파일 보기

@@ -855,34 +855,14 @@ void reset_stepper_drivers();    // Called by settings.load / settings.reset
855 855
 //
856 856
 
857 857
 #if ENABLED(MIXING_EXTRUDER)
858
-
859 858
   /**
860 859
    * Mixing steppers keep all their enable (and direction) states synchronized
861 860
    */
862
-  #if MIXING_STEPPERS > 7
863
-    #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(); }
864
-    #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(); }
865
-  #elif MIXING_STEPPERS > 6
866
-    #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(); }
867
-    #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(); }
868
-  #elif MIXING_STEPPERS > 5
869
-    #define  ENABLE_AXIS_E0() { ENABLE_STEPPER_E0();  ENABLE_STEPPER_E1();  ENABLE_STEPPER_E2();  ENABLE_STEPPER_E3();  ENABLE_STEPPER_E4();  ENABLE_STEPPER_E5(); }
870
-    #define DISABLE_AXIS_E0() { DISABLE_STEPPER_E0(); DISABLE_STEPPER_E1(); DISABLE_STEPPER_E2(); DISABLE_STEPPER_E3(); DISABLE_STEPPER_E4(); DISABLE_STEPPER_E5(); }
871
-  #elif MIXING_STEPPERS > 4
872
-    #define  ENABLE_AXIS_E0() { ENABLE_STEPPER_E0();  ENABLE_STEPPER_E1();  ENABLE_STEPPER_E2();  ENABLE_STEPPER_E3();  ENABLE_STEPPER_E4(); }
873
-    #define DISABLE_AXIS_E0() { DISABLE_STEPPER_E0(); DISABLE_STEPPER_E1(); DISABLE_STEPPER_E2(); DISABLE_STEPPER_E3(); DISABLE_STEPPER_E4(); }
874
-  #elif MIXING_STEPPERS > 3
875
-    #define  ENABLE_AXIS_E0() { ENABLE_STEPPER_E0();  ENABLE_STEPPER_E1();  ENABLE_STEPPER_E2();  ENABLE_STEPPER_E3(); }
876
-    #define DISABLE_AXIS_E0() { DISABLE_STEPPER_E0(); DISABLE_STEPPER_E1(); DISABLE_STEPPER_E2(); DISABLE_STEPPER_E3(); }
877
-  #elif MIXING_STEPPERS > 2
878
-    #define  ENABLE_AXIS_E0() { ENABLE_STEPPER_E0();  ENABLE_STEPPER_E1();  ENABLE_STEPPER_E2(); }
879
-    #define DISABLE_AXIS_E0() { DISABLE_STEPPER_E0(); DISABLE_STEPPER_E1(); DISABLE_STEPPER_E2(); }
880
-  #else
881
-    #define  ENABLE_AXIS_E0() { ENABLE_STEPPER_E0();  ENABLE_STEPPER_E1(); }
882
-    #define DISABLE_AXIS_E0() { DISABLE_STEPPER_E0(); DISABLE_STEPPER_E1(); }
883
-  #endif
884
-
885
-#endif // !MIXING_EXTRUDER
861
+  #define _CALL_ENA_E(N)  ENABLE_STEPPER_E##N () ;
862
+  #define _CALL_DIS_E(N) DISABLE_STEPPER_E##N () ;
863
+  #define  ENABLE_AXIS_E0() { RREPEAT(MIXING_STEPPERS, _CALL_ENA_E) }
864
+  #define DISABLE_AXIS_E0() { RREPEAT(MIXING_STEPPERS, _CALL_DIS_E) }
865
+#endif
886 866
 
887 867
 #ifndef ENABLE_AXIS_E0
888 868
   #if E_STEPPERS > 0 && HAS_E0_ENABLE

+ 6
- 23
Marlin/src/module/temperature.cpp 파일 보기

@@ -679,25 +679,8 @@ int16_t Temperature::getHeaterPower(const heater_ind_t heater_id) {
679 679
     static const uint8_t fanBit[] PROGMEM = {
680 680
       0
681 681
       #if HOTENDS > 1
682
-        , REPEAT2(1,_EFAN,1) 1
683
-        #if HOTENDS > 2
684
-          , REPEAT2(2,_EFAN,2) 2
685
-          #if HOTENDS > 3
686
-            , REPEAT2(3,_EFAN,3) 3
687
-            #if HOTENDS > 4
688
-              , REPEAT2(4,_EFAN,4) 4
689
-              #if HOTENDS > 5
690
-                , REPEAT2(5,_EFAN,5) 5
691
-                #if HOTENDS > 6
692
-                  , REPEAT2(6,_EFAN,6) 6
693
-                  #if HOTENDS > 7
694
-                    , REPEAT2(7,_EFAN,7) 7
695
-                  #endif
696
-                #endif
697
-              #endif
698
-            #endif
699
-          #endif
700
-        #endif
682
+        #define _NEXT_FAN(N) , REPEAT2(N,_EFAN,N) N
683
+        RREPEAT_S(1, HOTENDS, _NEXT_FAN)
701 684
       #endif
702 685
       #if HAS_AUTO_CHAMBER_FAN
703 686
         #define _CFAN(B) _FANOVERLAP(CHAMBER,B) ? B :
@@ -2116,10 +2099,10 @@ void Temperature::disable_all_heaters() {
2116 2099
     pause(false);
2117 2100
   #endif
2118 2101
 
2119
-  #define DISABLE_HEATER(NR) { \
2120
-    setTargetHotend(0, NR); \
2121
-    temp_hotend[NR].soft_pwm_amount = 0; \
2122
-    WRITE_HEATER_ ##NR (LOW); \
2102
+  #define DISABLE_HEATER(N) {           \
2103
+    setTargetHotend(0, N);              \
2104
+    temp_hotend[N].soft_pwm_amount = 0; \
2105
+    WRITE_HEATER_##N(LOW);              \
2123 2106
   }
2124 2107
 
2125 2108
   #if HAS_TEMP_HOTEND

+ 4
- 0
Marlin/src/pins/pins.h 파일 보기

@@ -1115,6 +1115,10 @@
1115 1115
   #define Z_MIN_PIN          -1
1116 1116
 #endif
1117 1117
 
1118
+#if HAS_FILAMENT_SENSOR
1119
+  #define FIL_RUNOUT1_PIN FIL_RUNOUT_PIN
1120
+#endif
1121
+
1118 1122
 #ifndef LCD_PINS_D4
1119 1123
   #define LCD_PINS_D4 -1
1120 1124
 #endif

Loading…
취소
저장