I have a few different strings of LEDs that I use with a given script, and they each have a different number of LEDs and color order. I'm wondering if there's a way to change their configs dynamically in setup()?
I know NUM_LEDS wants a const int. Is there some way to redefine that?
Here's an example:
#include "FastLED.h"
//#define NUM_LEDS 750
const int NUM_LEDS = 750;
#define LED_TYPE WS2811
//#define BRIGHTNESS 255
const int BRIGHTNESS = 255;
#define COLOR_ORDER RGB //RGB
#define LED_PIN 23
CRGB leds[NUM_LEDS];
void setup() {
Serial.begin(115200);
Serial.println("Starting up...");
int config_num=1;
if (config_num==1) {
const int NUM_LEDS = 32;
CRGB leds[NUM_LEDS];
const int BRIGHTNESS = 20;
// how to change COLOR_ORDER to "GRB"?
// how to change LED_TYPE?
}
FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.setBrightness(BRIGHTNESS);
FastLED.clear();
Serial.print("Set the brightness to: ");
Serial.println(BRIGHTNESS); // this prints 255
}
void loop() {
fill_solid(leds, NUM_LEDS, CRGB::Red);
FastLED.show();
delay(200);
fill_solid(leds, NUM_LEDS, CRGB::Green);
FastLED.show();
delay(200);
fill_solid(leds, NUM_LEDS, CRGB::Blue);
FastLED.show();
delay(200);
fill_solid(leds, NUM_LEDS, CRGB::Black);
FastLED.show();
delay(1000);
}
Can anyone think of a way to adjust the NUM_LEDS based on a configuration?