Browse Source

Add and apply REPEAT_1 macro

vanilla_fb_2.0.x
Scott Lahteine 4 years ago
parent
commit
ad991734c4
  1. 1
      Marlin/src/core/macros.h
  2. 2
      Marlin/src/core/serial.h
  3. 2
      Marlin/src/feature/runout.h
  4. 6
      Marlin/src/lcd/dogm/status_screen_DOGM.cpp
  5. 4
      Marlin/src/lcd/marlinui.cpp
  6. 2
      Marlin/src/module/endstops.cpp

1
Marlin/src/core/macros.h

@ -581,6 +581,7 @@
// Repeat a macro passing S...N-1. // Repeat a macro passing S...N-1.
#define REPEAT_S(S,N,OP) EVAL(_REPEAT(S,SUB##S(N),OP)) #define REPEAT_S(S,N,OP) EVAL(_REPEAT(S,SUB##S(N),OP))
#define REPEAT(N,OP) REPEAT_S(0,N,OP) #define REPEAT(N,OP) REPEAT_S(0,N,OP)
#define REPEAT_1(N,OP) REPEAT_S(1,INCREMENT(N),OP)
// 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))

2
Marlin/src/core/serial.h

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

2
Marlin/src/feature/runout.h

@ -207,7 +207,7 @@ class FilamentSensorBase {
// 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() {
#define _OR_RUNOUT(N) | (READ(FIL_RUNOUT##N##_PIN) ? _BV((N) - 1) : 0) #define _OR_RUNOUT(N) | (READ(FIL_RUNOUT##N##_PIN) ? _BV((N) - 1) : 0)
return (0 REPEAT_S(1, INCREMENT(NUM_RUNOUT_SENSORS), _OR_RUNOUT)); return (0 REPEAT_1(NUM_RUNOUT_SENSORS, _OR_RUNOUT));
#undef _OR_RUNOUT #undef _OR_RUNOUT
} }

6
Marlin/src/lcd/dogm/status_screen_DOGM.cpp

@ -243,9 +243,11 @@ FORCE_INLINE void _draw_centered_temp(const celsius_t temp, const uint8_t tx, co
#endif #endif
#if STATUS_HOTEND_BITMAPS > 1 #if STATUS_HOTEND_BITMAPS > 1
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)); #define _OFF_BMP(N) OFF_BMP(N),
#define _ON_BMP(N) ON_BMP(N),
static const unsigned char* const status_hotend_gfx[STATUS_HOTEND_BITMAPS] PROGMEM = { REPEAT_1(STATUS_HOTEND_BITMAPS, _OFF_BMP) };
#if ANIM_HOTEND #if ANIM_HOTEND
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)); static const unsigned char* const status_hotend_on_gfx[STATUS_HOTEND_BITMAPS] PROGMEM = { REPEAT_1(STATUS_HOTEND_BITMAPS, _ON_BMP) };
#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)]) #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)])
#else #else
#define HOTEND_BITMAP(N,S) (unsigned char*)pgm_read_ptr(&status_hotend_gfx[(N) % (STATUS_HOTEND_BITMAPS)]) #define HOTEND_BITMAP(N,S) (unsigned char*)pgm_read_ptr(&status_hotend_gfx[(N) % (STATUS_HOTEND_BITMAPS)])

4
Marlin/src/lcd/marlinui.cpp

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

2
Marlin/src/module/endstops.cpp

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

Loading…
Cancel
Save