Help ! My follower pixelblaze does not display anything a specific pattern?

Hello !

I’m currently building and testing the stage lights i’ve been working on:

  • suspended ring, 2x 800 LED (parallel data line) = Pixelblaze + sensor board “master” // Mapping is “ring” stock code
  • straight bar light 73 LED = Pixelblaze STD “follower” // mapping is as below:
function (pixelCount) {
  width = 1 //Note that using 1 or 2 does not change anything
  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
}

Most of the patterns work fine on the “master” and “follower”, I even have patterns using “y” for left/right effects actually going from left to right on both pieces.

However i have 2 issues:

  1. Some patterns don’t show up the same: it seems the “bar = slave” displays only the 73 first pixels of whatever pattern is displayed on the ring (which is the “master”. Shouldn’t it work using PixelCount ? I assume it is because some patterns use “index”, but do you know if there is a way to adapt easily a 1D pattern using index (to rotate around the ring for example) so it uses y instead of index for example ? I think it would solve the problem but not sure how to write it

  2. Some patterns don’t display anything at all on the “slave bar” even though other patterns work fine. I have checked and there is actually a render 2D function working in both, but since both have mapping information it should work well, the same as other patterns. Example: the famous SpectromatrixRender2D with code as below:

//This pattern uses the sensor expansion board
export var frequencyData

width = 1
zigzag = true


averageWindowMs = 750
sensitivity = 0
fade = .585

averages = array(32)
pixels = array(pixelCount)

speed = 2

targetFill = 0.07
brightnessFeedback = 0

pic = makePIController(.05, .15, 30, 0, 400)

// Makes a new PI Controller
function makePIController(kp, ki, start, min, max) {
  var pic = array(5)
  pic[0] = kp
  pic[1] = ki
  pic[2] = start
  pic[3] = min
  pic[4] = max
  return pic
}

function calcPIController(pic, err) {
  pic[2] = clamp(pic[2] + err, pic[3], pic[4])
  return pic[0] * err + pic[1] * pic[2]
}

export function beforeRender(delta) {
  t1 = time(.2)
  t2 = time(.13)
  t3 = time(1)

  sensitivity = calcPIController(pic, targetFill - brightnessFeedback / pixelCount);
  brightnessFeedback = 0
  
  dw = delta / averageWindowMs
  for (i = 0; i < 32; i++) {
    averages[i] = max(.00001, averages[i] * (1 - dw) + frequencyData[i] * dw * sensitivity)
  }

}

//interpolates values between indexes in an array
function arrayLerp(a, i) {
  var ifloor, iceil, ratio
  ifloor = floor(i)
  iceil = ceil(i);
  ratio = i - ifloor;
  return a[ifloor] * (1 - ratio) + a[iceil] * ratio
}

export function render2D(index, x, y) {
  var i, h, s, v

  i = triangle((wave(x + wave(t1 * speed)) + wave(y - wave(t1 * speed))) / 2 + t2 * speed) * 31

  v = (arrayLerp(frequencyData, i) * sensitivity - arrayLerp(averages, i)) * 10 * (arrayLerp(averages, i) * 1000 + .5)

  h = i / 600 +t3
  v = v > 0 ? v * v : 0
  s = 1 - v
  pixels[index] = pixels[index] * fade + v
  v = pixels[index];

  brightnessFeedback += clamp(v, 0, 1)
  hsv(h, s, v)
}

//this pixel mapper shim will work without a pixel map or on older Pixelblazes
//it calculates x/y based on a 2D LED matrix display given a know width and height
export function render(index) {
  var width = 850, height = 1
  var y = floor(index / width)
  var x = index % width
  //comment out this next line if you don't have zigzag wiring:
  //x = (y % 2 == 0 ? x : width - 1 - x)
  x /= width
  y /= height
  render2D(index, x, y)
}

Since there is a mapping, the 2D render function should execute no ? I’ve tried to remove the whole function render(), but it does not change anything… Could it be the fact the pattern is using x as well: but in this case can"t we see anything even if i map a 2 column matrix ?

Thank you very much !

Some patterns are defined in terms of pixel indices, not the percentage of all pixels (index / pixelCount). The sparks patterns are good examples of this.

For your map on the straight light bar, it looks like you’ve adapted the matrix code. You may instead want to define it as a horizontal line at the bottom of the map, or, you may find it best for 2D patterns to tell it it’s a diagonal line from (0,0) to (1,1).


function (pixelCount) {

  var map = []

  for (i = 0; i < pixelCount; i++) { 
    x = i / pixelCount 
    y = x // Diagonal
    // or….
    // y = 1 // Bottom

    map.push([x, y])
  }
  return map
}