Skip to content

Commit e834de2

Browse files
committed
make WLED_MAX_BUSSES constexpr
prevent macro expansion problems, because WLED_MAX_ANALOG_CHANNELS is a constexpr now.
1 parent 3a2674a commit e834de2

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

wled00/const.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ constexpr size_t FIXED_PALETTE_COUNT = DYNAMIC_PALETTE_COUNT + FASTLED_PALETTE_C
6666
#endif
6767

6868
// define -> constexpr to avoid preprocessor errors and enum arithmetic warnings from newer compilers
69+
#ifdef WLED_MAX_ANALOG_CHANNELS
70+
#undef WLED_MAX_ANALOG_CHANNELS // avoid clash between macro name and constexpr constant
71+
#endif
6972
constexpr size_t WLED_MAX_ANALOG_CHANNELS = static_cast<size_t>(LEDC_CHANNEL_MAX) * static_cast<size_t>(LEDC_SPEED_MODE_MAX);
7073

7174
#if defined(CONFIG_IDF_TARGET_ESP32C3) // 2 RMT, 6 LEDC, only has 1 I2S but NPB does not support it ATM
@@ -103,7 +106,8 @@ constexpr size_t FIXED_PALETTE_COUNT = DYNAMIC_PALETTE_COUNT + FASTLED_PALETTE_C
103106
#ifdef WLED_MAX_BUSSES
104107
#undef WLED_MAX_BUSSES
105108
#endif
106-
#define WLED_MAX_BUSSES (WLED_MAX_DIGITAL_CHANNELS+WLED_MAX_ANALOG_CHANNELS)
109+
// define -> constexpr to align with defintion of WLED_MAX_ANALOG_CHANNELS
110+
constexpr size_t WLED_MAX_BUSSES = WLED_MAX_DIGITAL_CHANNELS + WLED_MAX_ANALOG_CHANNELS;
107111
static_assert(WLED_MAX_BUSSES <= 32, "WLED_MAX_BUSSES exceeds hard limit");
108112

109113
// Maximum number of pins per output. 5 for RGBCCT analog LEDs.

0 commit comments

Comments
 (0)