Hi,
FastLED.addLeds() does not support variables as pin value.
I need to create a pre build firmware that let the user choose the digital pin to use at runtime.
I can workaround it using a switch but even if I use the FastLED.addLeds inside a switch case, it sucks up memory every time I create new case in the switch.
Is there a way to do it without wasting memory?
Thanks
Will this work to convert a variable into a constant?
void loop() {
int i = 5;
addLeds(i);
end();
}
void addLeds(const int X) {
FastLED.addLeds(X);
// X++;
}
X++
says: "Error: increment of read-only parameter 'X'", so I guess it really is a constant. Can't test it, I don't have this FastLED library.
Erik_Baas:
Will this work to convert a variable into a constant?void loop() {
int i = 5;
addLeds(i);
end();
}
void addLeds(const int X) {
FastLED.addLeds(X);
// X++;
}
`X++` says: "Error: increment of read-only parameter 'X'", so I guess it really *is* a constant. Can't test it, I don't have this FastLED library.
Erik_Baas:
Will this work to convert a variable into a constant?void loop() {
int i = 5;
addLeds(i);
end();
}
void addLeds(const int X) {
FastLED.addLeds(X);
// X++;
}
`X++` says: "Error: increment of read-only parameter 'X'", so I guess it really *is* a constant. Can't test it, I don't have this FastLED library.
but this does not solve the problem.
I need to call
FastLED.addLeds(X);
only once in the code because addLeds is a template and it consumes memory every time I call it.
even this
if (pluto == true) {
FastLED.addLeds(X);
} else {
FastLED.addLeds(Y);
}
consumes memory because addLeds is "interpreted 2 times" at compile time.
Sorry, I thought your question was about "Initializing FastLED with non-constant pin values". Maybe I misread the topic title...