I was wondering if there was a way to adjust the output brightness of the BlinkStick Pro. I am using the Processing API, but I imagine all the API’s are probably pretty similar. Obviously, there is no built-in function for brightness control (at least in Processing), but I am looking for a trick to somehow adjust the color values for a desired brightness percentage.
My current (not yet working) solution is to convert the GRB color data from an array and converting that into a similar array with HSV values. I then multiply the brightness value by whatever percentage I want and convert back to GRB. I then write this new array to the BlinkStick.
This method works for this function:
void colorWipe(color c, int wait, int start, int end) {
// calculate the values once
byte red = (byte)red(c);
byte green = (byte)green(c);
byte blue = (byte)blue(c);
// set each pixel's data values
for (int i = start*3; i < end*3; i+=3) {
data[i] = green;
data[i+1] = red;
data[i+2] = blue;
// and write the data to the BlinkStick
//blinky.setColors(0, data);
show(127);
delay(wait);
}
}
** Note: show(127);
does the conversions mentioned above and sets the brightness to 50%, then writes the data using blinky.setColors(0, data);
However, my method does not work for this function:
void rainbow(int wait) {
for (int j = 0; j < 256; j++) { // for each color in the wheel...
for (int i = 0; i < nLED; i++) { // and each pixel in the strip...
// retrieve the color for the current pixel
color c = Wheel((i+j) & 255);
// store each byte of the color seperately
data[i*3] = (byte)green(c);
data[i*3 + 1] = (byte)red(c);
data[i*3 + 2] = (byte)blue(c);
}
//blinky.setColors(0, data);
show(127);
delay(wait);
}
}
Is there something different about the second function that breaks this method, or is there just something wrong with my conversions?
Regardless, is there an easier way to adjust the brightness of the entire strip while maintaining the color of each pixel?