I want to implement three effects which display every 5 seconds. I know that using delay() is not a good method so I want to use milis(). Duration times of the effects are different from each other. How can I assure "non-freezing" or displaying 2 or 3 effects at the same time? Should I measure the time of display of every effect and on its base adjust intervals or is there another solution? What do you think?
EDIT:
Here is my code:
void loop() {
unsigned long currentMillis = millis();
if(currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
i++;
switch (i){
case 1:
meteorRain(0xff,0xff,0xff,10, 64, true, 30); // efekt spadającej gwiazdy
Serial.print("meteorrain: ");
Serial.print(previousMillis);
Serial.print("\n");
break;
case 2:
colorWipe(0x90,0x90,0x90, 50);
colorWipe(0x00,0x00,0x00, 50);
Serial.print("colorwipe: ");
Serial.print(previousMillis);
Serial.print("\n");
break;
case 3:
MyEffect();
Serial.print("My effect: ");
Serial.print(previousMillis);
Serial.print("\n");
break;
}
if (i>3) i=0;
}
}
I've ommited the code of effects (it doesn't matter, I think).