Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename the Color class to avoid collisions #4

Open
alranel opened this issue Feb 27, 2024 · 0 comments
Open

Rename the Color class to avoid collisions #4

alranel opened this issue Feb 27, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@alranel
Copy link
Member

alranel commented Feb 27, 2024

Unfortunately, the ArduinoIoTCloud library declares its own Color class. This makes it impossible to use Modulino.h in an IoT Cloud project. Likely, other third-party libraries may declare a Color class considering it's a pretty generic name, as well as variables or constants named RED, BLUE, GREEN...

We need to find a future-proof solution to avoid collisions.

Proposal 1 (easy)

Let's not expose any class for colors nor constants in Modulino. To set LED color we'll use this basic signature:

void ModulinoPixels::set(int idx, uint8_t r, uint8_t g, uint8_t b, uint8_t brightness = 255);

Proposal 2 (more ambitious)

Let's create an official Arduino_Color library exporting an Arduino_Color class providing a very generic and versatile API that any third-party library can implement. This library would also export a Color alias in the global namespace, except when a user tells it to not do so:

#define ARDUINO_COLOR_NO_GLOBAL
#include <Arduino_Color.h>

Then, we modify the ArduinoIoTCloud library to use this one as a dependency. Ta-dah, we'd get magic interoperability between cloud and Modulinos:

pixels.set(0, my_cloud_color);
@alranel alranel added the bug Something isn't working label Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant