From 6aaf544079b6348a9bb88f95aa92376021a2802f Mon Sep 17 00:00:00 2001 From: cschwinne Date: Mon, 5 Nov 2018 02:24:13 +0100 Subject: [PATCH] Auto-select pixel driving method based on LEDPIN --- wled00/NpbWrapper.h | 24 +++++++++++++++--------- wled00/wled05_init.ino | 7 +------ 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/wled00/NpbWrapper.h b/wled00/NpbWrapper.h index 5912966a..db469816 100644 --- a/wled00/NpbWrapper.h +++ b/wled00/NpbWrapper.h @@ -5,22 +5,28 @@ //#define WORKAROUND_ESP32_BITBANG //see https://github.com/Aircoookie/WLED/issues/2 for flicker free ESP32 support -#define LEDPIN 2 //strip pin. Only effective for ESP32, ESP8266 must use gpio2 +#define LEDPIN 2 //strip pin. Any for ESP32, gpio2 is recommended for ESP8266 //uncomment this if red and green are swapped //#define SWAPRG //automatically uses the right driver method for each platform #ifdef ARDUINO_ARCH_ESP32 -#ifdef WORKAROUND_ESP32_BITBANG -#define PIXELMETHOD NeoEsp32BitBangWs2813Method -#else -#define PIXELMETHOD NeoEsp32RmtWS2813_V3Method -#endif + #ifdef WORKAROUND_ESP32_BITBANG + #define PIXELMETHOD NeoEsp32BitBangWs2813Method + #else + #define PIXELMETHOD NeoEsp32RmtWS2813_V3Method + #endif #else //esp8266 -//you may change to DMA method on pin GPIO3 here -#define PIXELMETHOD NeoEsp8266Uart800KbpsMethod -//#define PIXELMETHOD NeoEsp8266Dma800KbpsMethod + //autoselect the right method depending on strip pin + #if LEDPIN == 2 + #define PIXELMETHOD NeoEsp8266Uart800KbpsMethod + #elif LEDPIN == 3 + #define PIXELMETHOD NeoEsp8266Dma800KbpsMethod + #else + #define PIXELMETHOD NeoEsp8266BitBang800KbpsMethod + #pragma message "Software BitBang will be used because of your selected LED pin. This may cause flicker. Use GPIO 2 or 3 for best results." + #endif #endif //handle swapping Red and Green automatically diff --git a/wled00/wled05_init.ino b/wled00/wled05_init.ino index 6f391979..a41fff78 100644 --- a/wled00/wled05_init.ino +++ b/wled00/wled05_init.ino @@ -258,13 +258,8 @@ void getBuildInfo() #endif oappend("button-pin: gpio"); oappendi(buttonPin); - oappend("\r\n"); - #ifdef ARDUINO_ARCH_ESP32 - oappend("strip-pin: gpio"); + oappend("\r\nstrip-pin: gpio"); oappendi(LEDPIN); - #else - oappend("strip-pin: gpio2"); - #endif oappend("\r\nbuild-type: dev\r\n"); }