r/FastLED • u/happyplace28 • Jun 07 '23
Support Patterns on an Irregular Matrix!
Hi All! I am trying to program a backpack to light up with patterns I code. Where I am running into trouble is with getting any patterns to show properly. The lights are staggered, so I made an irregular matrix to note the blank spot in between them, similar to this video.
I have been using this video as a source for some practice patterns before making my own. When I use my irregular matrix however, I get seemingly random noise. Would someone be able to help me figure out how to integrate my matrix with the code to make the patterns work?
I recreated my code in Wokwi here for vis purposes: https://wokwi.com/projects/366899382894067713. It has the exact same issue as my physical backpack. The pattern's mostion should look more like this
Arduino Uno, WS2812 lights (I believe, they're just addressable string lights)
7
u/truetofiction Jun 07 '23 edited Jun 07 '23
You're not going to get the simulator to show anything useful unless you change the display to match your mapping. If you remove your XY function from the output and change the canvas to your matrix size it looks fine.
Try this. Here's the same XY table, but rewritten so that a non-visible LED is 0, and the first index starts at 1:
Rewrite the XY function to check if the value in the table is not 0, and if so return the index. Otherwise return a non-visible LED:
And change the simulator diagram to match the width/height of the matrix:
Then you get a display of what you should be seeing and it looks fine to me. If it doesn't look right in real life then your problems are probably in another castle.
Here's a copy of the Wokwi project with those changes.
2
u/happyplace28 Jun 07 '23
I have been working on this project for a while, here is an earlier post I made about the same issue a few weeks ago: https://www.reddit.com/r/FastLED/comments/12j0rgz/help_creating_irregular_matrices_for_irregular/?utm_source=share&utm_medium=web2x&context=3
2
u/Maleficent-Pea-3785 Jun 08 '23
Pixel mapping is the way.
I have forked u/stefanpetrick's animatrix repo to support 3d pixel mapping. It's successfully running all his patterns on my 3d irregular shaped prototype but I still have a lot more I want to do with this.
Check it out an Hit me with any questions you have. https://github.com/cpreinholtz/animartrix/tree/mapping
1
u/CharlesGoodwin Jun 08 '23
First off - brilliant idea!
I love the way you have integrated the LEDs with the contours of the back pack.
But the skewed rows pose a challenge.
One solution would be to double the row lengths within your mailing matrix. Then for the first row just have the even columns holding displayable LED sequence numbers. The following row would then only have the odd columns as displayable LED sequence numbers. You would then continue down the rows alternating between even and odd columns.
In the XY function where the rows don't conform to the standard length (i.e. towards the bottom) you'd put in conditions and return a non displayable LED sequence number for those positions that don't have an led.
Happy to expand on any point I've put forward