pixelblaze
pixelblaze copied to clipboard
Test Patterns
It would be helpful if there were a handful of test patterns that could be used to validate that the configuration of the strips are set up correctly; RGB in the right order, all pixels addressable as expected, etc.
Maybe only 3 (RGB) or 4 (RGBW) are needed where each exercises only one color channel.
Possibly, two pixels at the start/end, one pixel at 10,20,30,40,etc....
Might also be helpful to have a white "dot" that starts at 0 and goes to the end of the strip?
I haven't yet dove into the programming language enough to write such a pattern. I'll try to give it a shot when I have a moment, but am hoping someone can beat me to it. :)
I usually eyeball whats in the live preview. The "An Intro to Pixelblaze Code" does walk you through color order. This pattern does many of the things you are looking for, including the white dot: https://github.com/jvyduna/pb-examples/blob/master/src/Utility_%20Mapping%20helper%202D_3D.js
Still, maybe a test button on the settings page would be pretty nice!
This is what I meant.
This snippet does two things;
- ensures that the RGB ordering is correct. Should be 2 seconds of red, then green, then blue.
- puts a white pixel at the beginning and the end of the strip, ensuring that the # of LEDs is configured correctly.
- puts a color dot every 10 LEDs to help get a feel for spacing
A dead simple test of whether or not things are configured correctly. I appreciate that the intro does all this and more, but it isn't nearly as approachable for a basic sanity test. Especially for newcomers.
(The first version of this code was utterly wrong. Shamefully horribly wrong. Wrong wrong wrong. Moved to a much simpler, pure RGB based, implementation. And added a grey first mode so you have an anchor. So, should be grey-red-green-blue w/2 seconds on each color. White end caps to ensure you got the LED count right.)
/*
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)
}
}