Pixel Mapping Help / Design

Can someone help me with my pixel mapping i have 8 vertical led tubes, each tube is a channel on the output expander. The tube has leds back to back something like

Front of tube pixels 1 - 120 back of tube 121 - 240.
So pixel 1 and 240 are back to back at the bottom, 2 and 239 and so forth going up the tube

I think ideally the pixels on the front of the back and the tubes in the same position should be showing the same thing. However open to suggestions from people that have any pratical experience ?

Can anyone help me map this ? Thanks in advance im sorry the JS is beyond me

Terrible mock up. White line is my data and its my understanding it has to be like this ( and i have no more space on the output expander )

For those that have been helping me so far this is were im at currently !

Sounds like a zig-zag matrix, but 1) x doesn’t change on the backside run and 2) it goes down-up instead of left-right.

If we start from the built-in matrix map example:

function (pixelCount) {
  width = 8
  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, y])
  }
  return map
}

First let’s just swap x and y so that it goes down-up, down-up, and rename the width to be the height (120 LEDs - ledsPerStrip). We’ll get there by defining 16 vertical runs - I’ll call them verticalStrips.

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

We’re very close - note the flow looks good. We just need to make sure that the 2nd, 4th, 6th etc strips (the ones that flow data back up) share the same x-coordinate as the strip that preceded it. We do that by getting that floor function (whole number part of division) to work on 240 LEDs instead of 120 LEDs.

function (pixelCount) {
  verticalStrips = 16
  ledsPerStrip = pixelCount / verticalStrips
  var map = []
  for (i = 0; i < pixelCount; i++) {
    x = Math.floor(i / (ledsPerStrip * 2))  // This * 2 is the only change from the above
    y = i % ledsPerStrip
    y = x % 2 == 1 ? ledsPerStrip - 1 - y : y // zigzag
    map.push([x, y])
  }
  return map
}

LGTM:

11-33-49

1 Like

Amazing jeff im working at the momnet but hope to be able to test it on Saturday :slight_smile:

How does the script know there are 240 leds per channel does this come from the max pixel count set in the output expander config ? Sorry if this is stupid or basic question

Good eye! Just because pixelCount / 16 is assumed to be 120! It’d be partially broken/incomplete if the total number of pixels was somehow set such that it wasn’t.

Thanks Jeff i have had a play with this and it works great ! Making these for my wedding next weekend and we have so many things to prepair not been able to play fully.

I think afterwards i need to sit down to try properly understand the interaction between

mapping <-> pattern <-> pixel index setting

I guess getting into Thanks Jeff i have had a play with this and it works great ! Making these for my wedding next weekend and we have so many things to prepair not been able to play fully.

I think afterwards i need to sit down to try properly understand the interaction between

mapping <-> pattern <-> Pixel index

Starting to get into aesthetics how ‘should’ the pattern display vs how you would like it to display.

I said i wouldnt be back before my wedding 🫣 but ‘sound - rays’ made me do it !

This is my favourite pattern by far is there any way withing the pattern for it to overide the index for each output so it starts at 0 instead of whats given in the settings ? So all the outputs mirror each other instead of the design being spread across them. Anyone know ?

Not the most efficient answer, but certainly the laziest:

In the render() function, try replacing i = (index + pos) % pixelCount with i = (index + pos) % PPO. (where PPO is the number of pixels per output)

You might also want to replace ‘index’ with ‘i’ in the line h += index / pixelCount / 4 + t1

sorceror not just by name.

yay !! So happy - thanks