Browse Source

Add and apply REPEAT_1 macro

Scott Lahteine 3 years ago
parent
commit
f09fa69e86

+ 1
- 0
Marlin/src/core/macros.h View File

@@ -581,6 +581,7 @@
581 581
 // Repeat a macro passing S...N-1.
582 582
 #define REPEAT_S(S,N,OP)        EVAL(_REPEAT(S,SUB##S(N),OP))
583 583
 #define REPEAT(N,OP)            REPEAT_S(0,N,OP)
584
+#define REPEAT_1(N,OP)          REPEAT_S(1,INCREMENT(N),OP)
584 585
 
585 586
 // Repeat a macro passing 0...N-1 plus additional arguments.
586 587
 #define REPEAT2_S(S,N,OP,V...)  EVAL(_REPEAT2(S,SUB##S(N),OP,V))

+ 1
- 1
Marlin/src/core/serial.h View File

@@ -119,7 +119,7 @@ extern uint8_t marlin_debug_flags;
119 119
   #define __S_MULTI(N) decltype(SERIAL_LEAF_##N),
120 120
   #define _S_MULTI(N) __S_MULTI(N)
121 121
 
122
-  typedef MultiSerial< REPEAT_S(1, INCREMENT(NUM_SERIAL), _S_MULTI) 0> SerialOutputT;
122
+  typedef MultiSerial< REPEAT_1(NUM_SERIAL, _S_MULTI) 0> SerialOutputT;
123 123
 
124 124
   #undef __S_MULTI
125 125
   #undef _S_MULTI

+ 1
- 1
Marlin/src/feature/runout.h View File

@@ -207,7 +207,7 @@ class FilamentSensorBase {
207 207
     // Return a bitmask of runout pin states
208 208
     static inline uint8_t poll_runout_pins() {
209 209
       #define _OR_RUNOUT(N) | (READ(FIL_RUNOUT##N##_PIN) ? _BV((N) - 1) : 0)
210
-      return (0 REPEAT_S(1, INCREMENT(NUM_RUNOUT_SENSORS), _OR_RUNOUT));
210
+      return (0 REPEAT_1(NUM_RUNOUT_SENSORS, _OR_RUNOUT));
211 211
       #undef _OR_RUNOUT
212 212
     }
213 213
 

+ 4
- 2
Marlin/src/lcd/dogm/status_screen_DOGM.cpp View File

@@ -243,9 +243,11 @@ FORCE_INLINE void _draw_centered_temp(const celsius_t temp, const uint8_t tx, co
243 243
     #endif
244 244
 
245 245
     #if STATUS_HOTEND_BITMAPS > 1
246
-      static const unsigned char* const status_hotend_gfx[STATUS_HOTEND_BITMAPS] PROGMEM = ARRAY_N(STATUS_HOTEND_BITMAPS, OFF_BMP(1), OFF_BMP(2), OFF_BMP(3), OFF_BMP(4), OFF_BMP(5), OFF_BMP(6));
246
+      #define _OFF_BMP(N) OFF_BMP(N),
247
+      #define _ON_BMP(N)   ON_BMP(N),
248
+      static const unsigned char* const status_hotend_gfx[STATUS_HOTEND_BITMAPS] PROGMEM = { REPEAT_1(STATUS_HOTEND_BITMAPS, _OFF_BMP) };
247 249
       #if ANIM_HOTEND
248
-        static const unsigned char* const status_hotend_on_gfx[STATUS_HOTEND_BITMAPS] PROGMEM = ARRAY_N(STATUS_HOTEND_BITMAPS, ON_BMP(1), ON_BMP(2), ON_BMP(3), ON_BMP(4), ON_BMP(5), ON_BMP(6));
250
+        static const unsigned char* const status_hotend_on_gfx[STATUS_HOTEND_BITMAPS] PROGMEM = { REPEAT_1(STATUS_HOTEND_BITMAPS, _ON_BMP) };
249 251
         #define HOTEND_BITMAP(N,S) (unsigned char*)pgm_read_ptr((S) ? &status_hotend_on_gfx[(N) % (STATUS_HOTEND_BITMAPS)] : &status_hotend_gfx[(N) % (STATUS_HOTEND_BITMAPS)])
250 252
       #else
251 253
         #define HOTEND_BITMAP(N,S) (unsigned char*)pgm_read_ptr(&status_hotend_gfx[(N) % (STATUS_HOTEND_BITMAPS)])

+ 2
- 2
Marlin/src/lcd/marlinui.cpp View File

@@ -114,8 +114,8 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
114 114
   PGM_P MarlinUI::get_preheat_label(const uint8_t m) {
115 115
     #define _PDEF(N) static PGMSTR(preheat_##N##_label, PREHEAT_##N##_LABEL);
116 116
     #define _PLBL(N) preheat_##N##_label,
117
-    REPEAT_S(1, INCREMENT(PREHEAT_COUNT), _PDEF);
118
-    static PGM_P const preheat_labels[PREHEAT_COUNT] PROGMEM = { REPEAT_S(1, INCREMENT(PREHEAT_COUNT), _PLBL) };
117
+    REPEAT_1(PREHEAT_COUNT, _PDEF);
118
+    static PGM_P const preheat_labels[PREHEAT_COUNT] PROGMEM = { REPEAT_1(PREHEAT_COUNT, _PLBL) };
119 119
     return (PGM_P)pgm_read_ptr(&preheat_labels[m]);
120 120
   }
121 121
 #endif

+ 1
- 1
Marlin/src/module/endstops.cpp View File

@@ -475,7 +475,7 @@ void _O2 Endstops::report_states() {
475 475
       uint8_t state;
476 476
       switch (i) {
477 477
         default: continue;
478
-        REPEAT_S(1, INCREMENT(NUM_RUNOUT_SENSORS), _CASE_RUNOUT)
478
+        REPEAT_1(NUM_RUNOUT_SENSORS, _CASE_RUNOUT)
479 479
       }
480 480
       SERIAL_ECHOPGM(STR_FILAMENT_RUNOUT_SENSOR);
481 481
       if (i > 1) SERIAL_CHAR(' ', '0' + i);

Loading…
Cancel
Save