#include <FastLED.h>
#define NUM_STRIPS 3
CRGBSet *strips[] = {
new CRGBArray<32>,
new CRGBArray<48>,
new CRGBArray<64>
};
void setup() {
FastLED.addLeds<WS2812B, 3, GRB>(strips[0]->leds, strips[0]->size());
FastLED.addLeds<WS2812B, 4, GRB>(strips[1]->leds, strips[1]->size());
FastLED.addLeds<WS2812B, 5, GRB>(strips[2]->leds, strips[2]->size());
Serial.begin(115200);
}
struct stateVariables {
char name[11];
unsigned long interval;
CHSV ringColours[3];
};
stateVariables states[] = {
{"RED", 9000, { CHSV(0, 255, 192), CHSV(0, 0, 0), CHSV(0, 0, 0) } },
{"RED_YELLOW", 2000, { CHSV(0, 255, 192), CHSV(32, 255, 255), CHSV(0, 0, 0) } },
{"GREEN", 6000, { CHSV(0, 0, 0), CHSV(0, 0, 0), CHSV(80, 255, 168) } },
{"YELLOW", 2000, { CHSV(0, 0, 0), CHSV(32, 255, 255), CHSV(0, 0, 0) } },
{"FLASHING", 600, { CHSV(0, 0, 0), CHSV(0, 0, 0), CHSV(0, 0, 0) } },
{"FLASHING", 600, { CHSV(0, 0, 0), CHSV(32, 255, 255), CHSV(0, 0, 0) } },
{"FLASHING", 600, { CHSV(0, 0, 0), CHSV(0, 0, 0), CHSV(0, 0, 0) } },
{"FLASHING", 600, { CHSV(0, 0, 0), CHSV(32, 255, 255), CHSV(0, 0, 0) } },
{"FLASHING", 600, { CHSV(0, 0, 0), CHSV(0, 0, 0), CHSV(0, 0, 0) } },
{"FLASHING", 600, { CHSV(0, 0, 0), CHSV(32, 255, 255), CHSV(0, 0, 0) } },
{"FLASHING", 600, { CHSV(0, 0, 0), CHSV(0, 0, 0), CHSV(0, 0, 0) } },
{"FLASHING", 600, { CHSV(0, 0, 0), CHSV(32, 255, 255), CHSV(0, 0, 0) } },
{"FLASHING", 600, { CHSV(0, 0, 0), CHSV(0, 0, 0), CHSV(0, 0, 0) } },
{"FLASHING", 600, { CHSV(0, 0, 0), CHSV(32, 255, 255), CHSV(0, 0, 0) } },
};
const size_t sz_states = sizeof(states) / sizeof(*states);
void fillRings(byte state) {
for (byte i = 0; i <= NUM_STRIPS; i++) {
fill_solid(strips[i]->leds, strips[i]->size(), states[state].ringColours[i]);
}
}
// Or fillRings() could take a pointer to an array of CHSVs
void fillRings_ptr(CHSV *colours) {
for (byte i = 0; i <= NUM_STRIPS; i++) {
fill_solid(strips[i]->leds, strips[i]->size(), colours[i]);
}
}
void loop() {
static byte state = 0;
Serial.println(states[state].name);
fillRings(state);
// fillRings_ptr(states[state].ringColours);
FastLED.show();
delay(states[state].interval);
state = (state + 1) % sz_states;
}