Browse Source

Add and apply REPEAT_1 macro

Scott Lahteine 4 years ago
parent
commit
f09fa69e86

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

581
 // Repeat a macro passing S...N-1.
581
 // Repeat a macro passing S...N-1.
582
 #define REPEAT_S(S,N,OP)        EVAL(_REPEAT(S,SUB##S(N),OP))
582
 #define REPEAT_S(S,N,OP)        EVAL(_REPEAT(S,SUB##S(N),OP))
583
 #define REPEAT(N,OP)            REPEAT_S(0,N,OP)
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
 // Repeat a macro passing 0...N-1 plus additional arguments.
586
 // Repeat a macro passing 0...N-1 plus additional arguments.
586
 #define REPEAT2_S(S,N,OP,V...)  EVAL(_REPEAT2(S,SUB##S(N),OP,V))
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
   #define __S_MULTI(N) decltype(SERIAL_LEAF_##N),
119
   #define __S_MULTI(N) decltype(SERIAL_LEAF_##N),
120
   #define _S_MULTI(N) __S_MULTI(N)
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
   #undef __S_MULTI
124
   #undef __S_MULTI
125
   #undef _S_MULTI
125
   #undef _S_MULTI

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

207
     // Return a bitmask of runout pin states
207
     // Return a bitmask of runout pin states
208
     static inline uint8_t poll_runout_pins() {
208
     static inline uint8_t poll_runout_pins() {
209
       #define _OR_RUNOUT(N) | (READ(FIL_RUNOUT##N##_PIN) ? _BV((N) - 1) : 0)
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
       #undef _OR_RUNOUT
211
       #undef _OR_RUNOUT
212
     }
212
     }
213
 
213
 

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

243
     #endif
243
     #endif
244
 
244
 
245
     #if STATUS_HOTEND_BITMAPS > 1
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
       #if ANIM_HOTEND
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
         #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)])
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
       #else
252
       #else
251
         #define HOTEND_BITMAP(N,S) (unsigned char*)pgm_read_ptr(&status_hotend_gfx[(N) % (STATUS_HOTEND_BITMAPS)])
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
   PGM_P MarlinUI::get_preheat_label(const uint8_t m) {
114
   PGM_P MarlinUI::get_preheat_label(const uint8_t m) {
115
     #define _PDEF(N) static PGMSTR(preheat_##N##_label, PREHEAT_##N##_LABEL);
115
     #define _PDEF(N) static PGMSTR(preheat_##N##_label, PREHEAT_##N##_LABEL);
116
     #define _PLBL(N) preheat_##N##_label,
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
     return (PGM_P)pgm_read_ptr(&preheat_labels[m]);
119
     return (PGM_P)pgm_read_ptr(&preheat_labels[m]);
120
   }
120
   }
121
 #endif
121
 #endif

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

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

Loading…
Cancel
Save