From 539ba116902e9db3f2c45685e24dc353a9c66dfa Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Mon, 5 Oct 2020 19:03:40 +0200 Subject: [PATCH] Add support for inverted NeoPixelBus data Add support for inverted NeoPixelBus data line by enabling ``#define USE_WS2812_INVERTED`` (#8988) --- RELEASENOTES.md | 1 + tasmota/CHANGELOG.md | 1 + tasmota/my_user_config.h | 1 + tasmota/xlgt_01_ws2812.ino | 34 ++++++++++++++++++++++++++++++++-- 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index a860f942f..46e203c81 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -79,3 +79,4 @@ The attached binaries can also be downloaded from http://ota.tasmota.com/tasmota - Add optional support for Mitsubishi Electric HVAC by David Gwynne (#9237) - Add optional support for Orno WE517-Modbus energy meter by Maxime Vincent (#9353) - Add SDM630 three phase ImportActive Energy display when ``#define SDM630_IMPORT`` is enabled by Janusz Kostorz (#9124) +- Add support for inverted NeoPixelBus data line by enabling ``#define USE_WS2812_INVERTED`` (#8988) diff --git a/tasmota/CHANGELOG.md b/tasmota/CHANGELOG.md index 7c107d184..d4296a9ee 100644 --- a/tasmota/CHANGELOG.md +++ b/tasmota/CHANGELOG.md @@ -20,6 +20,7 @@ - Add optional support for Mitsubishi Electric HVAC by David Gwynne (#9237) - Add optional support for Orno WE517-Modbus energy meter by Maxime Vincent (#9353) - Add SDM630 three phase ImportActive Energy display when ``#define SDM630_IMPORT`` is enabled by Janusz Kostorz (#9124) +- Add support for inverted NeoPixelBus data line by enabling ``#define USE_WS2812_INVERTED`` (#8988) ## Released diff --git a/tasmota/my_user_config.h b/tasmota/my_user_config.h index 82eb7aa39..89fdd678d 100644 --- a/tasmota/my_user_config.h +++ b/tasmota/my_user_config.h @@ -474,6 +474,7 @@ // -- Optional light modules ---------------------- #define USE_WS2812 // WS2812 Led string using library NeoPixelBus (+5k code, +1k mem, 232 iram) - Disable by // // #define USE_WS2812_DMA // DMA supports only GPIO03 (= Serial RXD) (+1k mem). When USE_WS2812_DMA is enabled expect Exceptions on Pow +// #define USE_WS2812_INVERTED // Use inverted data signal #define USE_WS2812_HARDWARE NEO_HW_WS2812 // Hardware type (NEO_HW_WS2812, NEO_HW_WS2812X, NEO_HW_WS2813, NEO_HW_SK6812, NEO_HW_LC8812, NEO_HW_APA106) #define USE_WS2812_CTYPE NEO_GRB // Color type (NEO_RGB, NEO_GRB, NEO_BRG, NEO_RBG, NEO_RGBW, NEO_GRBW) #define USE_MY92X1 // Add support for MY92X1 RGBCW led controller as used in Sonoff B1, Ailight and Lohas diff --git a/tasmota/xlgt_01_ws2812.ino b/tasmota/xlgt_01_ws2812.ino index 368567181..e22d090d4 100644 --- a/tasmota/xlgt_01_ws2812.ino +++ b/tasmota/xlgt_01_ws2812.ino @@ -63,7 +63,21 @@ void (* const Ws2812Command[])(void) PROGMEM = { #ifdef USE_WS2812_DMA +#ifdef USE_WS2812_INVERTED // See NeoEspDmaMethod.h for available options + +#if (USE_WS2812_HARDWARE == NEO_HW_WS2812X) + typedef NeoEsp8266DmaInvertedWs2812xMethod selectedNeoSpeedType; +#elif (USE_WS2812_HARDWARE == NEO_HW_SK6812) + typedef NeoEsp8266DmaInvertedSk6812Method selectedNeoSpeedType; +#elif (USE_WS2812_HARDWARE == NEO_HW_APA106) + typedef NeoEsp8266DmaInvertedApa106Method selectedNeoSpeedType; +#else // USE_WS2812_HARDWARE + typedef NeoEsp8266DmaInverted800KbpsMethod selectedNeoSpeedType; +#endif // USE_WS2812_HARDWARE + +#else // No USE_WS2812_INVERTED + #if (USE_WS2812_HARDWARE == NEO_HW_WS2812X) typedef NeoEsp8266DmaWs2812xMethod selectedNeoSpeedType; #elif (USE_WS2812_HARDWARE == NEO_HW_SK6812) @@ -74,9 +88,23 @@ void (* const Ws2812Command[])(void) PROGMEM = { typedef NeoEsp8266Dma800KbpsMethod selectedNeoSpeedType; #endif // USE_WS2812_HARDWARE -#else // USE_WS2812_DMA +#endif // No USE_WS2812_INVERTED +#else // No USE_WS2812_DMA + +#ifdef USE_WS2812_INVERTED // See NeoEspBitBangMethod.h for available options + +#if (USE_WS2812_HARDWARE == NEO_HW_WS2812X) + typedef NeoEsp8266BitBangWs2812xInvertedMethod selectedNeoSpeedType; +#elif (USE_WS2812_HARDWARE == NEO_HW_SK6812) + typedef NeoEsp8266BitBangSk6812InvertedMethod selectedNeoSpeedType; +#else // USE_WS2812_HARDWARE + typedef NeoEsp8266BitBang400KbpsInvertedMethod selectedNeoSpeedType; +#endif // USE_WS2812_HARDWARE + +#else // No USE_WS2812_INVERTED + #if (USE_WS2812_HARDWARE == NEO_HW_WS2812X) typedef NeoEsp8266BitBangWs2812xMethod selectedNeoSpeedType; #elif (USE_WS2812_HARDWARE == NEO_HW_SK6812) @@ -85,7 +113,9 @@ void (* const Ws2812Command[])(void) PROGMEM = { typedef NeoEsp8266BitBang800KbpsMethod selectedNeoSpeedType; #endif // USE_WS2812_HARDWARE -#endif // USE_WS2812_DMA +#endif // No USE_WS2812_INVERTED + +#endif // No USE_WS2812_DMA NeoPixelBus *strip = nullptr;