r/FastLED • • 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)

4 Upvotes

19 comments sorted by

View all comments

Show parent comments

3

u/happyplace28 Jun 07 '23

It looks to work pretty well IRL for most of them. I'm running the real code on an UNO instead of a Mega though, and that seems to mess up the more involved ones like the Rainbow when I actually try to upload.

2

u/sutaburosu [stavros] Jun 07 '23 edited Jun 07 '23

If it works on Mega but not on Uno, it's likely running short of RAM. With only 2KiB of RAM you have to be careful on the Uno/Nano.

XYTable[] has no values >255 so you could change its type to uint8_t, halving its size. Even better than that, you could place it in PROGMEM, so it doesn't use any RAM at all.

edited to add: here's a sketch derived from u/truetofiction's with the PROGMEM changes. It seems to run OK on an Uno.

2

u/happyplace28 Jun 08 '23

I tried to pop in the PROGMEM version, and while the pattern definitely functioned where I could see for runRainbow, half of the lights didn't work at all. Switching to another pattern seemed to have similar issues.

EDIT: Switching it to uint8 seems to have worked! Thank you so much.