diff --git a/sonoff/_changelog.ino b/sonoff/_changelog.ino index b94815cd0..edcfbd87b 100644 --- a/sonoff/_changelog.ino +++ b/sonoff/_changelog.ino @@ -2,6 +2,7 @@ * 6.6.0.9 20190828 * Change theoretical baudrate range to 300..19660500 bps in 300 increments (#6294) * Add Full support of all protocols in IRremoteESP8266, to be used on dedicated-IR Tasmota version. Warning: +81k Flash when compiling with USE_IR_REMOTE_FULL + * Add compile time define USE_WS2812_HARDWARE to select hardware type WS2812, WS2812X, WS2813, SK6812, LC8812 or APA106 (DMA mode only) * * 6.6.0.8 20190827 * Add Tuya Energy monitoring by Shantur Rathore diff --git a/sonoff/my_user_config.h b/sonoff/my_user_config.h index fd3771bc4..c5c9ad799 100644 --- a/sonoff/my_user_config.h +++ b/sonoff/my_user_config.h @@ -487,9 +487,9 @@ // ------------------------------------------------ #define USE_WS2812 // WS2812 Led string using library NeoPixelBus (+5k code, +1k mem, 232 iram) - Disable by // - #define USE_WS2812_BTYPE NEO_BB_DEFAULT // BitBang type (NEO_BB_DEFAULT, NEO_BB_WS2812X, NEO_BB_SK6812) - #define USE_WS2812_CTYPE NEO_GRB // WS2812 Color type (NEO_RGB, NEO_GRB, NEO_BRG, NEO_RBG, NEO_RGBW, NEO_GRBW) // #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_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_ARILUX_RF // Add support for Arilux RF remote controller (+0k8 code, 252 iram (non 2.3.0)) diff --git a/sonoff/sonoff.h b/sonoff/sonoff.h index 6a0b9606f..1ce925355 100644 --- a/sonoff/sonoff.h +++ b/sonoff/sonoff.h @@ -172,9 +172,12 @@ const uint32_t LOOP_SLEEP_DELAY = 50; // Lowest number of milliseconds to #define RGB_REMAP_BRGW 48 #define RGB_REMAP_BGRW 54 -#define NEO_BB_DEFAULT 0 // NeoPixelBus BitBang speed 800kBps with reset time 50 uSec -#define NEO_BB_WS2812X 1 // NeoPixelBus BitBang speed 800kBps with reset time 300 uSec -#define NEO_BB_SK6812 2 // NeoPixelBus BitBang speed 800kBps with reset time 80 uSec +#define NEO_HW_WS2812 0 // NeoPixelBus hardware WS2812 +#define NEO_HW_WS2812X 1 // NeoPixelBus hardware WS2812x like WS2812b +#define NEO_HW_WS2813 1 // NeoPixelBus hardware WS2813 +#define NEO_HW_SK6812 2 // NeoPixelBus hardware SK6812 +#define NEO_HW_LC8812 2 // NeoPixelBus hardware LC8812 +#define NEO_HW_APA106 3 // NeoPixelBus hardware APA106 #define MQTT_PUBSUBCLIENT 1 // Mqtt PubSubClient library #define MQTT_TASMOTAMQTT 2 // Mqtt TasmotaMqtt library based on esp-mqtt-arduino - soon obsolete diff --git a/sonoff/xplg_ws2812.ino b/sonoff/xplg_ws2812.ino index 250866238..8b15d4286 100644 --- a/sonoff/xplg_ws2812.ino +++ b/sonoff/xplg_ws2812.ino @@ -40,18 +40,32 @@ #endif // USE_WS2812_CTYPE #ifdef USE_WS2812_DMA - typedef Neo800KbpsMethod selectedNeoSpeedType; + +// See NeoEspDmaMethod.h for available options +#if (USE_WS2812_HARDWARE == NEO_HW_WS2812X) + typedef NeoEsp8266DmaWs2812xMethod selectedNeoSpeedType; +#elif (USE_WS2812_HARDWARE == NEO_HW_SK6812) + typedef NeoEsp8266DmaSk6812Method selectedNeoSpeedType; +#elif (USE_WS2812_HARDWARE == NEO_HW_APA106) + typedef NeoEsp8266DmaApa106Method selectedNeoSpeedType; +#else // USE_WS2812_HARDWARE + typedef NeoEsp8266Dma800KbpsMethod selectedNeoSpeedType; +#endif // USE_WS2812_HARDWARE + #else // USE_WS2812_DMA + // See NeoEspBitBangMethod.h for available options -#if (USE_WS2812_BTYPE == NEO_BB_WS2812X) +#if (USE_WS2812_HARDWARE == NEO_HW_WS2812X) typedef NeoEsp8266BitBangWs2812xMethod selectedNeoSpeedType; -#elif (USE_WS2812_BTYPE == NEO_BB_SK6812) +#elif (USE_WS2812_HARDWARE == NEO_HW_SK6812) typedef NeoEsp8266BitBangSk6812Method selectedNeoSpeedType; -#else // USE_WS2812_BTYPE +#else // USE_WS2812_HARDWARE typedef NeoEsp8266BitBang800KbpsMethod selectedNeoSpeedType; -#endif // USE_WS2812_BTYPE +#endif // USE_WS2812_HARDWARE + #endif // USE_WS2812_DMA - NeoPixelBus *strip = nullptr; + +NeoPixelBus *strip = nullptr; struct WsColor { uint8_t red, green, blue; @@ -305,11 +319,8 @@ void Ws2812Bars(uint32_t schemenr) void Ws2812Init(void) { -#ifdef USE_WS2812_DMA - strip = new NeoPixelBus(WS2812_MAX_LEDS); // For Esp8266, the Pin is omitted and it uses GPIO3 due to DMA hardware use. -#else // USE_WS2812_DMA + // For DMA, the Pin is ignored as it uses GPIO3 due to DMA hardware use. strip = new NeoPixelBus(WS2812_MAX_LEDS, pin[GPIO_WS2812]); -#endif // USE_WS2812_DMA strip->Begin(); Ws2812Clear(); }