fastpath: use i2s#1 for 5th LED pin

use 4 RMT channels, then I2S#1, then RMT 5-8. This allows to have up to 5 "fast" LED pins.

"Even though the ESP32 has 8 channels of RMT hardware, using beyond 4 has shown to cause sending delays." (https://github.com/Makuna/NeoPixelBus/wiki/ESP32-NeoMethods#rmt)
This commit is contained in:
Frank
2023-05-03 00:29:14 +02:00
parent 56b6290fdd
commit 91d36fa269
3 changed files with 22 additions and 2 deletions

View File

@@ -9,6 +9,8 @@
#include "bus_wrapper.h"
#include "bus_manager.h"
//WLEDMM: #define DEBUGOUT(x) netDebugEnabled?NetDebug.print(x):Serial.print(x) not supported in this file as netDebugEnabled not in scope
#if 0
//colors.cpp
uint32_t colorBalanceFromKelvin(uint16_t kelvin, uint32_t rgb);
uint16_t approximateKelvinFromRGB(uint32_t rgb);
@@ -18,7 +20,6 @@ void colorRGBtoRGBW(byte* rgb);
uint8_t realtimeBroadcast(uint8_t type, IPAddress client, uint16_t length, byte *buffer, uint8_t bri=255, bool isRGBW=false);
// enable additional debug output
//WLEDMM: #define DEBUGOUT(x) netDebugEnabled?NetDebug.print(x):Serial.print(x) not supported in this file as netDebugEnabled not in scope
#if defined(WLED_DEBUG_HOST)
#include "net_debug.h"
#define DEBUGOUT NetDebug
@@ -38,6 +39,10 @@ uint8_t realtimeBroadcast(uint8_t type, IPAddress client, uint16_t length, byte
#define DEBUG_PRINTLN(x)
#define DEBUG_PRINTF(x...)
#endif
#else
// WLEDMM use wled.h
#include "wled.h"
#endif
//color mangling macros
#define RGBW32(r,g,b,w) (uint32_t((byte(w) << 24) | (byte(r) << 16) | (byte(g) << 8) | (byte(b))))
@@ -114,7 +119,11 @@ BusDigital::BusDigital(BusConfig &bc, uint8_t nr, const ColorOrderMap &com) : Bu
_busPtr = PolyBus::create(_iType, _pins, lenToCreate, nr);
_valid = (_busPtr != nullptr);
_colorOrder = bc.colorOrder;
DEBUG_PRINTF("%successfully inited strip %u (len %u) with type %u and pins %u,%u (itype %u)\n", _valid?"S":"Uns", nr, _len, bc.type, _pins[0],_pins[1],_iType);
if (_pins[1] != 255) { // WLEDMM USER_PRINTF
USER_PRINTF("%successfully inited strip %u (len %u) with type %u and pins %u,%u (itype %u)\n", _valid?"S":"Uns", nr, _len, bc.type, _pins[0],_pins[1],_iType);
} else {
USER_PRINTF("%successfully inited strip %u (len %u) with type %u and pin %u (itype %u)\n", _valid?"S":"Uns", nr, _len, bc.type, _pins[0],_iType);
}
}
void BusDigital::show() {

View File

@@ -928,9 +928,15 @@ class PolyBus {
if (num > 3) return I_NONE;
//if (num > 3) offset = num -4; // I2S not supported yet
#else
#ifndef WLEDMM_FASTPATH
// standard ESP32 has 8 RMT and 2 I2S channels
if (num > 9) return I_NONE;
if (num > 7) offset = num -7;
#else
// ESP32 "audio_fastpath" - 8 RMT and 1 I2S channels. RMT 5-8 have sending delays, so use I2S#1 as 5th bus, before going for RMT 5-8
if (num > 8) return I_NONE;
if (num == 4) offset = 2; // use I2S channel 2 as 5th bus. Ladies and Gentlemen, _this_ is a dirty hack.
#endif
#endif
switch (busType) {
case TYPE_WS2812_1CH_X3:

View File

@@ -43,8 +43,13 @@
#define WLED_MIN_VIRTUAL_BUSSES 4
#else
#if defined(USERMOD_AUDIOREACTIVE) // requested by @softhack007 https://github.com/blazoncek/WLED/issues/33
#ifndef WLEDMM_FASTPATH
#define WLED_MAX_BUSSES 8
#define WLED_MIN_VIRTUAL_BUSSES 2
#else
#define WLED_MAX_BUSSES 9 // WLEDMM I2S#1 is availeable for LEDs
#define WLED_MIN_VIRTUAL_BUSSES 1
#endif
#else
#define WLED_MAX_BUSSES 10
#define WLED_MIN_VIRTUAL_BUSSES 0