Simple Configuration Tester

I’m new to this whole gig.

Configuring PixelBlaze for the LED strip at hand was a bit of a challenge.

I wrote a pattern to make it easier.

/*
Simple LED strip configuration tester.

1. Puts white pixels at each end of the strip, verifying that the LED count is correct.
2. Sequences colors starting with White, then Red, Green, Blue in that order.
3. Puts a colored pixel every 10 pixels.

This makes it easy to test the strip settings to ensure that the color order and pixel count are correct.
*/

numModes = 4
modes = array(numModes) // Make an array to store the modes

modes[0]  = [0.5, 0.5, 0.5]
modes[1]  = [1, 0, 0]
modes[2]  = [0, 1, 0]
modes[3]  = [0, 0, 1]

timer = 0 // Accumulate all the deltas each animation frame

export var mode = 0 // Start with mode 0

export function beforeRender(delta) {
  timer += delta // Accumulate all the deltas into a timer
  if (timer > 2000) { // After 600ms, rewind the timer and switch modes
    timer -= 2000
    mode = (mode + 1) % numModes // Go to the next mode, and keep between 0 and numModes
  }
}

export function render(index) {
  if ((index == 0) || (index == (pixelCount - 1))) {
    rgb(0.5,0.5,0.5)
  } else if ( (index % 10) == 0) {
    // look up the RGB color values and set the color
    rgbColor = modes[mode]
    rgb(rgbColor[0], rgbColor[1], rgbColor[2])
  } else {
    rgb(0,0,0)
  }
}
5 Likes