Has anyone seen techniques for handling a 2D matrix of LEDs that are NOT

Has anyone seen techniques for handling a 2D matrix of LEDs that are NOT arranged on a rectangle? I’m torn between creating a memory space that is a rectangle and just mapping the LEDs to the space or creating a function that will convert one coordinate system to the other.

And of course, reusing someone else’s code is even better. :slight_smile:

I wrote just such a function (remapping technique so not as fast as a creating a new pixel mapping system). Will post code when I get home.

There’s some discussion of a few different techniques in the comments here: https://plus.google.com/+JasonCoon1/posts/PsFjSyFbf2e

What does your layout look like?

The way I do this is is I have an array of X/Y coordinates - something like:

uint8_t XY[NUM_LEDS][2] = { {10,11}, {33,42}, … };

then my led/pattern functions take in an XY coordinate for deciding what should be shown where and my loop looks something like:

for(int i = 0; i < NUM_LEDS; i++) {
leds[i] = pattern_function(XY[i][0], XY[i][1]);

CRGB pattern_function(uint8_t x, uint8_t y) {
return CHSV(x+y, 128, 128);

I did this by building a map in excel, then running some code to build the array of the LED numbers that I could paste into the arduino code. Then I just run through either the vertical or horizontal array either forwards or backwards to get the patterns I wanted. Does that make any sense? And it’s not too slow I’m running about 300 WS2812Bs over eight strips on a teensy 3.2

Im with @Jeremy_Spencer i dot the same thing. I have projects that run into 1000s of LEDs with this technique

I just started messing with this one

I did a while ago play around with a masked version of my matrix code but felt I could improve it so never released it. You basically had to supply a binary mask when declaring it that had 1’s where leds existed. I could revisit this if anyones interested.

@Aaron_Liddiment Re the masks, i do this with all my mapped led installations. Its very useful but memory intensive.

My method had an overhead of 2 bytes ram per line and 1 byte rom for every 8 leds. The ram bytes are for start of line indexes which made it quicker.

Mvoe to 2:22 in this video, it’s a coat I did the electronics for. This was for the London art and Fashion week.