I somehow managed to make this works... Maybe it's not the prettiest and super optimised sketch, but:
#include "FastLED.h"
#define NUM_LEDS 300
CRGB leds[NUM_LEDS];
#define PIN 8
#define Select 2
int buttonPushCounter = -1;
bool buttonState = 0;
bool lastButtonState = 0;
#define Choose 3
bool buttonChooseState = 0;
bool lastButtonChoose = 0;
bool choose = 0;
void setup()
{
Serial.begin(9600);
pinMode(Select, INPUT_PULLUP);
pinMode(Choose, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(Select), counter, CHANGE);
attachInterrupt(digitalPinToInterrupt(Choose), selector, CHANGE);
FastLED.addLeds<WS2812B, PIN, GRB>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
}
void counter()
{
buttonState = digitalRead(Select);
if (buttonState != lastButtonState) {
if (buttonState == HIGH) {
buttonPushCounter++;
choose = 0;
if (buttonPushCounter > 10)
{
buttonPushCounter = 0;
}
Serial.println(buttonPushCounter);
}
lastButtonState = buttonState;
}
choose = 0;
}
void selector()
{
buttonChooseState = digitalRead(Choose);
if (buttonChooseState != lastButtonChoose) {
if (buttonChooseState == HIGH) {
choose = 1;
Serial.println("Choose pressed!");
}
lastButtonChoose = buttonChooseState;
}
}
void loop()
{
if (buttonPushCounter == 0 && (choose == 0 || choose == 1))
{
setAllOff();
}
if (buttonPushCounter == 1 && choose == 1)
{
Strobe(0xff, 0, 0, 3, 10, 100);
Strobe(0, 0, 0xff, 3, 10, 1000);
}
if (buttonPushCounter == 2 && choose == 1)
{
CylonBounce(0, 0xff, 0xff, 3);
}
if (buttonPushCounter == 3 && choose == 1)
{
RGBLoop();
}
}
void CylonBounce(byte red, byte green, byte blue, int EyeSize) {
for (int i = 0; i < NUM_LEDS - EyeSize - 2; i++) {
setAll(0, 0, 0);
setPixel(i, red / 10, green / 10, blue / 10);
for (int j = 1; j <= EyeSize; j++) {
setPixel(i + j, red, green, blue);
}
setPixel(i + EyeSize + 1, red / 10, green / 10, blue / 10);
showStrip();
}
for (int i = NUM_LEDS - EyeSize - 2; i > 0; i--) {
setAll(0, 0, 0);
setPixel(i, red / 10, green / 10, blue / 10);
for (int j = 1; j <= EyeSize; j++) {
setPixel(i + j, red, green, blue);
}
setPixel(i + EyeSize + 1, red / 10, green / 10, blue / 10);
showStrip();
}
}
void RGBLoop() {
for (int j = 0; j < 3; j++ ) {
// Fade IN
for (int k = 0; k < 256; k++) {
switch (j) {
case 0: setAll(k, 0, 0); break;
case 1: setAll(0, k, 0); break;
case 2: setAll(0, 0, k); break;
}
showStrip();
}
// Fade OUT
for (int k = 255; k >= 0; k--) {
switch (j) {
case 0: setAll(k, 0, 0); break;
case 1: setAll(0, k, 0); break;
case 2: setAll(0, 0, k); break;
}
showStrip();
}
}
}
void Strobe(byte red, byte green, byte blue, int StrobeCount, int FlashDelay, int EndPause) {
for (int j = 0; j < StrobeCount; j++) {
setAll(red, green, blue);
showStrip();
delay(FlashDelay);
setAll(0, 0, 0);
showStrip();
delay(FlashDelay);
}
delay(EndPause);
}
void showStrip() {
#ifdef ADAFRUIT_NEOPIXEL_H
// NeoPixel
strip.show();
#endif
#ifndef ADAFRUIT_NEOPIXEL_H
// FastLED
FastLED.show();
#endif
}
void setPixel(int Pixel, byte red, byte green, byte blue) {
#ifdef ADAFRUIT_NEOPIXEL_H
// NeoPixel
strip.setPixelColor(Pixel, strip.Color(red, green, blue));
#endif
#ifndef ADAFRUIT_NEOPIXEL_H
// FastLED
leds[Pixel].r = red;
leds[Pixel].g = green;
leds[Pixel].b = blue;
#endif
}
void setAll(byte red, byte green, byte blue) {
for (int i = 0; i < NUM_LEDS; i++ ) {
setPixel(i, red, green, blue);
}
showStrip();
}
void setAllOff() {
for (int i = 0; i < NUM_LEDS; i++ ) {
setPixel(i, 0, 0, 0);
}
showStrip();
}