I’m in need of a bit of assistance, i’m messing around with a HEAVILY modified Demoreel100 based sketch that I’m working on integrating a button into, this does exactly what I want it to do for the most part, right now it changes patterns every 15 seconds like I want it to, it changes patterns with the press of the button, and it stores gCurrentPatternNumber to the eeprom when I hold the button for 1 second just like it should. I’m trying to get it to “ignore” the nextPattern(); loop every 15 seconds but only when there wasn’t a “longpress” event. I basically want it to cycle through my patterns normally every 15 seconds and also advance to the next pattern when I press the button, then “lock” the current pattern that it’s on when I press and hold the button for 1 second. It’s probably as simple as an “If/Else” statement but I’m having trouble figuring out where to put it and what it needs to do. Can anyone give me some insight? Any help is greatly appreciated.
void loop()
{
gPatternsgCurrentPatternNumber; // Call the current pattern function once, updating the ‘leds’ array
readbutton();
FastLED.show(); // send the ‘leds’ array out to the actual LED strip
// do some periodic updates
EVERY_N_MILLISECONDS( 15 ) { gHue++; } // slowly cycle the “base color” through the rainbow
EVERY_N_SECONDS( 15 ) { nextPattern();} // change patterns every N seconds
} //loop()
void nextPattern()
{
// add one to the current pattern number, and wrap around at the end
gCurrentPatternNumber = (gCurrentPatternNumber + 1) % ARRAY_SIZE( gPatterns);
Serial.println(gCurrentPatternNumber);
}//nextPattern()
void readbutton() { // Read the button and increase the mode.
myBtn.read();
if(myBtn.wasReleased()) {
if (longpress==1) {
EEPROM.write(eepaddress, gCurrentPatternNumber);
Serial.print("Writing: ");
} else {
gCurrentPatternNumber = gCurrentPatternNumber > maxMode-1 ? 0 : gCurrentPatternNumber+1; // Reset to 0 only during a mode change.
}
longpress = 0;
Serial.println(gCurrentPatternNumber);
}
if(myBtn.pressedFor(1000)) {
longpress = 1;
}
}//readbutton()
