|
18 | 18 |
|
19 | 19 | #include "CommandQueue.h" |
20 | 20 |
|
| 21 | +#include <NeoPixelBus.h> |
| 22 | + |
| 23 | +const uint16_t PixelCount = 20; // this example assumes 4 pixels, making it smaller will cause a failure |
| 24 | +const uint8_t PixelPin = 2; // make sure to set this to the correct pin, ignored for ESP8266 (there it is GPIO2 = D4) |
| 25 | +#define colorSaturation 255 |
| 26 | +RgbColor red(colorSaturation, 0, 0); |
| 27 | +RgbColor green(0, colorSaturation, 0); |
| 28 | +RgbColor blue(0, 0, colorSaturation); |
| 29 | +RgbColor white(colorSaturation); |
| 30 | +RgbColor black(0); |
| 31 | + |
| 32 | +#if defined(ESP8266) |
| 33 | + NeoPixelBus<NeoGrbFeature, NeoEsp8266Uart1Ws2813Method> strip(PixelCount); // ESP8266 always uses GPIO2 = D4 |
| 34 | +#elif defined(ESP32) |
| 35 | + NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> strip(PixelCount, PixelPin); |
| 36 | +#endif |
| 37 | + |
21 | 38 | // On ESP8266 use the normal Serial() for now, but name it PrinterSerial for compatibility with ESP32 |
22 | 39 | // On ESP32, use Serial1 (rather than the normal Serial0 which prints stuff during boot that confuses the printer) |
23 | 40 | #ifdef ESP8266 |
@@ -934,6 +951,18 @@ void ReceiveResponses() { |
934 | 951 | serialResponse = ""; |
935 | 952 | restartSerialTimeout(); |
936 | 953 | } |
| 954 | + // this resets all the neopixels to an off state |
| 955 | + strip.Begin(); |
| 956 | + strip.Show(); |
| 957 | + // strip.SetPixelColor(0, red); |
| 958 | + // strip.SetPixelColor(1, green); |
| 959 | + // strip.SetPixelColor(2, blue); |
| 960 | + // strip.SetPixelColor(3, white); |
| 961 | + int a; |
| 962 | + for(a=0; a<PixelCount; a++){ |
| 963 | + strip.SetPixelColor(a, white); |
| 964 | + } |
| 965 | + strip.Show(); |
937 | 966 | } |
938 | 967 |
|
939 | 968 |
|
|
0 commit comments