Revert "Update logic so Pixel uses only ONE channel and shares across all instances"
This reverts commit 4af3a22764.
This commit is contained in:
parent
4af3a22764
commit
95b41fd929
|
|
@ -5,14 +5,10 @@
|
|||
|
||||
Pixel::Pixel(int pin){
|
||||
|
||||
if(!rf) // RMT Channel not yet assigned
|
||||
rf=new RFControl(pin,false,false); // set clock to 1/80 usec, no default driver
|
||||
|
||||
if(!*rf) // if RMT Channel could NOT be assigned (no more channels)
|
||||
rf=new RFControl(pin,false,false); // set clock to 1/80 usec, no default driver
|
||||
if(!rf)
|
||||
return;
|
||||
|
||||
this->pin=pin;
|
||||
|
||||
setTiming(0.32, 0.88, 0.64, 0.56, 80.0); // set default timing parameters (suitable for most SK68 and WS28 RGB pixels)
|
||||
|
||||
rmt_isr_register(loadData,NULL,0,NULL); // set custom interrupt handler
|
||||
|
|
@ -71,8 +67,6 @@ void Pixel::setColors(const uint32_t *data, uint32_t nPixels, boolean multiColor
|
|||
status.px=this;
|
||||
status.multiColor=multiColor;
|
||||
|
||||
rmt_set_gpio(rf->getChannel(),RMT_MODE_TX,(gpio_num_t)(pin),false);
|
||||
|
||||
loadData(this); // load first two bytes of data to get started
|
||||
loadData(this);
|
||||
|
||||
|
|
@ -128,4 +122,3 @@ void IRAM_ATTR Pixel::loadData(void *arg){
|
|||
///////////////////
|
||||
|
||||
volatile Pixel::pixel_status_t Pixel::status;
|
||||
RFControl *Pixel::rf=NULL;
|
||||
|
|
|
|||
|
|
@ -21,12 +21,11 @@ class Pixel {
|
|||
};
|
||||
|
||||
private:
|
||||
static RFControl *rf; // Pixel utilizes RFControl (shared across all Pixel instances)
|
||||
RFControl *rf; // Pixel utilizes RFControl
|
||||
uint32_t pattern[2]; // storage for zero-bit and one-bit pulses
|
||||
uint32_t resetTime; // minimum time (in usec) between pulse trains
|
||||
uint32_t txEndMask; // mask for end-of-transmission interrupt
|
||||
uint32_t txThrMask; // mask for threshold interrupt
|
||||
int pin=-1; // pin number to which pixel is connected
|
||||
|
||||
const int memSize=sizeof(RMTMEM.chan[0].data32)/4; // determine size (in pulses) of one channel
|
||||
|
||||
|
|
@ -42,7 +41,7 @@ class Pixel {
|
|||
void setHSV(float h, float s, float v, uint32_t nPixels=1); // sets color of nPixels to HSV values where h=[0,360], s=[0,100], v=[0,100]
|
||||
void setColors(const uint32_t *data, uint32_t nPixels, bool multiColor=true); // sets colors of nPixels from array of colors stored in data
|
||||
|
||||
int getPin(){return(pin);} // returns pixel pin (or -1 if initialization failed)
|
||||
int getPin(){return(rf->getPin());} // returns pixel pin if valid, else returns -1
|
||||
|
||||
static uint32_t getColorRGB(uint8_t r, uint8_t g, uint8_t b); // return pixel Color from RGB values
|
||||
static uint32_t getColorHSV(float h, float s, float v); // return pixel Color from HSV values
|
||||
|
|
|
|||
|
|
@ -33,16 +33,19 @@ RFControl::RFControl(uint8_t pin, boolean refClock, boolean installDriver){
|
|||
if(installDriver)
|
||||
rmt_driver_install(config->channel,0,0);
|
||||
|
||||
// If specified, set the base clock to 1 MHz so tick-units are in microseconds (before any CLK_DIV is applied), otherwise default will be 80 MHz APB clock
|
||||
|
||||
this->refClock=refClock;
|
||||
nChannels++;
|
||||
|
||||
if(refClock)
|
||||
#if SOC_RMT_SUPPORT_REF_TICK
|
||||
rmt_set_source_clk(config->channel,RMT_BASECLK_REF); // use 1 MHz REF Tick Clock for ESP32 and ESP32-S2 instead of 80 MHz APB clock
|
||||
#elif SOC_RMT_SUPPORT_XTAL
|
||||
REG_SET_FIELD(RMT_SYS_CONF_REG,RMT_SCLK_DIV_NUM,79); // ESP32-C3 does not have a 1 MHz REF Tick Clock, but allows the 80 MHz APB clock to be scaled by an additional RMT-specific divider
|
||||
#ifdef CONFIG_IDF_TARGET_ESP32C3
|
||||
REG_SET_FIELD(RMT_SYS_CONF_REG,RMT_SCLK_DIV_NUM,79); // ESP32-C3 does not have a 1 MHz REF Tick Clock, but allows the 80 MHz APB clock to be scaled by an additional RMT-specific divider
|
||||
#else
|
||||
rmt_set_source_clk(config->channel,RMT_BASECLK_REF); // use 1 MHz REF Tick Clock for ESP32 and ESP32-S2
|
||||
#endif
|
||||
|
||||
nChannels++;
|
||||
|
||||
}
|
||||
|
||||
///////////////////
|
||||
|
|
@ -58,7 +61,7 @@ void RFControl::start(uint32_t *data, int nData, uint8_t nCycles, uint8_t tickTi
|
|||
if(!config || nData==0)
|
||||
return;
|
||||
|
||||
rmt_set_clk_div(config->channel,tickTime); // set clock divider
|
||||
rmt_set_clk_div(config->channel,tickTime); // set clock divider
|
||||
|
||||
for(int i=0;i<nCycles;i++) // loop over nCycles
|
||||
rmt_write_items(config->channel, (rmt_item32_t *) data, nData, true); // start transmission and wait until completed before returning
|
||||
|
|
|
|||
|
|
@ -81,12 +81,13 @@ struct Effect2 {
|
|||
#define PIN 21
|
||||
#endif
|
||||
|
||||
Pixel px(PIN);
|
||||
Pixel px2(2);
|
||||
Pixel px5(5);
|
||||
Pixel px(PIN);
|
||||
Pixel px3(3);
|
||||
Pixel px4(4);
|
||||
Pixel px5(5);
|
||||
Pixel px6(6);
|
||||
Pixel px7(7);
|
||||
|
||||
Effect1 effect1(&px,5);
|
||||
Effect2 effect2(&px,100);
|
||||
|
|
@ -99,13 +100,6 @@ void setup() {
|
|||
|
||||
Serial.println("\n\nHomeSpan Pixel Example\n");
|
||||
|
||||
Serial.println(px.getPin());
|
||||
Serial.println(px2.getPin());
|
||||
Serial.println(px3.getPin());
|
||||
Serial.println(px4.getPin());
|
||||
Serial.println(px5.getPin());
|
||||
Serial.println(px6.getPin());
|
||||
|
||||
} // end of setup()
|
||||
|
||||
void loop(){
|
||||
|
|
|
|||
Loading…
Reference in New Issue