Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test Patterns #17

Open
bbum opened this issue Jan 6, 2022 · 3 comments
Open

Test Patterns #17

bbum opened this issue Jan 6, 2022 · 3 comments

Comments

@bbum
Copy link
Contributor

bbum commented Jan 6, 2022

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?

@bbum
Copy link
Contributor Author

bbum commented Jan 6, 2022

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. :)

@simap
Copy link
Owner

simap commented Jan 6, 2022

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!

@bbum
Copy link
Contributor Author

bbum commented Jan 8, 2022

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)
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants