New to coding, sync issues, doing quite a large LED project

Hey lovely light wizards, i would love some help on understanding how to get patterns to sync up when using the output expander; for example if i have a string of 300 leds on one output and another 300 on another output and use a sound reactive pattern (and certain other patterns) they seem to be operating independently, is that something i can change in the code of the pattern itself and if so which parameters/lines of code do i edit, or is there a way to sequence my leds in the ouput expander section so the pattern plays at the same time?
Thankyou hugely in advance for any help.

Hi @Kemix ,

Adding a pixel map will get most patterns working like you want.

Without a pixel map, most patterns will try to spread out and scale using the entire set of addressable pixels. Even if you have two going on output expander ports, it’s going to treat that like one big strip.

Currently only 2d and 3d maps are supported but it will work for many patterns even if your two sets of pixels are a single overlapping line. Some 1d only patterns would need some code modification.

Try loading up a 2d matrix map, set the width to your led string length, and hard code the y coordinate (the second one) to something.

Ill do my best haha, i dont really understand coding at all yet.
Im guessing once i have a pixel map im happy with i copy the code from the pixel map and save it into the pattern code correct?

So something like this:

function (pixelCount) {
  width = 300
  var map = []
  for (i = 0; i < pixelCount; i++) {
    y = Math.floor(i / width)
    x = i % width
    x = y % 2 == 1 ? width - 1 - x : x //zigzag
    map.push([x, 0])
  return map

The two lines I modified from the example matrix map are changing width = 300 and map.push([x, 0]) to make each run 300 pixels, and stack on top of each other. That should work for any patterns that support render2D or render3D.

In many 1D only patterns, you can often modify them by making the pixel index wrap every 300 pixels using a modulus trick by adding this line to the start of any render() functions.

pixelCount = 300
index = index % pixelCount

For example, here’s the basic new example pattern rainbow modified:

export function beforeRender(delta) {
  t1 = time(.1)

export function render(index) {
  pixelCount = 300 //added this
  index = index % pixelCount //and this

  h = t1 + index/pixelCount
  s = 1
  v = 1
  hsv(h, s, v)