diff --git a/src/extras/Blinker.h b/src/extras/Blinker.h index 16994ee..13aec3f 100644 --- a/src/extras/Blinker.h +++ b/src/extras/Blinker.h @@ -42,21 +42,6 @@ class Blinkable { virtual int getPin()=0; }; -//////////////////////////////// -// Generic_LED // -//////////////////////////////// - -class LED : public Blinkable { - int pin; - - public: - - LED(int pin) : pin{pin} {pinMode(pin,OUTPUT);digitalWrite(pin,0);} - void on() {digitalWrite(pin,HIGH);} - void off() {digitalWrite(pin,LOW);} - int getPin() {return(pin);} -}; - //////////////////////////////// // Blinker // //////////////////////////////// diff --git a/src/extras/Pixel.cpp b/src/extras/Pixel.cpp index 479d115..1e87187 100644 --- a/src/extras/Pixel.cpp +++ b/src/extras/Pixel.cpp @@ -58,7 +58,9 @@ Pixel::Pixel(int pin, boolean isRGBW){ rmt_set_tx_intr_en(rf->getChannel(),false); // disable end-of-transmission interrupt txEndMask=RMT.int_ena.val; // save interrupt enable vector rmt_set_tx_intr_en(rf->getChannel(),true); // enable end-of-transmission interrupt - txEndMask^=RMT.int_ena.val; // find bit that flipped and save as end-of-transmission mask for this channel + txEndMask^=RMT.int_ena.val; // find bit that flipped and save as end-of-transmission mask for this channel + + onColor.HSV(0,100,100,0); } /////////////////// diff --git a/src/extras/Pixel.h b/src/extras/Pixel.h index facd92d..e781129 100644 --- a/src/extras/Pixel.h +++ b/src/extras/Pixel.h @@ -132,13 +132,14 @@ class Pixel : public Blinkable { uint32_t txEndMask; // mask for end-of-transmission interrupt uint32_t txThrMask; // mask for threshold interrupt uint32_t lastBit; // 0=RGBW; 8=RGB + Color onColor; // color used for on() command const int memSize=sizeof(RMTMEM.chan[0].data32)/4; // determine size (in pulses) of one channel static void loadData(void *arg); // interrupt handler volatile static pixel_status_t status; // storage for volatile information modified in interupt handler - public: + public: Pixel(int pin, boolean isRGBW=false); // creates addressable single-wire RGB (false) or RGBW (true) LED connected to pin (such as the SK68 or WS28) void set(Color *c, int nPixels, boolean multiColor=true); // sets colors of nPixels based on array of Colors c; setting multiColor to false repeats Color in c[0] for all nPixels void set(Color c, int nPixels=1){set(&c,nPixels,false);} // sets color of nPixels to be equal to specific Color c @@ -153,8 +154,9 @@ class Pixel : public Blinkable { return(*rf); } - void on() {set(RGB(255,0,0));} - void off() {set(RGB(0,0,0));} + void on() {set(onColor);} + void off() {set(RGB(0,0,0,0));} + Pixel *setOnColor(Color c){onColor=c;return(this);} }; //////////////////////////////////////////// diff --git a/src/extras/PwmPin.h b/src/extras/PwmPin.h index c3d3f4c..3edecc3 100644 --- a/src/extras/PwmPin.h +++ b/src/extras/PwmPin.h @@ -44,6 +44,7 @@ #include #include +#include "Blinker.h" #define DEFAULT_PWM_FREQ 5000 @@ -80,7 +81,24 @@ class LedPin : public LedC { static void HSVtoRGB(float h, float s, float v, float *r, float *g, float *b ); // converts Hue/Saturation/Brightness to R/G/B }; -///////////////////////////////////// +//////////////////////////////// +// LED // +//////////////////////////////// + +class LED : public Blinkable { + int pin; + + public: + + LED(int pin) : pin{pin} {pinMode(pin,OUTPUT);digitalWrite(pin,0);} + void on() {digitalWrite(pin,HIGH);} + void off() {digitalWrite(pin,LOW);} + int getPin() {return(pin);} +}; + +//////////////////////////////// +// ServoPin // +//////////////////////////////// class ServoPin : public LedC { uint16_t minMicros;