I am using the neopixel library, and I saw this snippet of code and was completely amazed it worked.
uint32_t red = flora.Color(0, 255, 0);
...
flora.setPixelColor(1,red);
my question is, I thought uint32_t was an unsigned integer (just numbers), how does this nifty trick work. I don't get how the object.attribute was allowed to be used that way.
Can someone explain this to me. What is going on behind the scenes here? Is this the general usage of uint32_t?
Not quite - it's not uint32_t that's doing the magic here. That's just a variable type (32 bit unsigned integer).
The Color() function is the important bit. It takes the three separate RGB values, and combines them into a single 32 bit number that you can store for later use.
The first number is the hexadecimal representation so you can see what is placed where, the second number (between brackets) the decimal representation.
If you use uint32_t red = flora.Color(0x33, 0xFF, 0x44);, it might be clearer; output: