Completed "optimization"
Pixels now lets you reserve memory for pixels so that the call to start the RF transmission can be done for multiple pixels at once. However, gain is not as much as expected. May need to revisit if driving a large matrix of pixels is needed.
This commit is contained in:
parent
ee6c270de3
commit
aefa737675
|
|
@ -30,7 +30,7 @@ void Pixel::setRGB(uint8_t r, uint8_t g, uint8_t b, int nPixels){
|
|||
if(!*rf)
|
||||
return;
|
||||
|
||||
uint32_t *pulses = (uint32_t *) malloc(96);
|
||||
uint32_t *pulses = (uint32_t *) malloc(24*sizeof(uint32_t));
|
||||
|
||||
loadColor(getColorRGB(r,g,b),pulses);
|
||||
rf->start(pulses,24,nPixels); // start pulse train and repeat for nPixels
|
||||
|
|
@ -44,25 +44,25 @@ void Pixel::setRGB(uint8_t r, uint8_t g, uint8_t b, int nPixels){
|
|||
void Pixel::setColors(color_t *color, int nPixels){
|
||||
|
||||
if(!*rf)
|
||||
return;
|
||||
|
||||
uint32_t *pulses = (uint32_t *) malloc(nTrain*24*sizeof(uint32_t));
|
||||
|
||||
if(!pulses){
|
||||
Serial.printf("*** ERROR: Not enough memory to reserve for %d Pixels per batch transmission\n",nTrain);
|
||||
return;
|
||||
|
||||
uint32_t x0,x1,x2;
|
||||
|
||||
x0=micros();
|
||||
|
||||
uint32_t *pulses = (uint32_t *) malloc(nTrain*96);
|
||||
|
||||
for(int i=0;i<nPixels;i++){
|
||||
loadColor(color[i],pulses);
|
||||
rf->start(pulses,24); // start pulse train
|
||||
}
|
||||
|
||||
x1=micros();
|
||||
Serial.printf("%d\n",x1-x0);
|
||||
int i,j;
|
||||
|
||||
for(i=0;i<nPixels;){
|
||||
for(j=0;j<nTrain && i<nPixels;j++,i++)
|
||||
loadColor(color[i],pulses+j*24);
|
||||
rf->start(pulses,j*24);
|
||||
}
|
||||
|
||||
while(1);
|
||||
delayMicroseconds(resetTime);
|
||||
free(pulses);
|
||||
delayMicroseconds(resetTime);
|
||||
}
|
||||
|
||||
///////////////////
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ struct Effect2 {
|
|||
}
|
||||
};
|
||||
|
||||
Pixel px(21);
|
||||
Pixel px(21,8);
|
||||
Effect1 effect1(&px,5);
|
||||
Effect2 effect2(&px,100);
|
||||
|
||||
|
|
@ -87,21 +87,19 @@ void setup() {
|
|||
Serial.printf("PX on Pin=%d check: %s\n",px.getPin(),px?"OKAY":"BAD");
|
||||
|
||||
px.setRGB(0,0,0,8);
|
||||
px.setRGB(255,0,0,1);
|
||||
delay(500);
|
||||
px.setRGB(0,255,0,2);
|
||||
delay(500);
|
||||
px.setRGB(0,255,0,4);
|
||||
delay(500);
|
||||
px.setRGB(0,255,255,6);
|
||||
delay(500);
|
||||
px.setRGB(0,0,255,8);
|
||||
delay(500);
|
||||
for(int i=1;i<5;i++){
|
||||
px.setHSV(0,100,20,i);
|
||||
delay(500);
|
||||
}
|
||||
|
||||
for(int i=5;i<8;i++){
|
||||
px.setHSV(60,100,30,i);
|
||||
delay(500);
|
||||
}
|
||||
|
||||
// while(1);
|
||||
|
||||
|
||||
|
||||
px.setHSV(120,100,100,8);
|
||||
delay(500);
|
||||
|
||||
} // end of setup()
|
||||
|
||||
void loop(){
|
||||
|
|
|
|||
Loading…
Reference in New Issue