r/FastLED • u/Ok-Giraffe4721 • Aug 07 '25
Support Question about Led Matrix Layout / XYMap Lookup Table
hi,
I try to display WaveFx 2d effects on a 40 x 50 neopixel matrix (wired vertically, with serpentines). I use 5 parallel lanes on a Teensy4.1.
I used the XY-Map generator for creating the lookup table for the XYMap: https://macetech.github.io/FastLED-XY-Map-Generator/
In the code, I create the maps using
XYMap xyMap = XYMap::constructWithLookUpTable(WIDTH, HEIGHT, XYTable, 0);XYMap xyRect(WIDTH, HEIGHT, 0); // for the WaveFX effect
(XYTable being the const int array created by the XY-Map generator).
The led positions (rows and columns) are correct when the leds are set individually using
leds[xyMap(xPos, yPos)] = CRGB(red, green, blue);
However, when triggering a wave, the mapping does not work and the effect is not displayed correctly. When using a smaller matrix with horizontal wiring (without the lookup table) everthing works okay.
I tried using the lookup table also for xyRect and other tweaks, but without success.
Any ideas what goes wrong here / if I was missing something?
thanks,
Chris
2
u/ZachVorhies Zach Vorhies Aug 11 '25 edited Aug 11 '25
You want the wavefx to dump into a multi plexed mapped controller in serpentine format... in one draw step.
My recommendation is to draw the wave fx it into a pure rectangular led grid as a side buffer first, then copy it into your controller buffers unique dimensions (blitting). memcopy on teensy is so fast you can consider it free.
Make it work right for one strip, then 2, then all 5.
Teensy 41 has a massive amount of memory. So in this case a side buffer won't cost you anything, and will just make your life easier. Just draw it to a rectangle buffer, then call memcopy to get into your unique segments.
Then call FastLED.show() like normal.
Want to do direct RGB write?
Wave fx grants you access via a visitor pattern that will iterate on each pixel and pass coordinates back to the caller. So if you want to skip the side buffer, then you can do this via a draw visitor.
GOOD LUCK! IT'S GOING TO LOOK AMAZING!
2
u/4wheeljive Jeff Holman Aug 11 '25
Hi, Chris -
I wrestled on and off for a couple of weeks with several issues that may be related.
[Much of this was chronicled in an earlier thread: https://www.reddit.com/r/FastLED/comments/1kwwvcd/using_screenmap_with_nonstandard_led_layouts/. About this thread, though:
Here are some key tl/dr takeaways, which reference various parts of this Gist I put together with some relevant code snippets: https://gist.github.com/4wheeljive/cbad9a6e88d9c584a8e75fd978d6c4e0
CUSTOM XYMAP
- constuctWithUserFunction vs constructWithLookUpTable
- loc2indProgByColBottomUp[y][x]
I never could get a custom LUT to work for my LED mapping, but after much trial and error I was able to use the constuctWithUserFunction approach.
The actual mapping that has worked for me for some of the fl::fx class functions is "progressive, by column, bottom up"
DIFFERENT SIZED BOARDS
Like you, I wanted to be be able to switch easily between different sized boards. This involved both (1) using different XYMAPs and (2) switching between a single data pin and multiple data pins. I addressed both of these with an "#ifdef BIG_BOARD toggle" that drives (1) which of my matrixMap_.h files supplies the loc2indProgByColBottomUp[y][x] array and (2) whether one or multiple FastLED controllers are initialized in setup().
If you share more of your code, I (and I'm sure others) would be happy to help you troubleshoot further.
[POSTED at 14:30PDT on 250811]
2
u/ZachVorhies Zach Vorhies Aug 12 '25
Resolved: https://www.reddit.com/r/FastLED/comments/1mkcnon/comment/n89h7bu/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button