Hi! Thanks for the wiring diagram, that really helps.
I think you might not need the mapper. The mapper is best when you want to run patterns written in terms of 2D space on your particular project and wiring. In that way it also makes it a lot easier to use patterns other people write for their projects.
I think you might be best served by writing your own maps to transform your physical indices to another arrangement. I’m going to use the term “map” and “remap” in the examples below, but they do not refer to the built in mapper. We’re just writing our own index-transforming maps.
For example, let’s figure out this transform:
Here’s code for a small color changing pulse traveling along your physical indices:
export function render(index) {
// (map will go here)
v = index == floor(time(0.05) * pixelCount)
hsv(index / pixelCount, 1, v)
}
So we need some code to say, “When render
says index is 17, let’s feed it to the rest of the math as if index = 1”. Here’s the map I think you want:
17 => 1 9 => 11 50 => 21
16 => 2 8 => 12 49 => 42
... ... ...etc
10 => 8 1 => 19
35 => 9 18 => 20
34 => 10
One way to make the map would be to code a bunch of if
ranges. Let’s only do the first 8 pixels. Note how we are transforming index
to something called newIndex
so we find-and-replace those terms in the code below the map transform. (You could also reassign index
itself but maybe that’s a touch less clear.)
export function render(index) {
if (index >=10 && index <= 17) {
newIndex = 18 - index // 17 becomes 1, 10 becomes 8
}
v = newIndex == floor(time(0.05) * pixelCount)
hsv(newIndex / pixelCount, 1, v)
}
This might get tedious and hard to fix edge cases, so instead you might find it easier to work with an array that does the transform for you, pixel by pixel. The array’s order is such that the first element (array index 0) is whatever we’d like the newIndex
to be set to when the physical LED index is zero. I know you’ll need to read that sentence a few times, but look at the code and you’ll see it’s pretty straightforward.
I see that you started your diagram with an LED numbered 1, when usually that’s the LED we refer to as having its index set to 0. So in this example, to keep it consistent with the diagram and code above, we’re going to skip physical index 0.
map = array(pixelCount)
map[ 0] = 0 // I do NOT assume index = 0 is what you labeled as LED #1
map[ 1] = 17
map[ 2] = 16
// etc
map[ 8] = 10
map[ 9] = 35
map[10] = 34
map[11] = 9
// etc
export function render(index) {
newIndex = map[index]
v = newIndex == floor(time(0.05) * pixelCount)
hsv(newIndex / pixelCount, 1, v)
}
You could define map2[], map3[], etc for other flows/orderings. If you’re feeling good with all that (otherwise ignore this, it’s optional), here’s an example of using a third map via a 2D array:
maps = array(3)
maps[3] = array(pixelCount)
maps[3][0] = 0
// etc
newIndex = maps[3][index] // remap using the 3rd map
Does all this make sense?