Global Mapping Functions

There’s one feature that I would like to see. It would be awesome if each pattern could, have its own separate map. For example I kind of have to split my playlist up between patterns that look good on ring and patterns that look good as a matrix.

It might be worth writing map transforms into certain patterns themselves! IE have one map that represents physical reality, then have a function or lookup table that converts that in a pattern code.

If you’d like an example, share the two map generators you’re using…

What does your map look like for ring and matrix? Do you mean 1D strip vs 2D mapping?

If you have a 1D / 2D capable pattern that doesn’t look good in 2D, renaming the render2D (and render3D if it has one) function will force it to use the 1D render function.

for example 2d fireworks fade and fast pulse look accurate with mapper tab on ring and shimmer crossfade looks accurate on matrix.

Not sure I 100% follow. can you post screenshots of the mapper tab?

this is with mapper tab set to ring

this is with it set to matrix


What we have here is a failure to communicate.

Neither of those YOUR setup.

You need to make a custom map of YOUR particular layout of LEDs.

Setting to Matrix is wrong: your LEDs are not in a matrix, not at all. Any “it works” is purely coincidence, and not what it should look like.

Setting to Ring is mostly wrong, your LEDs are in a ring like layout, but NOT in the default layout of that ring, so it “works, kinda sorta”

Does this describe your current setup? You also mentioned using an output expander, if so how?

If you really just combined it all down to one ring, since it’s all forked and when you light the “first led”, LEDs lights up two per wheel? How many LEDs in one wheel? Same number to both inner and outer circumferences?

Assuming the above is true, and your PB is set to the number of pixels in HALF the wheel, in the right order from where the ring begins, then that’s the ring layout, yes. The actual orientation matters (imagine a pattern with a top/bottom, but your “top” is 90° to the left) but that’s fixable in most patterns by a simple rotation transformation before the pattern starts, or globally in the map (which otherwise assumes where the starting point is)

You don’t need switchable maps, just the right map.

I fully understand that I do not have a matrix setup. So the example in the mapper tab I can just copy and paste that into each specific pattern code. That would be in before render correct? So my setup is this I have a total of 8 LED strips the outside circumference of each wheel ring is 176 pixels the inside circumference is 170 pixels. The two strips on each wheel are wired in parallel. The two front wheels connect to one channel on the expander the rears connect to the second Channel. Start index of rears is 176 start index of fronts is zero.
Sometimes i just round up to 200

Not at all. The mapper code is NOT PB code, it’s real JavaScript intended to return a set of coordinates, one time (and saved)

So it’s actually 176 x2? (Front and back?)
Or are you setting up the two channels as mirrored, so only 176 total?

If 176 is the start of the rear, then you have 352 pixels in the PB settings?

If that’s the case, then it’s two rings, not one and that’s what your map needs to do, as a custom map, not a single ring.

Sorry, I’m really not understanding how you have it setup, and without that, mapping is pretty difficult. The 176-only setup (Total in PB is 176, mirrored onto all 4 wheels, 2 strips on each) is the most ring-like…

Btw, the 176 vs 170 is also an issue, it won’t look quite right…one will be shifted a bit…

You shouldn’t be using the matrix map at all. You might like the way it works but that’s purely coincidence and there is no easy way to swap mappers like that. It’s a totally different map, also 2D, so the suggestion above about 1D/2D won’t help.

yep there mirrored. So the pattern begins at the inside strip and the outside strip at the same time. Yeah it is slightly off but not very noticable

I’ve tried both ways 352 total pixels that way I can set the color order for the front separate from the rear which is kind of cool but I also lose frame rate or just one data Channel 176 total for all four wheels. If I set it at 352 and the rear wheels pixel index starts at 176 then for example firework rocket Sparks begins on the front wheels and then immediately continues on the rear wheels.

If it’s not easy to do it’s not really a big deal majority of the patterns look accurate when I keep it on ring.

That’s the best for your setup, yes.

So if you matrix mapped that setup, it would be technically wrong (or perhaps inaccurate is the right word) but if it looks good, thats really what you are after, no harm in that. You can get that same “look” with similar code to the pixel mapper code in a single pattern to replicate that same look.

Some of the older 2D patterns calculated x and y on the fly based on pixel index before we had the mapper feature. We can do something similar with an existing pattern. Here’s a basic template of that code that you can copy in to existing patterns to make them look like they were matrix mapped, effectively ignoring the actual pixel map and doing a matrix map on the fly:

//add these 2 settings to the top of the pattern so you can adjust the look
width = 8 // the width of the 2D matrix
zigzag = true //straight or zigzag wiring?

export function render2D(index, x, y) {
  //copy this code to the start of the render function
  y = floor(index/width)
  x = (index%width)/width
  if (zigzag) {
    x = (y % 2 == 0 ? x : 1-x)
  y /= width
  //end of copy/paste
  //... original pattern code

This works by overwriting the x and y values with ones that are calculated based on the pixel index, much like the matrix mapper would do.

1 Like

Awesome thank you that’s what I was looking for majority of the patterns are fine on ring but I would like to include a couple of them in my playlist that look good as a matrix even though i don’t have a matrix setup.