verified works on C3 when either channel 0 or 1 is used
This commit is contained in:
parent
5f513c4c34
commit
89f0d0dd94
|
|
@ -8,11 +8,13 @@ Pixel::Pixel(int pin){
|
||||||
rf=new RFControl(pin,false,false); // set clock to 1/80 usec, no default driver
|
rf=new RFControl(pin,false,false); // set clock to 1/80 usec, no default driver
|
||||||
setTiming(0.32, 0.88, 0.64, 0.56, 80.0); // set default timing parameters (suitable for most SK68 and WS28 RGB pixels)
|
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,(void *)this,0,NULL); // set custom interrupt handler
|
rmt_isr_register(loadData,NULL,0,NULL); // set custom interrupt handler
|
||||||
rmt_set_tx_thr_intr_en(rf->getChannel(),true,8); // enable threshold interrupt (note end-transmission interrupt automatically enabled by rmt_tx_start)
|
rmt_set_tx_thr_intr_en(rf->getChannel(),true,8); // enable threshold interrupt (note end-transmission interrupt automatically enabled by rmt_tx_start)
|
||||||
|
|
||||||
txEndMask=TxEndMask(rf->getChannel()); // create bit mask for end-of-transmission interrupt specific to this channel
|
txEndMask=TxEndMask(rf->getChannel()); // create bit mask for end-of-transmission interrupt specific to this channel
|
||||||
|
|
||||||
|
Serial.printf("%d %d %08X\n",rf->getChannel(),txEndMask,RMT.int_ena.val);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////
|
///////////////////
|
||||||
|
|
@ -55,11 +57,15 @@ void Pixel::setColors(const uint32_t *data, uint32_t nPixels, boolean multiColor
|
||||||
status.iMem=0;
|
status.iMem=0;
|
||||||
status.iBit=24;
|
status.iBit=24;
|
||||||
status.started=true;
|
status.started=true;
|
||||||
this->multiColor=multiColor;
|
status.px=this;
|
||||||
|
status.multiColor=multiColor;
|
||||||
|
|
||||||
loadData(this); // load first two bytes of data to get started
|
loadData(this); // load first two bytes of data to get started
|
||||||
loadData(this);
|
loadData(this);
|
||||||
|
|
||||||
|
for(int i=0;i<status.px->memSize;i++)
|
||||||
|
Serial.printf("%d %08X\n",i,RMTMEM.chan[rf->getChannel()].data32[i].val);
|
||||||
|
|
||||||
rmt_tx_start(rf->getChannel(),true);
|
rmt_tx_start(rf->getChannel(),true);
|
||||||
|
|
||||||
while(status.started); // wait for transmission to be complete
|
while(status.started); // wait for transmission to be complete
|
||||||
|
|
@ -84,9 +90,7 @@ uint32_t Pixel::getColorHSV(float h, float s, float v){
|
||||||
|
|
||||||
void Pixel::loadData(void *arg){
|
void Pixel::loadData(void *arg){
|
||||||
|
|
||||||
Pixel *pix=(Pixel *)arg;
|
if((RMT.int_st.val & status.px->txEndMask) >0){
|
||||||
|
|
||||||
if(RMT.int_st.val & pix->txEndMask){
|
|
||||||
RMT.int_clr.val=~0;
|
RMT.int_clr.val=~0;
|
||||||
status.started=false;
|
status.started=false;
|
||||||
return;
|
return;
|
||||||
|
|
@ -95,20 +99,20 @@ void Pixel::loadData(void *arg){
|
||||||
RMT.int_clr.val=~0;
|
RMT.int_clr.val=~0;
|
||||||
|
|
||||||
if(status.nPixels==0){
|
if(status.nPixels==0){
|
||||||
RMTMEM.chan[pix->rf->getChannel()].data32[status.iMem].val=0;
|
RMTMEM.chan[status.px->rf->getChannel()].data32[status.iMem].val=0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i=0;i<8;i++)
|
for(int i=0;i<8;i++)
|
||||||
RMTMEM.chan[pix->rf->getChannel()].data32[status.iMem++].val=pix->pattern[(*status.data>>(--status.iBit))&1];
|
RMTMEM.chan[status.px->rf->getChannel()].data32[status.iMem++].val=status.px->pattern[(*status.data>>(--status.iBit))&1];
|
||||||
|
|
||||||
if(status.iBit==0){
|
if(status.iBit==0){
|
||||||
status.iBit=24;
|
status.iBit=24;
|
||||||
status.data+=pix->multiColor;
|
status.data+=status.multiColor;
|
||||||
status.nPixels--;
|
status.nPixels--;
|
||||||
}
|
}
|
||||||
|
|
||||||
status.iMem%=pix->memSize;
|
status.iMem%=status.px->memSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////
|
///////////////////
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,8 @@ class Pixel {
|
||||||
int iBit;
|
int iBit;
|
||||||
int iMem;
|
int iMem;
|
||||||
boolean started;
|
boolean started;
|
||||||
|
Pixel *px;
|
||||||
|
boolean multiColor;
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -23,7 +25,6 @@ class Pixel {
|
||||||
uint32_t pattern[2]; // storage for zero-bit and one-bit pulses
|
uint32_t pattern[2]; // storage for zero-bit and one-bit pulses
|
||||||
uint32_t resetTime; // minimum time (in usec) between pulse trains
|
uint32_t resetTime; // minimum time (in usec) between pulse trains
|
||||||
uint32_t txEndMask; // mask for end-of-transmission interrupt
|
uint32_t txEndMask; // mask for end-of-transmission interrupt
|
||||||
boolean multiColor; // flag to indicate array contains multiple colors (don't just repeat first color for nPixels)
|
|
||||||
|
|
||||||
#if defined(CONFIG_IDF_TARGET_ESP32)
|
#if defined(CONFIG_IDF_TARGET_ESP32)
|
||||||
const int memSize=64;
|
const int memSize=64;
|
||||||
|
|
|
||||||
|
|
@ -95,22 +95,23 @@ void setup() {
|
||||||
|
|
||||||
Serial.println("\n\nHomeSpan Pixel Example\n");
|
Serial.println("\n\nHomeSpan Pixel Example\n");
|
||||||
|
|
||||||
// Pixel px0(10);
|
Pixel px0(10);
|
||||||
Pixel px(1);
|
Pixel px(1);
|
||||||
|
Pixel px1(0);
|
||||||
|
|
||||||
uint32_t colors[20];
|
uint32_t colors[20];
|
||||||
|
|
||||||
colors[0]=px.getColorRGB(0,40,0);
|
colors[0]=px.getColorRGB(40,0,0);
|
||||||
colors[1]=px.getColorRGB(40,0,0);
|
colors[1]=px.getColorRGB(40,0,0);
|
||||||
colors[2]=px.getColorRGB(40,0,0);
|
colors[2]=px.getColorRGB(40,0,0);
|
||||||
colors[3]=px.getColorRGB(40,40,0);
|
colors[3]=px.getColorRGB(40,40,0);
|
||||||
colors[4]=px.getColorRGB(40,40,0);
|
colors[4]=px.getColorRGB(40,40,0);
|
||||||
colors[5]=px.getColorRGB(40,40,0);
|
colors[5]=px.getColorRGB(40,40,0);
|
||||||
colors[6]=px.getColorRGB(0,40,0);
|
colors[6]=px.getColorRGB(0,40,0);
|
||||||
colors[7]=px.getColorRGB(0,40,0);
|
colors[7]=px.getColorRGB(40,0,0);
|
||||||
|
|
||||||
px.setColors(colors,8);
|
px.setColors(colors,8);
|
||||||
// px.setHSV(240,80,40,3);
|
px.setHSV(0,100,40,3);
|
||||||
Serial.println("\n\nDone\n\n");
|
Serial.println("\n\nDone\n\n");
|
||||||
while(1);
|
while(1);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue