so no luck?
I would go for a modification of the state machine to only check for button state when you have completed a cycle
#include <FastLED.h>
#define NUM_LEDS 30
#define DATA_PIN 5
CRGB leds[NUM_LEDS];
const byte buttonPin = 7;
enum : byte {STOPPED, RUNNING, PAUSING} currentState = STOPPED;
const int deltaStep = 5;
const int startingColor = 255;
int colorStep = startingColor;
unsigned long pauseStartTime;
const unsigned long pauseDuration = 1000; // in ms ie 1 second
void fillStrip(byte c) {
for (byte px = 0; px < NUM_LEDS; px++) leds[px] = CRGB(0, c, 0);
FastLED.show();
}
void black() {
FastLED.clear();
FastLED.show(); // not sure if this is neeed after clear
}
void manageStrip() {
switch (currentState) {
case STOPPED: // we are stopped, if there is one button press, start running
if (digitalRead(buttonPin) == LOW) {
colorStep = startingColor;
currentState = RUNNING;
}
break;
case RUNNING: // run a complete cycle, at the end check for button still pressed
fillStrip(colorStep);
colorStep -= deltaStep;
if (colorStep <= 0) {
black();
if (digitalRead(buttonPin) == LOW) { // button is still pressed, pause for a bit
colorStep = startingColor;
pauseStartTime = millis();
currentState = PAUSING;
} else { // button is no longer pressed, stop
currentState = STOPPED;
}
}
break;
case PAUSING:
if (millis() - pauseStartTime >= pauseDuration) {
currentState = RUNNING;
}
break;
}
}
void setup() {
pinMode(buttonPin, INPUT_PULLUP); // wire pin D7 --- button --- GND
FastLED.addLeds<WS2811, DATA_PIN, RGB>(leds, NUM_LEDS);
black();
}
void loop() {
manageStrip();
}
(typed here, fully untested)