LED fade and delay function

Hi Guys,

I'm up to the next stage of my project now and need a bit of help with the LED fade code.

I've got seven different sets of values which I assign with a switch case... this all works fine.

The idea is to map the led value and then use a time counter to increment the fadeR,G,B.

This all worked pretty well.

Now I need to stagger each succeeding LED so they come on one after the other and this has broken the code due to exceeding the time of 100.

I'm wondering if I should try rewriting the whole thing and use an array of values for each pixels RGB values... maybe this would help?

Any suggestions would be great.

Thanks!

Chris

// Main function used to chase the LEDs up and down
void chase(byte valR, byte valG, byte valB)
{
  //maths to work out increment for each colour
  uint8_t fadeR = constrain(map(time, 0, 100, 0, valR+10),0,100);
  uint8_t fadeG = constrain(map(time, 0, 100, 0, valG+10),0,100);
  uint8_t fadeB = constrain(map(time, 0, 100, 0, valB+10),0,100);
  //chase the colour on
  currenttime = millis();
  // main bit of code
    if(currenttime - previoustime > interval) // tells the function the interval at which to increment the LED brightness
    {      
      for(int i=0; i<pixel.numPixels(); i++) // incremments the LED so that you can light up multiple
      {                                     
            
            
            fadeDR = fadeR-(i*DELAYINT);
            fadeDG = fadeG-(i*DELAYINT);
            fadeDB = fadeB-(i*DELAYINT);
                        
            pixel.setPixelColor(i,curve(fadeDR),curve(fadeDG),curve(fadeDB)); // tells the LED what value it should be at
  
            time++;

            pixel.show();

            //lastButton = 8;
        
      } // close for loop
      previoustime = currenttime;
    } //   close if loop
}    //    close function

Please post ALL your code.
My crystal ball has crashed, so I can't tell what value DELAYINT has.

RaraAvis:
Now I need to stagger each succeeding LED so they come on one after the other and this has broken the code due to exceeding the time of 100.

I'm wondering if I should try rewriting the whole thing and use an array of values for each pixels RGB values... maybe this would help?

You need to rethink what it is you're trying to do.

You only need to change 2 leds at a time yet you process the whole array every time.

Also, I have no idea of what the apparent code object pixel does and no inclination to find out.
Does it by any chance have built-in delays?