Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Matrix and Coordinate Mapping
#1
I am building a matrix using ten 2metre strips of WS2811 led's which i am going to drive with two AllPixel boards.

While I am waiting for the boards and taps to be delivered I am playing with the code using the visualizer and I can't figure out how to create the map to amalgamate the two separate matrixes.

Any clues gratefully received.

Thanks in advance
#2
It kind of depends on how your matrices are arranged. A good place to start is here:
https://github.com/ManiacalLabs/BiblioPixel/wiki/Multiple-Driver-Support

and here:
https://github.com/ManiacalLabs/BiblioPixel/wiki/Display-Setup#multimapbuilder-and-mapgen

I'll assume, for example that each of your all pixels is controlling 5 of the 10 strips and that each 2 meter strip has 120 LEDs (60/meter)... just guessing. But it would be a good reason to need to AllPixels instead of just one.

So, basically two 120 wide by 5 high matrices.
To map the 2 matrices using the AllPixel, you would do this:

Code:
from bibliopixel.led import *
build = MultiMapBuilder()
build.addRow(mapGen(120,5))
build.addRow(mapGen(120,5))

from bibliopixel.drivers.serial_driver import *
driverA = DriverSerial(LEDTYPE.WS2811, 120*5, deviceID = 1)
driverB = DriverSerial(LEDTYPE.WS2811, 120*5, deviceID = 2)

led = LEDMatrix([driverA, driverB], width = 120, height = 10, coordMap = build.map)

So, yes... that doesn't actually answer the question about the visualizer. There's 2 ways of looking at that...

a) don't bother doing the multiple matrices thing. Just create a DriverVisualizer instance that is 120x10 (or whatever your actual dimensions) and develop against that. Because BiblioPixel handles all the (x,y) coordinate mapping, as long as you get the mapping right when you hookup the AllPixels for real, your code will work fine. Just change a few lines of code and you are good.

b) Use two instances of DriverVisualizer which is... a little weird. But here's how to do it.


Code:
from bibliopixel.led import *
build = MultiMapBuilder()
build.addRow(mapGen(120,5))
build.addRow(mapGen(120,5))

from bibliopixel.drivers.visualizer import *
driverA = DriverVisualizer(width = 120, height = 5, port = 1618)  #port is the key
driverB = DriverVisualizer(width = 120, height = 5, port = 1619)  #port is the key

led = LEDMatrix([driverA, driverB], width = 120, height = 10, coordMap = build.map)

As noted above, the "port" parameter is the key here. I should probably make this easier, but it's one of those cases that so far so few people ever use (you are the first aside from me that I know of).

Basically, DriverVisualizer communicates between the python code running your animation and the actual visualizer UI over the network. It's all local networking, but standard TCP stuff all the same. When you use the visualizer it defaults to using port 1618 (just a random one I chose). In order to use multiple visualizers at the same time, you need to use a different port for all the others, which is why driverB, above, uses 1619.

Personally, I would just ignore using 2 visualizers since it adds complications. Then map 2 matrices when using the real hardware.
But that's me... I've used up to 5 visualizers at the same time, so it does work. But then you've got to drag all the windows around. More trouble than it's worth.

Hopefully that helps!
#3
Thumbs Up 
Hi Adam,

Thanks for the comprehensive response.

I can see the logic in only using one visualizer, I guess I was trying to over think the problem.

The sample code for the AllPixel's is exactly what I am looking to achieve.

Best news is that I have just had notification that my AllPixels and Taps have arrived from Hong Kong  Cool

Thanks again.

Danny
#4
Awesome. Glad we could help.
Can't wait to see what you build!
#5
Thanks for sharing!
Great Article.


Forum Jump:


Users browsing this thread: 1 Guest(s)