Added setOnColor to Pixel

Allows user to set the color to be used for Blinker
This commit is contained in:
Gregg 2022-09-03 16:47:02 -05:00
parent 355a2dfd4d
commit 546c87e3ec
4 changed files with 27 additions and 20 deletions

View File

@ -42,21 +42,6 @@ class Blinkable {
virtual int getPin()=0; 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 // // Blinker //
//////////////////////////////// ////////////////////////////////

View File

@ -59,6 +59,8 @@ Pixel::Pixel(int pin, boolean isRGBW){
txEndMask=RMT.int_ena.val; // save interrupt enable vector txEndMask=RMT.int_ena.val; // save interrupt enable vector
rmt_set_tx_intr_en(rf->getChannel(),true); // enable end-of-transmission interrupt 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);
} }
/////////////////// ///////////////////

View File

@ -132,6 +132,7 @@ class Pixel : public Blinkable {
uint32_t txEndMask; // mask for end-of-transmission interrupt uint32_t txEndMask; // mask for end-of-transmission interrupt
uint32_t txThrMask; // mask for threshold interrupt uint32_t txThrMask; // mask for threshold interrupt
uint32_t lastBit; // 0=RGBW; 8=RGB 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 const int memSize=sizeof(RMTMEM.chan[0].data32)/4; // determine size (in pulses) of one channel
@ -153,8 +154,9 @@ class Pixel : public Blinkable {
return(*rf); return(*rf);
} }
void on() {set(RGB(255,0,0));} void on() {set(onColor);}
void off() {set(RGB(0,0,0));} void off() {set(RGB(0,0,0,0));}
Pixel *setOnColor(Color c){onColor=c;return(this);}
}; };
//////////////////////////////////////////// ////////////////////////////////////////////

View File

@ -44,6 +44,7 @@
#include <Arduino.h> #include <Arduino.h>
#include <driver/ledc.h> #include <driver/ledc.h>
#include "Blinker.h"
#define DEFAULT_PWM_FREQ 5000 #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 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 { class ServoPin : public LedC {
uint16_t minMicros; uint16_t minMicros;