Probleme animation with neopixel

Hi all,

I have been interested in the world of arduino for a few weeks and I am now embarking on the design of a neopixel ring control program.

My goal would be to integrate two different modes managed by a button:

  • A passive mode where there would be an animation on each ring.

  • An active mode where the rings change to a fixed color.

Here in 4 points the idea that I have of the program:

  • When the button is disabled, you can see the rainbow and fade animation.

  • If the button is activated, the neopixels take on a fixed color for a certain time.

-If during this time the button is reactivated, this resets the duration of this time.

  • At the end of this time and without pressing the button, we find our rainbow animation and Fade.
#include <Adafruit_NeoPixel.h>

#define LED1_PIN11    11
#define LED1_NUM      16
#define LED2_PIN12    12
#define LED2_NUM      20

#define BOUTON_PIN     2
boolean etatBouton; 

const long pauseIntervalle = 5000;      
int rainbowCyclesInterval = 12; 
int long fadeIntervalle = 3500;

int rainbowCycles = 0;
int rainbowCycleCycles = 0;
int fade = 0;
int fadeFade = 0;

unsigned long rainbowCyclesPreviousMillis=0;
unsigned long fadePreviousMillis = 0;

long debutPauseIntervalle;
long temps;
long tempsBreath;
long tempsRainbow;


Adafruit_NeoPixel strip1 = Adafruit_NeoPixel(LED1_NUM, LED1_PIN11, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel strip2 = Adafruit_NeoPixel(LED2_NUM, LED2_PIN12, NEO_GRB + NEO_KHZ800);

////////////////////////////////////////////////////////////////////////////////////////////////////
void setup() {
 // Serial.begin(9600);
  
  pinMode(BOUTON_PIN, INPUT_PULLUP);
  etatBouton = HIGH;
  strip1.begin();
  strip2.begin();
  strip1.setBrightness(70);
  strip2.setBrightness(70);
  strip1.show();
  strip2.show();
  temps = millis();
}


void loop(){ 
  etatBouton = digitalRead(BOUTON_PIN);
  
 // Serial.println();
 // Serial.println();

  task_alive();
  task_rest();
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void task_alive(){  
  if((etatBouton == LOW)){     //Bouton Appuyé       
    strip1.fill(strip1.Color(255,0,0),0,LED1_NUM);
    strip2.fill(strip2.Color(255,255,255),0,LED2_NUM);
    strip1.show();
    strip2.show();
    
    temps = millis();       // Enregistre le temps
    debutPauseIntervalle = temps;
   }    
  
  if((etatBouton == HIGH)  && (millis() - debutPauseIntervalle <= pauseIntervalle)){
    strip1.fill(strip1.Color(255,0,0),0,LED1_NUM);
    strip2.fill(strip2.Color(255,255,255),0,LED2_NUM);
    strip1.show();
    strip2.show();
    temps = millis();    
   } 
 } 

void task_rest(){
    if((etatBouton == HIGH) && (millis() - debutPauseIntervalle > pauseIntervalle)){  //Bouton Relaché   
    for(;((millis() - rainbowCyclesPreviousMillis) >= rainbowCyclesInterval); rainbowCyclesPreviousMillis = millis()){
     rainbowCycle();
    }
    
   for(;((millis() - fadePreviousMillis) >= fadeIntervalle); fadePreviousMillis = millis()){
      
      Fade(255, 0, 0, fadeIntervalle);
    }
    
     temps = millis();
   }
}

//////////////////////////////////////////////////////////////////////////////////////////////
void rainbowCycle() {
  uint16_t i;

  //for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
    for(i=0; i< strip2.numPixels(); i++) {
      strip2.setPixelColor(i, Wheel(((i * 256 / strip2.numPixels()) + rainbowCycleCycles) & 255));
    }
    strip2.show();

  rainbowCycleCycles++;
  if(rainbowCycleCycles >= 256*5) rainbowCycleCycles = 0;
}

uint32_t Wheel(byte WheelPos) {
  WheelPos = 255 - WheelPos;
  if(WheelPos < 85) {
    return strip2.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  }
  if(WheelPos < 170) {
    WheelPos -= 85;
    return strip2.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
  WheelPos -= 170;
  return strip2.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}



void Fade(uint8_t red, uint8_t green, uint8_t blue, uint8_t wait){
  for(uint8_t b = 0; b <255; b++) {
  for(uint8_t i=0; i < strip1.numPixels(); i++) {
  strip1.setPixelColor(i, red * b/255, green * b/255, blue * b/255);
  }
  strip1.show();
  wait = fadeIntervalle;
    
  fadeFade++;
  if(fadeFade >= 256*5) fadeFade = 0;
}
  for(uint8_t b=255; b > 0; b--) {
     for(uint8_t i = 0; i < strip1.numPixels(); i++) {
        strip1.setPixelColor(i, red * b/255, green * b/255, blue * b/255);
     }
     strip1.show();
     wait = fadeIntervalle;
     
     fadeFade++;
  if(fadeFade >= 256*5) fadeFade = 0;
  }
}

Here is what my program looks like. Both modes work as I want with the button. However, a small problem persists.

During passive mode (button released + duration of time exceeded)
the rainbow animation marks a delay while the Fade animation is playing while I am not using any delay (); in this program

Does somebody have an idea ?