Teensy with octows2811 library question

Jaromir_m

New member
Hey All,

I am currently experimenting with a Teensy 3.2 and a Octows2811.

I saw in the videodisplay example that you directly write into the drawingMemmory to set the leds.

so when i do:
drawingMemory[0] = (255<< 16) | (0 << 8) | (0 << 0);
All the first green leds of each output turn on.

so i expected that
drawingMemory[1] = (255<< 16) | (0 << 8) | (0 << 0);
would turn on the red ones but nothing happens.

so my question is how does this drawingMemmory work? Is there a reference somewhere i can read?
I know about leds.setColor() I am just curious on how this works :),

Thanks!
 
Try this: drawingMemory[0] = (0<< 16) | (255 << 8) | (0 << 0);
I'm not sure though that you should be using drawingMemory[] to set pixels on/off - I could not find any info on the usage.

Paul
 
Hey Paul, Thanks for the quick response!

Maybe i got a bit lost in the sauce.. but what i want to achieve is the following:

i have made this led mapper in max/jitter that i made. the patch sends an array of 1440(amount of leds that i have) * 3(rgb) values to my teensy. I want my teensy to display these values on my leds at around 30fps. On my windows machine this works fine but on my mac mini the leds get all glitched up. Maybe this is because the buffersize on my windows machine can be bigger but I am not sure.

So i was looking in how to fix my problem and the videodisplay example that is included with the OctoWS2811 library works great on my mac and windows machine so i was trying to understand how these programs work so I can adjust my own code.

So here is the code i use now:
#include <OctoWS2811.h>

const int ledsPerStrip = 240;
const int numStrips = 6;
const int numLeds = ledsPerStrip*numStrips;
const int numChannels = numLeds * 3;

DMAMEM int displayMemory[ledsPerStrip*6];
int drawingMemory[ledsPerStrip*6];
int incomingMemory[ledsPerStrip*6];
const int config = WS2811_800kHz; // color config is on the PC side

OctoWS2811 leds(ledsPerStrip, displayMemory, drawingMemory, config);
char serial_array[numChannels];
int serial_array_length = 0;

void setup() {
pinMode(13,OUTPUT);
digitalWrite(13,HIGH);
Serial.setTimeout(10);
Serial.begin(115200);
leds.begin();
leds.show();
}

void loop() {

// first, check if there's anything available to read
if (n > 0) {

Serial.readBytes((char *)serial_array, numChannels);

for (int i = 0; i < numLeds ; i++) {
leds.setPixel(i, serial_array[i*3], serial_array[i*3+1], serial_array[i*3+2]);
}
leds.show();
}

}
 
OK, I think I understand what you are trying to accomplish: instead of uploading data into the serial_array[] and then using setPixel() to set the intended pixels, you are trying to directly write into the drawingMemory[] array.
That might work but you have to figure out which array element belongs to which actual LED.

I guess this line int incomingMemory[ledsPerStrip*6]; was an effort to make a temporary buffer?

On the drawingMemory[] array, since every element is a 32-bit int, I assume that a single array element maps to a single RGB LED.

On my windows machine this works fine but on my mac mini the leds get all glitched up. Maybe this is because the buffersize on my windows machine can be bigger but I am not sure.
Don't know - your guess is as good as mine.

Paul
 
Hey Paul,

Thanks for the response. So i fixed my problem!
It turned out the serial object in max/msp was the problem.. So I now have a workaround where i sent my data via Syphon to Processing and then use the serial object in processing. The teensy code worked just fine..

So what i was trying to do earlier made no sense.. My thought was by speeding up my teensy code by writing directly into the drawingMemmory my serialBuffer would get less clogged.

Once I cleaned up all the code I will share everything on Github and will post a link to it here :). Thanks!
 
so my question is how does this drawingMemmory work?

It's complicated on Teensy 3.2. The data is stored in a transposed format where each byte in memory is the 8 bits which will transmit simultaneously. So to write a single 24 bit RGB pixel, you must alter 1 of the 8 bits within 24 consecutive bytes in memory.

For Teensy 4.0 & 4.1 the data format was changed to simple RGB data like you'd expect on a regular computer.


Is there a reference somewhere i can read?

The source code for setPixel() is really the only reference.
 
Back
Top