moved loadData into interrupt
This commit is contained in:
parent
40c05bd53f
commit
79c028c057
|
|
@ -8,11 +8,11 @@ Pixel::Pixel(int pin, uint32_t nPixels){
|
||||||
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(isrHandler,(void *)this,0,NULL); // end-transmission interrupt automatically enabled by rmt_tx_start
|
rmt_isr_register(loadData,(void *)this,0,NULL); // set custom interrupt handler
|
||||||
rmt_set_tx_thr_intr_en(rf->getChannel(),true,8); // need to also enable threshold interrupt
|
rmt_set_tx_thr_intr_en(rf->getChannel(),true,8); // enable threshold interrupt (note end-transmission interrupt automatically enabled by rmt_tx_start)
|
||||||
|
|
||||||
channelNum=rf->getChannel();
|
channelNum=rf->getChannel(); // save integer form of channel number
|
||||||
txEndMask=TxEndMask(channelNum);
|
txEndMask=TxEndMask(channelNum); // create bit mask for end-of-transmission interrupt specific to this channel
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -54,8 +54,11 @@ void Pixel::setColors(const uint32_t *data, uint32_t nPixels){
|
||||||
status.iBit=24;
|
status.iBit=24;
|
||||||
status.started=true;
|
status.started=true;
|
||||||
|
|
||||||
loadData(); // load first 2 bytes
|
// loadData(); // load first 2 bytes
|
||||||
loadData();
|
// loadData();
|
||||||
|
|
||||||
|
loadData(this);
|
||||||
|
loadData(this);
|
||||||
|
|
||||||
rmt_tx_start(rf->getChannel(),true);
|
rmt_tx_start(rf->getChannel(),true);
|
||||||
|
|
||||||
|
|
@ -120,27 +123,7 @@ uint32_t Pixel::getColorHSV(float h, float s, float v){
|
||||||
|
|
||||||
///////////////////
|
///////////////////
|
||||||
|
|
||||||
void Pixel::loadData(){
|
void Pixel::loadData(void *arg){
|
||||||
|
|
||||||
if(status.nPixels==0){
|
|
||||||
RMTMEM.chan[channelNum].data32[status.iMem].val=0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int i=0;i<8;i++)
|
|
||||||
RMTMEM.chan[channelNum].data32[status.iMem++].val=pattern[(*status.data>>(--status.iBit))&1];
|
|
||||||
|
|
||||||
if(status.iBit==0){
|
|
||||||
status.iBit=24;
|
|
||||||
status.data++;
|
|
||||||
status.nPixels--;
|
|
||||||
}
|
|
||||||
status.iMem%=memSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////
|
|
||||||
|
|
||||||
void Pixel::isrHandler(void *arg){
|
|
||||||
|
|
||||||
Pixel *pix=(Pixel *)arg;
|
Pixel *pix=(Pixel *)arg;
|
||||||
|
|
||||||
|
|
@ -151,7 +134,22 @@ void Pixel::isrHandler(void *arg){
|
||||||
}
|
}
|
||||||
|
|
||||||
RMT.int_clr.val=~0;
|
RMT.int_clr.val=~0;
|
||||||
pix->loadData();
|
|
||||||
|
if(status.nPixels==0){
|
||||||
|
RMTMEM.chan[pix->channelNum].data32[status.iMem].val=0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int i=0;i<8;i++)
|
||||||
|
RMTMEM.chan[pix->channelNum].data32[status.iMem++].val=pix->pattern[(*status.data>>(--status.iBit))&1];
|
||||||
|
|
||||||
|
if(status.iBit==0){
|
||||||
|
status.iBit=24;
|
||||||
|
status.data++;
|
||||||
|
status.nPixels--;
|
||||||
|
}
|
||||||
|
|
||||||
|
status.iMem%=pix->memSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////
|
///////////////////
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ class Pixel {
|
||||||
|
|
||||||
volatile static pixel_status_t status;
|
volatile static pixel_status_t status;
|
||||||
|
|
||||||
static void isrHandler(void *arg); // interrupt handler
|
static void loadData(void *arg); // interrupt handler
|
||||||
void loadColor(uint32_t c, uint32_t *p); // creates pulse pattern for pixel color (encoded as RGB in low 24-bits of *p)
|
void loadColor(uint32_t c, uint32_t *p); // creates pulse pattern for pixel color (encoded as RGB in low 24-bits of *p)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -58,8 +58,6 @@ class Pixel {
|
||||||
static uint32_t getColorRGB(uint8_t r, uint8_t g, uint8_t b); // return pixel Color from RGB values
|
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
|
static uint32_t getColorHSV(float h, float s, float v); // return pixel Color from HSV values
|
||||||
|
|
||||||
void loadData();
|
|
||||||
|
|
||||||
operator bool(){ // override boolean operator to return true/false if creation succeeded/failed
|
operator bool(){ // override boolean operator to return true/false if creation succeeded/failed
|
||||||
return(*rf);
|
return(*rf);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -99,13 +99,13 @@ void setup() {
|
||||||
|
|
||||||
uint32_t colors[20];
|
uint32_t colors[20];
|
||||||
|
|
||||||
colors[0]=px.getColorRGB(40,40,0);
|
colors[0]=px.getColorRGB(40,0,0);
|
||||||
colors[1]=px.getColorRGB(40,40,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(0,0,40);
|
colors[3]=px.getColorRGB(40,40,0);
|
||||||
colors[4]=px.getColorRGB(40,0,0);
|
colors[4]=px.getColorRGB(40,40,0);
|
||||||
colors[5]=px.getColorRGB(40,0,0);
|
colors[5]=px.getColorRGB(40,40,0);
|
||||||
colors[6]=px.getColorRGB(40,0,0);
|
colors[6]=px.getColorRGB(0,40,0);
|
||||||
colors[7]=px.getColorRGB(0,40,0);
|
colors[7]=px.getColorRGB(0,40,0);
|
||||||
|
|
||||||
px.setColors(colors,8);
|
px.setColors(colors,8);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue