I am working with fastLED.h library and 200 WS2811 LEDs.
I have some functions in my project sketch that are identical except for the color. So I pass the color as a hex value.
For example:
The call:
oneLed(0xFFA07A);
The function:
void oneLed(unsigned int myColor) {
// Move a single led
for (int ledNum = 0; ledNum < NUM_LEDS; ledNum = ledNum + 1) {
leds[ledNum] = myColor;
FastLED.show();
delay(pixelDelay);
// Turn our current led back to black for the next loop around
leds[ledNum] = CRGB::Black;
}
}
Is there a way to specify the color as an argument to the function so that I don't have to find the hex value for each color I want to use?
Thanks, Paul. So, in the function parameters, I treat CRGB as the data type? Then why are the double colons required in the call? Why wouldn't oneLed(CRGB LightSalmon); work?
The scope resolution operator confuses me to no end. (And I thought pointers would break me, then you, among others, rescued me from String hell).
When you call a function (or in this case a class method), you don't/can't specify the data type. You can only define the data type when you define the method.