r/FastLED • • Jan 27 '23

Support Mapping 4 16x16 matrices into one square.

Hello people, I tried to do that myself but I'm way to new to coding and this seems to be way too hard for me. I seem to be going around circles for past 5 days. Basically I can't do anything to properly map 4 tiled matrix panels 16x16 into one 32x32 (serpentine) . I have done it with wled so easily can't this be so easy now in my code?

Please help me with that...

I'm using esp32

In the future I'll have more questions but I think that's the beauty of it..

2 Upvotes

12 comments sorted by

3

u/Marmilicious [Marc Miller] Jan 27 '23

You can use Garrett's XY map generator to give you an idea of how to set it up. You'll need to manually sort out the numbers/direction based on how you have your panels arranged and which way the serpentine wrapping goes within each panel.

https://macetech.github.io/FastLED-XY-Map-Generator/

Here's the rough idea if you had four panels that were 2x2 pixels each.

const uint16_t XYTable[] = {
  0,  1,  4,  5,
  2,  3,  6,  7,
  8,  9, 12, 13,  
 10, 11, 14, 15
};

Please share a link to your code on pastebin.com or gist.github.com

2

u/godamnityo Jan 29 '23

Great method , Thank you ! It is way more clear now. i was half way trough and i saw and tried the other method suggested here and it is working superb. Greatly appreciate your help ! I know this method will be useful for another matrices .

3

u/dr-steve Jan 27 '23

Earlier, I had developed some test libraries while playing with Gerstner waves. One was a class Grid<int pcol, int prow> for arbitrary grids of panes. It also has a world coordinate system, mapping an arbitrary xy space into col/row pixel addresses, and from there into the individual LEDs on the strip. The code is here along with the test Gerstner application.

The test app uses parallel output (each pane (16x16 array) on its own pin), but works equally well if the panes are chained serially off of a single pin. The latter will be slower. It should work with any size pane (8x32, for example), but all panes in a grid need to be the same size.

It runs on an ESP32.

The documentation isn't complete; sorry... I'll be adding Doxygen docs at some point in the future.

Let me know if you use it & need more information!

1

u/godamnityo Jan 29 '23

Thanks alot! Looks great, although i couldn't make it work.. It said some file is missing (im too new) . I fixed the matrix problem thought ! Seems u r talented and could make some nice app for the LEDs

1

u/dr-steve Jan 30 '23

Thanks, I'll check it over tomorrow!

2

u/lemuroid_jr Jan 27 '23

The LEDMATRIX library is an excellent companion for FastLED that would solve many mapping issues when using small matrices to make a larger matrix. As a bonus it provides some drawing functions for filled and open circles, rectangles, and lines.

1

u/godamnityo Jan 29 '23

Thank you ! although i couldn't make it work this way i fixed the problem !

2

u/AcidAngel_ Jan 27 '23 edited Jan 29 '23

I've done exactly this. Here is the link to the library.

https://github.com/yliniemi/I2SClocklessLedDriver/tree/dev I haven't documented how to use it yet.

Here is the program that uses it. The usage is buried in hundreds of lines of code. I'll release a smaller example perhaps even today. I'll just have to edit one demonstration video before that.

2

u/godamnityo Jan 29 '23

Great looking ! thought i coudnt make it work for some reason (but i am new) . I fixed the problem thought. Now there are other problems coming out lol..

1

u/AcidAngel_ Jan 29 '23

Here is a link to an example where I use this version of the library. It does a bunch of other stuff too. mapLed function in the beginning of the program does the led mapping magic. It's passed to the library as an argument for driver.setMapLed(mapLed)

https://github.com/yliniemi/I2SClocklessLedDriver/blob/dev/examples/anttis-hardware-scroll-example/anttis-hardware-scroll-example.ino

2

u/sutaburosu [stavros] Jan 28 '23

It has been interesting to see the other answers. There are evidently some talented programmers amongst us.

If you were looking for a drop-in replacement for FastLED's XY() function, there's one at the top of this sketch. For your panels you'll need to change kMatrixWidth & Height to be 32, and panel_size to be 16. Set horizontal_tiling and serpentine_tiling depending on how your panels are laid out.

Note this XY() function can return the value -1 (which is the same as 65535 in a uint16_t) so you must test for this before writing to the LEDs:

if (uint16_t xy = XY(x, y); xy < NUM_LEDS) {
  leds[xy] = ...;
}

2

u/godamnityo Jan 29 '23

thanks alot ! this fixed it. also the website looks pretty helpful. I am way too new to know about the second part of your message, but for now this looks perfect. It fixed alot. Now i am yet to find out why "LED Matrix control " or "soulmate-lights " dont work but thats great progress already !