• Tue 2021.03.02

    Hello @Weiluen,

    The most basic approach is to set the value of each RGB element as a percentage of the maximum allowable value. This would be in the range from 0 to 255 decimal the equivalent of 0 to FF hexidecimal. But the percentage isn't a direct ratiometric conversion.

    As the eye doesn't perceive brightness as a color intensity level, and also struggles with the differences in color when displayed by a monitor or in this case an LED, there is the need to approximate those values.

    Using a standard WS2812B single Neopixel

    require("neopixel").write(B15, [255,0,0]); // turn RED LED to full intensity
    
    require("neopixel").write(B15, [0,127,0]); // turn GRN LED to half intensity
    
    require("neopixel").write(B15, [0,0,63]); // turn BLU LED to one quarter intensity
    

    It will soon be discoverd that there seems to be a better ratiometric control when the values are in the lower end of the range. This has to do with the eye's persistence when detecting color differences, and human perceived brightness then is just an approximation of that intensity value.

    This is one method of applying a brightness value as a percentage:

      var nPcntBr = Math.floor( nRGBvalue * nBrightness / 100 );
    

    Topics to discover, color palette, eye persistence, color Gamma, monitor color rendering, to name a few. There are many excellent tutorials at SparkFun and AdaFruit. Reverse engineering the FastLED module will also provide insight that may assist in getting a near perfect solution.

About

Avatar for Weiluen @Weiluen started