I am using something similar for an led array that is used both in the daytime and the night, and it is too bright in the night. One other way that you can do this, if not using HSL and you want to manipulate the whole array, You can objectify a brightness value to apply to the sketch by using a helper function. This example below is simplified for if you are receiving your colour values as rgb input. This would work in two parts:
firstly, so that you can just use any value into a fixed value for brightness for all leds:
Code:
float brightness = 40; //should be value between 1-255, or can be a value received from another function//
//--------Brightness HELPER FUNCTION-----------//
float scale = brightness/255;
secondly, use the colour helper function that this relates to:
Code:
//-------Colour HELPER FUNCTION------//
// Create a 24 bit color value from R,G,B ////these strips are BRG, but you might need to change this
unsigned int Color(byte b, byte r, byte g)
{
b = b*scale;g=g*scale;r=r*scale;
//Take the lowest 8 bits of each value and append them end to end
return( ((unsigned int)r & 0xFF )<<16 | ((unsigned int)g & 0xFF)<<8 | (unsigned int)b & 0xFF);
}
in your code you could then use the Color function such as:
Code:
leds.setPixel(i, Color(255,0,0));//B-R-G
so, I know that it isn't needed as written i.e. 255,0,0, but but if you had a loop getting rgb values and pasting then into a buffer, and that buffer was then accessed by the loop with the 'Color' function, you get your brightness output, like Color(x,y,z), where x,y,and z are objects. This way you can input original colours quickly from different sources, without looking into changing individual values.
Also (but I have not tried it yet) you should be able to make the brightness float receive a value from an external source (perhaps an analogue input from a 'brightness dial'.
note that as wozzy pointed out, this is not a straight linear relationship.