Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Gridded display of LED matrix panels
#1
I've been enjoying using the adafruit matrix hat with the matrix hat driver (https://github.com/adafruit/rpi-rgb-led-matrix/blob/master/ada-matrix.py) to animate bibliopixel patterns on one of these LED panels: https://www.adafruit.com/product/607

Now I'd like to upgrade to four 32x32 LED matrix panels arranged in a square to produce a 64x64 display, but I'm struggling with how to tell it the relative orientation of the 4 panels (e.g. that I have them in a square rather than a straight chain).

Is there a way to use the multi-map builder and matrix orientation (as described here: https://github.com/ManiacalLabs/BiblioPixel/wiki/Display-Setup#multimapbuilder-and-mapgen) with a chain of 4 panels, or will this only work for LED strips?

Or is there some other way to specify the orientation/layout of 4 LED panels in a chain?
thanks
bonnie
#2
Hmmm... interesting question.
So, the multimapbuilder class is for using multiple drivers. But you are only using one driver (note... I've only ever tested that driver with one 32x32 panel... but the underlying library supports it, so my driver should.).

So let's assume you have the displays setup like this:

0 1
2 3

Such that they are chained 0 > 1 > 2 > 3

The problem is that the actual code that controls the matrix chain still sees it as 32 rows, 128 pixels long. This means that the first 128 pixels of data on the BiblioPixel buffer is for row 0 on each panel, the next 128 pixels of data is for row 1 on *each* panel, etch. So we need to remap.

That's one big giant map... 4096 data points! So, I find it easier to represent as code:

Code:
def gen_map():
    matrix = (32, 32)
    top = []
    bot = []
    cur_index = 0
    for y in range(matrix[1]):
        row_top = [x+cur_index for x in range(matrix[0]*2)]
        cur_index = row_top[len(row_top)-1] + 1
        top.append(row_top)
        row_bot = [x+cur_index for x in range(matrix[0]*2)]
        cur_index = row_bot[len(row_bot)-1] + 1
        bot.append(row_bot)

    matrix_map = top + bot
    return matrix_map

Then in LEDMatrix do: LEDMatrix(driver, 64, 64, coordMap = gen_map())

This *should* do what you need. Maybe needs a little tweaking. Let me know. Definitely want to see how this turns out!
#3
Ohhh, now I see how to represent the information about the arrangement of pixels. Nice, thanks so much.

To keep the cabling between panels 1 and 2 as short as possible, I actually intend to arrange the panels as:

0 1
3 2

This means that panels 2 and 3 are upside down with respect to 1 and 2, but I can modify your example to account for the rotation. I'll update with results when I get a chance to try it out (probably tomorrow).
#4
Works like a charm and it looks great. For the record, here's what I did to generate the pixel map for 4 panels in a square as I described above:

Code:
def gen_map():
   matrix = (32, 32)
   top = []
   bot = []
   cur_index = 0
   for y in range(matrix[1]):
       row_top = [x+cur_index for x in range(matrix[0]*2)]
       cur_index = row_top[len(row_top)-1] + 1
       top.append(row_top)
       row_bot = [x+cur_index for x in reversed(range(matrix[0]*2))]
       cur_index = row_bot[0] + 1
       bot.insert(0,row_bot)
   matrix_map = top + bot
   return matrix_map

The camera puts weird lines into the image and I haven't lined up the panels nicely, but the animation looks crisp and perfect in person. 

[Image: KeWB2Wr.jpg]

I'm planning to play a series of animated gifs on it (just on a big loop). There's a noticeable lag when I load an animated gif with ImageAnim, but once it starts playing, it plays smoothly. Maybe I'll try merging them all into one big gif so it can load the whole thing in one go. 

Anyway, thanks again for the help.
bonnie
#5
One more update -- I went with 9 panels and put a bunch of looping gifs on them.

Video (which really doesn't do it justice but gives the general idea): https://vimeo.com/172067781

Code (including the logic to remap the pixels onto 9 panels in a grid): https://github.com/bbarrilleaux/BrainCandy

Very happy with how this turned out.


Forum Jump:


Users browsing this thread: 1 Guest(s)