mirror of
https://github.com/wled/WLED.git
synced 2025-07-25 19:56:32 +00:00
Merge pull request #160 from T-Arens/master
Added support for APA102 LEDs.
This commit is contained in:
commit
315987b2f6
@ -3,8 +3,17 @@
|
|||||||
#define NpbWrapper_h
|
#define NpbWrapper_h
|
||||||
|
|
||||||
//PIN CONFIGURATION
|
//PIN CONFIGURATION
|
||||||
#define LEDPIN 2 //strip pin. Any for ESP32, gpio2 or 3 is recommended for ESP8266 (gpio2/3 are labeled D4/RX on NodeMCU and Wemos)
|
|
||||||
#define BTNPIN 0 //button pin. Needs to have pullup (gpio0 recommended)
|
#define BTNPIN 0 //button pin. Needs to have pullup (gpio0 recommended)
|
||||||
|
//#define USE_APA102 // Uncomment for using APA102 LEDs.
|
||||||
|
#ifdef USE_APA102
|
||||||
|
#define CLKPIN 0
|
||||||
|
#define DATAPIN 2
|
||||||
|
#if BTNPIN == CLKPIN || BTNPIN == DATAPIN
|
||||||
|
#undef BTNPIN // Deactivate button pin if it conflicts with one of the APA102 pins.
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define LEDPIN 2 //strip pin. Any for ESP32, gpio2 or 3 is recommended for ESP8266 (gpio2/3 are labeled D4/RX on NodeMCU and Wemos)
|
||||||
#define IR_PIN 4 //infrared pin (-1 to disable)
|
#define IR_PIN 4 //infrared pin (-1 to disable)
|
||||||
#define RLYPIN 12 //pin for relay, will be set HIGH if LEDs are on (-1 to disable). Also usable for standby leds, triggers,...
|
#define RLYPIN 12 //pin for relay, will be set HIGH if LEDs are on (-1 to disable). Also usable for standby leds, triggers,...
|
||||||
#define AUXPIN -1 //debug auxiliary output pin (-1 to disable)
|
#define AUXPIN -1 //debug auxiliary output pin (-1 to disable)
|
||||||
@ -17,7 +26,9 @@
|
|||||||
#define PIXELMETHOD NeoWs2813Method
|
#define PIXELMETHOD NeoWs2813Method
|
||||||
#else //esp8266
|
#else //esp8266
|
||||||
//autoselect the right method depending on strip pin
|
//autoselect the right method depending on strip pin
|
||||||
#if LEDPIN == 2
|
#ifdef USE_APA102
|
||||||
|
#define PIXELMETHOD DotStarMethod
|
||||||
|
#elif LEDPIN == 2
|
||||||
#define PIXELMETHOD NeoEsp8266Uart1Ws2813Method //if you get an error here, try to change to NeoEsp8266UartWs2813Method or update Neopixelbus
|
#define PIXELMETHOD NeoEsp8266Uart1Ws2813Method //if you get an error here, try to change to NeoEsp8266UartWs2813Method or update Neopixelbus
|
||||||
#elif LEDPIN == 3
|
#elif LEDPIN == 3
|
||||||
#define PIXELMETHOD NeoEsp8266Dma800KbpsMethod
|
#define PIXELMETHOD NeoEsp8266Dma800KbpsMethod
|
||||||
@ -29,8 +40,13 @@
|
|||||||
|
|
||||||
|
|
||||||
//you can now change the color order in the web settings
|
//you can now change the color order in the web settings
|
||||||
|
#ifdef USE_APA102
|
||||||
|
#define PIXELFEATURE3 DotStarBgrFeature
|
||||||
|
#define PIXELFEATURE4 DotStarLbgrFeature
|
||||||
|
#else
|
||||||
#define PIXELFEATURE3 NeoGrbFeature
|
#define PIXELFEATURE3 NeoGrbFeature
|
||||||
#define PIXELFEATURE4 NeoGrbwFeature
|
#define PIXELFEATURE4 NeoGrbwFeature
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#include <NeoPixelBrightnessBus.h>
|
#include <NeoPixelBrightnessBus.h>
|
||||||
@ -68,12 +84,20 @@ public:
|
|||||||
switch (_type)
|
switch (_type)
|
||||||
{
|
{
|
||||||
case NeoPixelType_Grb:
|
case NeoPixelType_Grb:
|
||||||
|
#ifdef USE_APA102
|
||||||
|
_pGrb = new NeoPixelBrightnessBus<PIXELFEATURE3,PIXELMETHOD>(countPixels, CLKPIN, DATAPIN);
|
||||||
|
#else
|
||||||
_pGrb = new NeoPixelBrightnessBus<PIXELFEATURE3,PIXELMETHOD>(countPixels, LEDPIN);
|
_pGrb = new NeoPixelBrightnessBus<PIXELFEATURE3,PIXELMETHOD>(countPixels, LEDPIN);
|
||||||
|
#endif
|
||||||
_pGrb->Begin();
|
_pGrb->Begin();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NeoPixelType_Grbw:
|
case NeoPixelType_Grbw:
|
||||||
|
#ifdef USE_APA102
|
||||||
|
_pGrbw = new NeoPixelBrightnessBus<PIXELFEATURE4,PIXELMETHOD>(countPixels, CLKPIN, DATAPIN);
|
||||||
|
#else
|
||||||
_pGrbw = new NeoPixelBrightnessBus<PIXELFEATURE4,PIXELMETHOD>(countPixels, LEDPIN);
|
_pGrbw = new NeoPixelBrightnessBus<PIXELFEATURE4,PIXELMETHOD>(countPixels, LEDPIN);
|
||||||
|
#endif
|
||||||
_pGrbw->Begin();
|
_pGrbw->Begin();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -154,7 +154,9 @@ void beginStrip()
|
|||||||
strip.setColor(0);
|
strip.setColor(0);
|
||||||
strip.setBrightness(255);
|
strip.setBrightness(255);
|
||||||
|
|
||||||
|
#ifdef BTNPIN
|
||||||
pinMode(BTNPIN, INPUT_PULLUP);
|
pinMode(BTNPIN, INPUT_PULLUP);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (bootPreset>0) applyPreset(bootPreset, turnOnAtBoot, true, true);
|
if (bootPreset>0) applyPreset(bootPreset, turnOnAtBoot, true, true);
|
||||||
colorUpdated(0);
|
colorUpdated(0);
|
||||||
@ -170,7 +172,11 @@ void beginStrip()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
//disable button if it is "pressed" unintentionally
|
//disable button if it is "pressed" unintentionally
|
||||||
|
#ifdef BTNPIN
|
||||||
if(digitalRead(BTNPIN) == LOW) buttonEnabled = false;
|
if(digitalRead(BTNPIN) == LOW) buttonEnabled = false;
|
||||||
|
#else
|
||||||
|
buttonEnabled = false;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ void shortPressAction()
|
|||||||
|
|
||||||
void handleButton()
|
void handleButton()
|
||||||
{
|
{
|
||||||
|
#ifdef BTNPIN
|
||||||
if (!buttonEnabled) return;
|
if (!buttonEnabled) return;
|
||||||
|
|
||||||
if (digitalRead(BTNPIN) == LOW && !buttonPressedBefore) //pressed
|
if (digitalRead(BTNPIN) == LOW && !buttonPressedBefore) //pressed
|
||||||
@ -51,6 +52,7 @@ void handleButton()
|
|||||||
buttonWaitTime = 0;
|
buttonWaitTime = 0;
|
||||||
shortPressAction();
|
shortPressAction();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleIO()
|
void handleIO()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user