Some sample code showing off the grid mapping.

Some sample code showing off the grid mapping. It’s a templated class, and two different instantiations that use linear interpolation to map from a small grid (say 20x20) of uint16_t values or CRGB objects to a larger grid (say, 200x200).

This way, if you have something that’s really expensive to compute per point, you can compute a much smaller number of points, and then fill in the spaces between when rendering out to the leds.

And for fun, the classes allow rotating around the center point :slight_smile:
https://gist.github.com/focalintent/5f97216341278976e749

Nice! borrows

this is fantastic

@Daniel_Garcia I’ve been using this code for a small project & I think I’ve found some problems. Specifically I’m not sure that "lerp8"ing CRGB structures works in your CRGBGridMap? When I put LEDs at odd locations, random new colors are introduced during the interpolation.

I created a PaletteGridMap which holds byte palette indexes instead of full CRGBs, to eliminate the need for a separate 17x17 grid in the code (just use the internal array in the GridMap.)

I haven’t specifically gone in and debugged the CRGB lerping but switching to use the palette map (with palette->CRGB translation happening during the write to the LEDs) fixed all the weird color issues. And it kind of makes sense that treating CRGB as a number might cause over/underflows between R G B?

Anyway, would love to contribute back if you’re interested in my changed code!

If you end up lerp’ing between four wildly different colors, the interpolation may end up interesting. (The grid map interpolates in 4 directions as well, not just two :).

Feel free to post a version of the map that works with palettes!

(I’ve actually got a wildly different version of this class that I did when I was working on Locus that still needs some more debugging, so i’ll probably put up a new version sometime soon).

Yeah, that’s what I found - and it was really easy to end up with differing colors when using anything other than a monochrome palette.

I’ll send up my modifications tonight after I get a chance to clean things up a little and make sure it all runs OK… I’d also be curious to see your alternate version! My goal is to create something with minimal memory footprint, which eventually might even mean virtualizing the underlying m_Data representation if there are patterns that can be represented mathematically rather than bit-wise.