Skip to content

Commit

Permalink
Add WS2812B control, closes #126 (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
probonopd committed Jun 20, 2019
1 parent b65e0b0 commit bad8e51
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ install:
- git clone https://github.com/ayushsharma82/AsyncElegantOTA
- git clone -o 1c02154 https://github.com/alanswx/ESPAsyncWiFiManager
- ( git clone -b 6.x https://github.com/bblanchon/ArduinoJson ; cd ArduinoJson ; git reset --hard 3df4efd )
- git clone -o 9619fef https://github.com/Makuna/NeoPixelBus # https://github.com/Makuna/NeoPixelBus/issues/275
- if [[ "$BD" =~ "esp32:esp32:" ]]; then git clone https://github.com/bbx10/Hash_tng ; fi
- cd -

Expand Down
29 changes: 29 additions & 0 deletions ESP8266WirelessPrintAsync/ESP8266WirelessPrintAsync.ino
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,23 @@

#include "CommandQueue.h"

#include <NeoPixelBus.h>

const uint16_t PixelCount = 20; // this example assumes 4 pixels, making it smaller will cause a failure
const uint8_t PixelPin = 2; // make sure to set this to the correct pin, ignored for ESP8266 (there it is GPIO2 = D4)
#define colorSaturation 255
RgbColor red(colorSaturation, 0, 0);
RgbColor green(0, colorSaturation, 0);
RgbColor blue(0, 0, colorSaturation);
RgbColor white(colorSaturation);
RgbColor black(0);

#if defined(ESP8266)
NeoPixelBus<NeoGrbFeature, NeoEsp8266Uart1Ws2813Method> strip(PixelCount); // ESP8266 always uses GPIO2 = D4
#elif defined(ESP32)
NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> strip(PixelCount, PixelPin);
#endif

// On ESP8266 use the normal Serial() for now, but name it PrinterSerial for compatibility with ESP32
// On ESP32, use Serial1 (rather than the normal Serial0 which prints stuff during boot that confuses the printer)
#ifdef ESP8266
Expand Down Expand Up @@ -934,6 +951,18 @@ void ReceiveResponses() {
serialResponse = "";
restartSerialTimeout();
}
// this resets all the neopixels to an off state
strip.Begin();
strip.Show();
// strip.SetPixelColor(0, red);
// strip.SetPixelColor(1, green);
// strip.SetPixelColor(2, blue);
// strip.SetPixelColor(3, white);
int a;
for(a=0; a<PixelCount; a++){
strip.SetPixelColor(a, white);
}
strip.Show();
}


Expand Down

0 comments on commit bad8e51

Please sign in to comment.