Skip to content

Commit 20ed81c

Browse files
committed
Prefer I2S1 over RMT on ESP32
- remove Audioreactive limitation
1 parent 6f38874 commit 20ed81c

File tree

3 files changed

+36
-23
lines changed

3 files changed

+36
-23
lines changed

wled00/bus_manager.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ BusDigital::BusDigital(BusConfig &bc, uint8_t nr, const ColorOrderMap &com)
129129
if (bc.type == TYPE_WS2812_1CH_X3) lenToCreate = NUM_ICS_WS2812_1CH_3X(bc.count); // only needs a third of "RGB" LEDs for NeoPixelBus
130130
_busPtr = PolyBus::create(_iType, _pins, lenToCreate + _skip, nr, _frequencykHz);
131131
_valid = (_busPtr != nullptr);
132-
DEBUG_PRINTF("%successfully inited strip %u (len %u) with type %u and pins %u,%u (itype %u). mA=%d/%d\n", _valid?"S":"Uns", nr, bc.count, bc.type, _pins[0], _pins[1], _iType, _milliAmpsPerLed, _milliAmpsMax);
132+
DEBUG_PRINTF_P(PSTR("%successfully inited strip %u (len %u) with type %u and pins %u,%u (itype %u). mA=%d/%d\n"), _valid?"S":"Uns", nr, bc.count, bc.type, _pins[0], IS_2PIN(bc.type)?_pins[1]:255, _iType, _milliAmpsPerLed, _milliAmpsMax);
133133
}
134134

135135
//fine tune power estimation constants for your setup

wled00/bus_wrapper.h

+29-8
Original file line numberDiff line numberDiff line change
@@ -206,81 +206,101 @@
206206
//RGB
207207
#define B_32_RN_NEO_3 NeoPixelBusLg<NeoGrbFeature, NeoEsp32RmtNWs2812xMethod, NeoGammaNullMethod>
208208
#ifndef WLED_NO_I2S0_PIXELBUS
209-
#define B_32_I0_NEO_3 NeoPixelBusLg<NeoGrbFeature, NeoEsp32I2s0800KbpsMethod, NeoGammaNullMethod>
209+
#define B_32_I0_NEO_3 NeoPixelBusLg<NeoGrbFeature, NeoEsp32I2s0Ws2812xMethod, NeoGammaNullMethod>
210+
//#define B_32_I0_NEO_3 NeoPixelBusLg<NeoGrbFeature, NeoEsp32I2s0X8Ws2812xMethod, NeoGammaNullMethod> // parallel I2S
210211
#endif
211212
#ifndef WLED_NO_I2S1_PIXELBUS
212-
#define B_32_I1_NEO_3 NeoPixelBusLg<NeoGrbFeature, NeoEsp32I2s1800KbpsMethod, NeoGammaNullMethod>
213+
#define B_32_I1_NEO_3 NeoPixelBusLg<NeoGrbFeature, NeoEsp32I2s1Ws2812xMethod, NeoGammaNullMethod>
214+
//#define B_32_I1_NEO_3 NeoPixelBusLg<NeoGrbFeature, NeoEsp32I2s1X8Ws2812xMethod, NeoGammaNullMethod> // parallel I2S
213215
#endif
214216
//RGBW
215-
#define B_32_RN_NEO_4 NeoPixelBusLg<NeoGrbwFeature, NeoEsp32RmtNWs2812xMethod, NeoGammaNullMethod>
217+
#define B_32_RN_NEO_4 NeoPixelBusLg<NeoGrbwFeature, NeoEsp32RmtNSk6812Method, NeoGammaNullMethod>
216218
#ifndef WLED_NO_I2S0_PIXELBUS
217-
#define B_32_I0_NEO_4 NeoPixelBusLg<NeoGrbwFeature, NeoEsp32I2s0800KbpsMethod, NeoGammaNullMethod>
219+
#define B_32_I0_NEO_4 NeoPixelBusLg<NeoGrbwFeature, NeoEsp32I2s0Sk6812Method, NeoGammaNullMethod>
220+
//#define B_32_I0_NEO_4 NeoPixelBusLg<NeoGrbwFeature, NeoEsp32I2s0X8Sk6812Method, NeoGammaNullMethod> // parallel I2S
218221
#endif
219222
#ifndef WLED_NO_I2S1_PIXELBUS
220-
#define B_32_I1_NEO_4 NeoPixelBusLg<NeoGrbwFeature, NeoEsp32I2s1800KbpsMethod, NeoGammaNullMethod>
223+
#define B_32_I1_NEO_4 NeoPixelBusLg<NeoGrbwFeature, NeoEsp32I2s1Sk6812Method, NeoGammaNullMethod>
224+
//#define B_32_I1_NEO_4 NeoPixelBusLg<NeoGrbwFeature, NeoEsp32I2s1X8Sk6812Method, NeoGammaNullMethod> // parallel I2S
221225
#endif
222226
//400Kbps
223227
#define B_32_RN_400_3 NeoPixelBusLg<NeoGrbFeature, NeoEsp32RmtN400KbpsMethod, NeoGammaNullMethod>
224228
#ifndef WLED_NO_I2S0_PIXELBUS
225229
#define B_32_I0_400_3 NeoPixelBusLg<NeoGrbFeature, NeoEsp32I2s0400KbpsMethod, NeoGammaNullMethod>
230+
//#define B_32_I0_400_3 NeoPixelBusLg<NeoGrbFeature, NeoEsp32I2s0X8400KbpsMethod, NeoGammaNullMethod> // parallel I2S
226231
#endif
227232
#ifndef WLED_NO_I2S1_PIXELBUS
228233
#define B_32_I1_400_3 NeoPixelBusLg<NeoGrbFeature, NeoEsp32I2s1400KbpsMethod, NeoGammaNullMethod>
234+
//#define B_32_I1_400_3 NeoPixelBusLg<NeoGrbFeature, NeoEsp32I2s1X8400KbpsMethod, NeoGammaNullMethod> // parallel I2S
229235
#endif
230236
//TM1814 (RGBW)
231237
#define B_32_RN_TM1_4 NeoPixelBusLg<NeoWrgbTm1814Feature, NeoEsp32RmtNTm1814Method, NeoGammaNullMethod>
232238
#ifndef WLED_NO_I2S0_PIXELBUS
233239
#define B_32_I0_TM1_4 NeoPixelBusLg<NeoWrgbTm1814Feature, NeoEsp32I2s0Tm1814Method, NeoGammaNullMethod>
240+
//#define B_32_I0_TM1_4 NeoPixelBusLg<NeoWrgbTm1814Feature, NeoEsp32I2s0X8Tm1814Method, NeoGammaNullMethod> // parallel I2S
234241
#endif
235242
#ifndef WLED_NO_I2S1_PIXELBUS
236243
#define B_32_I1_TM1_4 NeoPixelBusLg<NeoWrgbTm1814Feature, NeoEsp32I2s1Tm1814Method, NeoGammaNullMethod>
244+
//#define B_32_I1_TM1_4 NeoPixelBusLg<NeoWrgbTm1814Feature, NeoEsp32I2s1X8Tm1814Method, NeoGammaNullMethod> // parallel I2S
237245
#endif
238246
//TM1829 (RGB)
239247
#define B_32_RN_TM2_3 NeoPixelBusLg<NeoBrgFeature, NeoEsp32RmtNTm1829Method, NeoGammaNullMethod>
240248
#ifndef WLED_NO_I2S0_PIXELBUS
241249
#define B_32_I0_TM2_3 NeoPixelBusLg<NeoBrgFeature, NeoEsp32I2s0Tm1829Method, NeoGammaNullMethod>
250+
//#define B_32_I0_TM2_3 NeoPixelBusLg<NeoBrgFeature, NeoEsp32I2s0X8Tm1829Method, NeoGammaNullMethod> // parallel I2S
242251
#endif
243252
#ifndef WLED_NO_I2S1_PIXELBUS
244253
#define B_32_I1_TM2_3 NeoPixelBusLg<NeoBrgFeature, NeoEsp32I2s1Tm1829Method, NeoGammaNullMethod>
254+
//#define B_32_I1_TM2_3 NeoPixelBusLg<NeoBrgFeature, NeoEsp32I2s1X8Tm1829Method, NeoGammaNullMethod> // parallel I2S
245255
#endif
246256
//UCS8903
247257
#define B_32_RN_UCS_3 NeoPixelBusLg<NeoRgbUcs8903Feature, NeoEsp32RmtNWs2812xMethod, NeoGammaNullMethod>
248258
#ifndef WLED_NO_I2S0_PIXELBUS
249259
#define B_32_I0_UCS_3 NeoPixelBusLg<NeoRgbUcs8903Feature, NeoEsp32I2s0800KbpsMethod, NeoGammaNullMethod>
260+
//#define B_32_I0_UCS_3 NeoPixelBusLg<NeoRgbUcs8903Feature, NeoEsp32I2s0X8800KbpsMethod, NeoGammaNullMethod> // parallel I2S
250261
#endif
251262
#ifndef WLED_NO_I2S1_PIXELBUS
252263
#define B_32_I1_UCS_3 NeoPixelBusLg<NeoRgbUcs8903Feature, NeoEsp32I2s1800KbpsMethod, NeoGammaNullMethod>
264+
//#define B_32_I1_UCS_3 NeoPixelBusLg<NeoRgbUcs8903Feature, NeoEsp32I2s1X8800KbpsMethod, NeoGammaNullMethod> // parallel I2S
253265
#endif
254266
//UCS8904
255267
#define B_32_RN_UCS_4 NeoPixelBusLg<NeoRgbwUcs8904Feature, NeoEsp32RmtNWs2812xMethod, NeoGammaNullMethod>
256268
#ifndef WLED_NO_I2S0_PIXELBUS
257269
#define B_32_I0_UCS_4 NeoPixelBusLg<NeoRgbwUcs8904Feature, NeoEsp32I2s0800KbpsMethod, NeoGammaNullMethod>
270+
//#define B_32_I0_UCS_4 NeoPixelBusLg<NeoRgbwUcs8904Feature, NeoEsp32I2s0X8800KbpsMethod, NeoGammaNullMethod>// parallel I2S
258271
#endif
259272
#ifndef WLED_NO_I2S1_PIXELBUS
260273
#define B_32_I1_UCS_4 NeoPixelBusLg<NeoRgbwUcs8904Feature, NeoEsp32I2s1800KbpsMethod, NeoGammaNullMethod>
274+
//#define B_32_I1_UCS_4 NeoPixelBusLg<NeoRgbwUcs8904Feature, NeoEsp32I2s1X8800KbpsMethod, NeoGammaNullMethod>// parallel I2S
261275
#endif
262276
#define B_32_RN_APA106_3 NeoPixelBusLg<NeoGrbFeature, NeoEsp32RmtNApa106Method, NeoGammaNullMethod>
263277
#ifndef WLED_NO_I2S0_PIXELBUS
264278
#define B_32_I0_APA106_3 NeoPixelBusLg<NeoGrbFeature, NeoEsp32I2s0Apa106Method, NeoGammaNullMethod>
279+
//#define B_32_I0_APA106_3 NeoPixelBusLg<NeoGrbFeature, NeoEsp32I2s0X8Apa106Method, NeoGammaNullMethod> // parallel I2S
265280
#endif
266281
#ifndef WLED_NO_I2S1_PIXELBUS
267282
#define B_32_I1_APA106_3 NeoPixelBusLg<NeoGrbFeature, NeoEsp32I2s1Apa106Method, NeoGammaNullMethod>
283+
//#define B_32_I1_APA106_3 NeoPixelBusLg<NeoGrbFeature, NeoEsp32I2s1X8Apa106Method, NeoGammaNullMethod> // parallel I2S
268284
#endif
269285
//FW1906 GRBCW
270286
#define B_32_RN_FW6_5 NeoPixelBusLg<NeoGrbcwxFeature, NeoEsp32RmtNWs2812xMethod, NeoGammaNullMethod>
271287
#ifndef WLED_NO_I2S0_PIXELBUS
272288
#define B_32_I0_FW6_5 NeoPixelBusLg<NeoGrbcwxFeature, NeoEsp32I2s0800KbpsMethod, NeoGammaNullMethod>
289+
//#define B_32_I0_FW6_5 NeoPixelBusLg<NeoGrbcwxFeature, NeoEsp32I2s0X8800KbpsMethod, NeoGammaNullMethod> // parallel I2S
273290
#endif
274291
#ifndef WLED_NO_I2S1_PIXELBUS
275292
#define B_32_I1_FW6_5 NeoPixelBusLg<NeoGrbcwxFeature, NeoEsp32I2s1800KbpsMethod, NeoGammaNullMethod>
293+
//#define B_32_I1_FW6_5 NeoPixelBusLg<NeoGrbcwxFeature, NeoEsp32I2s1X8800KbpsMethod, NeoGammaNullMethod> // parallel I2S
276294
#endif
277295
//WS2805 RGBWC
278296
#define B_32_RN_2805_5 NeoPixelBusLg<NeoGrbwwFeature, NeoEsp32RmtNWs2805Method, NeoGammaNullMethod>
279297
#ifndef WLED_NO_I2S0_PIXELBUS
280298
#define B_32_I0_2805_5 NeoPixelBusLg<NeoGrbwwFeature, NeoEsp32I2s0Ws2805Method, NeoGammaNullMethod>
299+
//#define B_32_I0_2805_5 NeoPixelBusLg<NeoGrbwwFeature, NeoEsp32I2s0X8Ws2805Method, NeoGammaNullMethod> // parallel I2S
281300
#endif
282301
#ifndef WLED_NO_I2S1_PIXELBUS
283302
#define B_32_I1_2805_5 NeoPixelBusLg<NeoGrbwwFeature, NeoEsp32I2s1Ws2805Method, NeoGammaNullMethod>
303+
//#define B_32_I1_2805_5 NeoPixelBusLg<NeoGrbwwFeature, NeoEsp32I2s1X8Ws2805Method, NeoGammaNullMethod> // parallel I2S
284304
#endif
285305
#endif
286306

@@ -1458,11 +1478,11 @@ class PolyBus {
14581478
return I_8266_U0_2805_5 + offset;
14591479
}
14601480
#else //ESP32
1461-
uint8_t offset = 0; //0 = RMT (num 0-7) 8 = I2S0 9 = I2S1
1481+
uint8_t offset = 0; // 0 = RMT (num 1-8), 1 = I2S0 (used by Audioreactive), 2 = I2S1
14621482
#if defined(CONFIG_IDF_TARGET_ESP32S2)
14631483
// ESP32-S2 only has 4 RMT channels
14641484
if (num > 4) return I_NONE;
1465-
if (num > 3) offset = 1; // only one I2S
1485+
if (num > 3) offset = 1; // only one I2S (use last to allow Audioreactive)
14661486
#elif defined(CONFIG_IDF_TARGET_ESP32C3)
14671487
// On ESP32-C3 only the first 2 RMT channels are usable for transmitting
14681488
if (num > 1) return I_NONE;
@@ -1474,7 +1494,8 @@ class PolyBus {
14741494
#else
14751495
// standard ESP32 has 8 RMT and 2 I2S channels
14761496
if (num > 9) return I_NONE;
1477-
if (num > 7) offset = num -7;
1497+
if (num > 8) offset = 1;
1498+
if (num == 0) offset = 2; // prefer I2S1 for 1st bus (less flickering but more RAM needed)
14781499
#endif
14791500
switch (busType) {
14801501
case TYPE_WS2812_1CH_X3:

wled00/const.h

+6-14
Original file line numberDiff line numberDiff line change
@@ -53,24 +53,16 @@
5353
#define WLED_MAX_BUSSES 3 // will allow 2 digital & 1 analog (or the other way around)
5454
#define WLED_MIN_VIRTUAL_BUSSES 3
5555
#elif defined(CONFIG_IDF_TARGET_ESP32S2) // 4 RMT, 8 LEDC, only has 1 I2S bus, supported in NPB
56-
#if defined(USERMOD_AUDIOREACTIVE) // requested by @softhack007 https://github.com/blazoncek/WLED/issues/33
57-
#define WLED_MAX_BUSSES 6 // will allow 4 digital & 2 analog
58-
#define WLED_MIN_VIRTUAL_BUSSES 4
59-
#else
60-
#define WLED_MAX_BUSSES 7 // will allow 5 digital & 2 analog
61-
#define WLED_MIN_VIRTUAL_BUSSES 3
62-
#endif
56+
// the 5th bus (I2S) will prevent Audioreactive usermod from functioning (it is last used though)
57+
#define WLED_MAX_BUSSES 7 // will allow 5 digital & 2 analog
58+
#define WLED_MIN_VIRTUAL_BUSSES 3
6359
#elif defined(CONFIG_IDF_TARGET_ESP32S3) // 4 RMT, 8 LEDC, has 2 I2S but NPB does not support them ATM
6460
#define WLED_MAX_BUSSES 6 // will allow 4 digital & 2 analog
6561
#define WLED_MIN_VIRTUAL_BUSSES 4
6662
#else
67-
#if defined(USERMOD_AUDIOREACTIVE) // requested by @softhack007 https://github.com/blazoncek/WLED/issues/33
68-
#define WLED_MAX_BUSSES 8
69-
#define WLED_MIN_VIRTUAL_BUSSES 2
70-
#else
71-
#define WLED_MAX_BUSSES 10
72-
#define WLED_MIN_VIRTUAL_BUSSES 0
73-
#endif
63+
// the 10th digital bus (I2S0) will prevent Audioreactive usermod from functioning (it is last used though)
64+
#define WLED_MAX_BUSSES 10
65+
#define WLED_MIN_VIRTUAL_BUSSES 0
7466
#endif
7567
#endif
7668
#else

0 commit comments

Comments
 (0)