# Run same pattern start from 2 spots on 1 strip

Hello!

I am trying to build out a custom map and was wondering if anyone knew the best way to go about this.

I am working on a project where I have LEDs on a large archway.
The archway is about 10ft and about 2ft wide to give you and idea of the shape of this. Its a half circle LEDs on the outer edge and inner edge.

LEDs start on the the left outer edge, go over the outside edge (250 leds) to the right side then in the same circuit it wraps from the right side of the inner edge back to the left side (100 leds)

How can I write a map to where the LED pattern starts simultaneously from the inner and out left side and goes to the right side with the same timing.

So outer side starts at LED 0 and goes to Led 250 while inner side starts at 350 and goes to 251

Anyone know if this is possible?

Letâ€™s make it a 2D map and make the top y=0 and the bottom x=1 (in case you want to make patterns which are different on top and bottom). Then there is a different expression to calculate the x value depending on which direction youâ€™re going in, and we want to make the x values also go from 0 to 1.

Untested code follows!

``````function (pixelCount) {
var map = []
for(i = 0; i <= 250; i++) {
map[i] = [i/250,0]
}
for(i = 251; i <= 350; i++) {
n = i - 251 // n goes from 0 to 99
map[i] = [(99-n)/99,1]
}
return map
}
``````
1 Like

I think this is heading in the right direction.

I see the pattern going from the upper left starting point and around to the lower left point following the LED strip vs the pattern starting at both left points at same time and ending at both right points at the same time.

You havenâ€™t mentioned which pattern you are using. Existing patterns might not do what you want.

This mapper will work with a pattern with a Render2D() function, where the x value (between 0 and 1) tells you how far along the arch you are, and the y value (0 or 1) tells you whether you are on the top or the bottom.

It sounds to me like youâ€™re using a pattern which renders differently at y=0 vs y=1. Try changing the mapper code to `map[i] = [(99-n)/99,0]` so that every y coordinate is 0. Then both parts of the arch should get the same patternâ€¦ presuming the pattern uses Render2D() at all.

Hey @kissay!

Thanks sorceror for the 2D solution! Iâ€™ll offer one for the 1D patterns.

Over half the default patterns are 1D patterns. You can identify them because they display a [1D] in the top left when you run them, even when a map is provided. They are patterns that donâ€™t have an `export function render2D()` line, only an `export function render()` line.

These patterns depend heavily on the `index` variable, which is just the position of that pixel in the strip. It starts with index 0, so the third pixelâ€™s `index` is `2`. To fix these patterns, we wonâ€™t use the map; weâ€™ll decide how to transform the indices of your second, shorter run (the â€śinner rainbowâ€ť) that is reverse to the first.

Lots of â€ś1Dâ€ť patterns are written with some waves that repeat every 5-30 pixels. For these, things would look good if we flip the indices for the second, inner arc. To flip them, we want to find some function we can copy-paste just inside the `export function rendex(index) {}` part that will transform them like this:

This index Becomes this
0 0
249 249
250 349
349 250

Weâ€™ll also want pixelCount to be either 250 or 150 for that arc.

The code to do that is this:

``````if (index > 249) {
index = 599 - index
pixelCount = 150
} else {
pixelCount = 250
}
``````

For each 1D pattern you want to adapt, youâ€™ll need to copy-paste that inside `render()` at the top like this:

For example, with the built-in pattern â€śmarching rainbowâ€ť:

``````export function render(index) {
// PASTE THE NEW CODE HERE
if (index > 249) {
index = 599 - index
pixelCount = 150
} else {
pixelCount = 250
}

pct = index / pixelCount // Percent this pixel is into the overall strip
h = wave(wave(wave(t1 + pct)) - pct)
w1 = wave(t1 + pct)
w2 = wave(t2 - pct * 10)
v = w1 - w2
hsv(h, 1, v)
}
``````

This will work for many of the 1D patterns. If you find some that still donâ€™t look right, let us know which one looks off to you! Some that use pixelCount in other parts of the pattern may need a more specific fix.

2 Likes

Thank you both! This is all very helpful information.
I ordered an output expander to see if that will handle this as well.
I havenâ€™t fully installed the inner arches Strips yet so I am hoping I can use the output expander to run the inner sides LEDs with the same patterns as the outer strips and just wire it up so both strips are starting from the left side.

I will still give your suggestion a try Jeff but after this first arch is completed I will be doing a similar setup on 2 more arches that are much larger. So having the transform function in each pattern will need each of my pixel blazes to have different pixel counts hard coded in each pattern.

This is the end result of the 3 arches. They LED parts of it were destroyed during covid, so I am rebuilding it with a easier to use system/sync with new LEDs

1 Like