understanding getPixelColor in Neopixel Library

According to Adafruit, the function getPixelColor returns an “32-bit merged color value”

When I set it to fetch the value for a WS2812B set at 10,10,10 and println, the monitor shows the value to be 657930. This is the 32 bit merged colour value.

From an Adafruit forum discussion, I’ve learned that this number is the summation of the following formula:

(red * 65536) + (green * 256) + blue

So sub’ing in my 10,10,10 to confirm this formula:

(10* 65536) + (10 * 256) + 10 = 655360 + 2560 + 10 = 657930

Excellent. Now we’ve found bedrock.

Now question is… can I extract the RGB value just by knowing the 32BMV?

From a math standpoint, it seems like ascertaining 3 unknown variables from an equation is impossible. BUT since I am using making the yellow using only one random value and then dividing that value by 3 to make the green to mix w the red to get the yellow, it is possible. GENIUS!

Therefore, applied to Digital Rothko sketch, it becomes:

(red* 65536) + (red/3 * 256)  + 0 = 32BMV

red = 32BMV / 65621.33

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *