Suggestion for making the "color" property easier to use

I love being able to set widget color, thank you for that. I have two suggestions to make the API easier for makers:

  1. Overload .setProperty(int, "color", char*) to accept a uint32_t value like 0xFF00FF in addition to the char array "#FF00FF". This avoids people having to figure out sprintf or String::format for their platforms. I often see RGB colors represented by uint32_t, especially in color calculation functions.

  2. Consider adding a setColor(uint32_t) (or just color) method to the base Widget class, so that you could do more object-oriented expressions like:

    WidgetLED led1(V1);
    led1.on();
    led1.color(0xFF0000); // uint32_t
    // …
    led1.color("#0000FF"); // html string
    // …
    led1.color(0, 255, 0); // You could even overload to accept R, G, B
    What do you think?

2 Likes

I think this is a great idea.

Especially this as I want to allow FastLED library to change the slider colour to match the led colour

led1.color(0, 255, 0);  // You could even overload to accept R, G, B
2 Likes

Very nice idea. Thanks for sharing. I created ticket for that https://github.com/blynkkk/blynk-library/issues/227