diff --git a/wled00/bus_manager.h b/wled00/bus_manager.h index 265da36c..8ed68020 100644 --- a/wled00/bus_manager.h +++ b/wled00/bus_manager.h @@ -122,7 +122,7 @@ class BusDigital : public Bus { //Fix for turning off onboard LED breaking bus #ifdef LED_BUILTIN if (_bri == 0 && b > 0) { - if (_pins[0] == LED_BUILTIN || _pins[1] == LED_BUILTIN) PolyBus::begin(_busPtr, _iType); + if (_pins[0] == LED_BUILTIN || _pins[1] == LED_BUILTIN) PolyBus::begin(_busPtr, _iType, _pins); } #endif _bri = b; @@ -159,7 +159,7 @@ class BusDigital : public Bus { } void reinit() { - PolyBus::begin(_busPtr, _iType); + PolyBus::begin(_busPtr, _iType, _pins); } void cleanup() { diff --git a/wled00/bus_wrapper.h b/wled00/bus_wrapper.h index 3e3c0d8e..da3f96e3 100644 --- a/wled00/bus_wrapper.h +++ b/wled00/bus_wrapper.h @@ -191,7 +191,7 @@ //handles pointer type conversion for all possible bus types class PolyBus { public: - static void begin(void* busPtr, uint8_t busType) { + static void begin(void* busPtr, uint8_t busType, uint8_t* pins) { switch (busType) { case I_NONE: break; #ifdef ESP8266 @@ -211,6 +211,10 @@ class PolyBus { case I_8266_U1_TM1_4: (static_cast(busPtr))->Begin(); break; case I_8266_DM_TM1_4: (static_cast(busPtr))->Begin(); break; case I_8266_BB_TM1_4: (static_cast(busPtr))->Begin(); break; + case I_HS_DOT_3: (static_cast(busPtr))->Begin(); break; + case I_HS_LPD_3: (static_cast(busPtr))->Begin(); break; + case I_HS_WS1_3: (static_cast(busPtr))->Begin(); break; + case I_HS_P98_3: (static_cast(busPtr))->Begin(); break; #endif #ifdef ARDUINO_ARCH_ESP32 case I_32_R0_NEO_3: (static_cast(busPtr))->Begin(); break; @@ -253,14 +257,15 @@ class PolyBus { case I_32_R7_TM1_4: (static_cast(busPtr))->Begin(); break; case I_32_I0_TM1_4: (static_cast(busPtr))->Begin(); break; case I_32_I1_TM1_4: (static_cast(busPtr))->Begin(); break; + // ESP32 can (and should, to avoid inadvertantly driving the chip select signal) specify the pins used for SPI, but only in begin() + case I_HS_DOT_3: (static_cast(busPtr))->Begin(pins[1], -1, pins[0], -1); break; + case I_HS_LPD_3: (static_cast(busPtr))->Begin(pins[1], -1, pins[0], -1); break; + case I_HS_WS1_3: (static_cast(busPtr))->Begin(pins[1], -1, pins[0], -1); break; + case I_HS_P98_3: (static_cast(busPtr))->Begin(pins[1], -1, pins[0], -1); break; #endif - case I_HS_DOT_3: (static_cast(busPtr))->Begin(); break; case I_SS_DOT_3: (static_cast(busPtr))->Begin(); break; - case I_HS_LPD_3: (static_cast(busPtr))->Begin(); break; case I_SS_LPD_3: (static_cast(busPtr))->Begin(); break; - case I_HS_WS1_3: (static_cast(busPtr))->Begin(); break; case I_SS_WS1_3: (static_cast(busPtr))->Begin(); break; - case I_HS_P98_3: (static_cast(busPtr))->Begin(); break; case I_SS_P98_3: (static_cast(busPtr))->Begin(); break; } }; @@ -338,7 +343,7 @@ class PolyBus { case I_HS_P98_3: busPtr = new B_HS_P98_3(len, pins[1], pins[0]); break; case I_SS_P98_3: busPtr = new B_SS_P98_3(len, pins[1], pins[0]); break; } - begin(busPtr, busType); + begin(busPtr, busType, pins); return busPtr; }; static void show(void* busPtr, uint8_t busType) { @@ -831,8 +836,7 @@ class PolyBus { #ifdef ESP8266 if (pins[0] == P_8266_HS_MOSI && pins[1] == P_8266_HS_CLK) isHSPI = true; #else - if (pins[0] == P_32_HS_MOSI && pins[1] == P_32_HS_CLK) isHSPI = true; - if (pins[0] == P_32_VS_MOSI && pins[1] == P_32_VS_CLK) isHSPI = true; + if(!num) isHSPI = true; // temporary hack to limit use of hardware SPI to a single SPI peripheral: only allow ESP32 hardware serial on segment 0 #endif uint8_t t = I_NONE; switch (busType) {