Feeling slow. I'm generating pixel values in R to send to my 16x16 matrix.

Feeling slow. I’m generating pixel values in R to send to my 16x16 matrix. I thought it would be easier to just have my teensy 3.2 take values from python via serial vs. defining huge arrays ahead of time. I see this referenced a lot:

Serial.readBytes( (char*)(&leds[i]), 3);

Far less do I see how one might actually send the data. I don’t understand what the arduino/teensy is expecting. For example:

import serial
ser = serial.Serial('/dev/ttyACM0')

ser.write(???)

To prototype, I’m just substituting 0 (zero) for i in the code (just trying to control the color of the first led via serial). From the pyserial docs, I think I’m supposed to send something like this:[1]

b’the_data’

I’m just not sure what ‘the_data’ should be. I’ve tried things like a list [b’0’, b’0’, b’0’] (didn’t work) and other incantations. The closest I got was b’0 255 0’ where I thought I got the expected color, but eventually it just became white again.

Thanks for any pointers!

[1] http://pyserial.readthedocs.io/en/latest/shortintro.html

Dangit. It’s always right after I give up that I find something helpful! It seems that a list wrapped in bytes() is the ticket. So, on the teensy side, it’s what is already floating around, though I ditched the i to just write the whole string:

Serial.readBytes( (char*)(&leds), NUM_LEDS * 3);

On the python side, I can create my colors like so:

ser.write(bytes([r_0, g_0, b_0, … , r_n, g_n, b_n]))

Hopefully that makes sense. Just one long list of the r, g, b value per pixel. That seems to be working nicely.