Question: is it possible to initialize an array of APA102 objects?
dimitre opened this issue · 4 comments
It would be great to have an array of APA102 object and iterate over them. is it possible?
You cannot have a useful array of APA102 objects because all elements of an array have to have the same type, and the pins used by the LED strip are baked into the type of the APA102 object as template parameters.
However, you can do something which is pretty much just as good: using the APA102Base base class that we provide, you can have an array of pointers to different APA102 objects. You would define it using code that looks something like this:
APA102<dataPin0, clockPin0> strip0;
APA102<dataPin1, clockPin1> strip1;
APA102<dataPin2, clockPin2> strip2;
APA102Base * ledStripArray[] = { &strip0, &strip1, &strip2 };
Thanks, working great here!
Just for information your lib is running great on teensy 3.2 and 3.5, including the new 3.5 ports.
Cheers
Suggestion:
I'm using this constructors for rgb_color
typedef struct rgb_color
{
uint8_t red, green, blue;
rgb_color() {};
rgb_color(uint8_t r, uint8_t g, uint8_t b) : red(r), green(g), blue(b) {};
} rgb_color;
This way I can make this kind of compact calls, and port easily code from FastLED here
colors[i] = rgb_color(0, 30, 255);
Yeah, that sounds good. It would be a way to solve the warning about narrowing conversions we get for libraries like this: