       return;
   }
   
-  uint8_t delay = 8;
-  
-  switch(patternIndex)
-  {
-      case 0:
-      default:
-      delay = rainbow();
-      break;
-      
-      case 1:
-      delay = rainbowWithGlitter();
-      break;
-      
-      case 2:
-      delay = confetti();
-      break;
-      
-      case 3:
-      delay = sinelon();
-      break;
-      
-      case 4:
-      delay = bpm();
-      break;
-      
-      case 5:
-      delay = juggle();
-      break;
-      
-      case 6:
-      delay = fire();
-      break;
-      
-      case 7:
-      delay = analogClock();
-      break;
-      
-      case 8:
-      delay = fastAnalogClock();
-      break;
-      
-      case 9:
-      delay = showSolidColor(solidColor);
-      break;
-  }
+  uint8_t delay = patterns[patternIndex].drawFrame();
   
   // send the 'leds' array out to the actual LED strip
   FastLED.show();

        brightness = 1;
    else if(brightness > 255)
        brightness = 255;
    
    uint8_t timezoneSign = EEPROM.read(1);
    if(timezoneSign < 1)

    return 125;
}

uint8_t showSolidColor() {
    fill_solid(leds, NUM_LEDS, solidColor);
    
    return 30;
}

void heatMap(CRGBPalette16 palette, bool up) {
    fill_solid(leds, NUM_LEDS, CRGB::Black);
    
    // Add entropy to random number generator; we use a lot of it.
    random16_add_entropy(random(256));
    
    uint8_t cooling = 55;
    uint8_t sparking = 120;
    
    // Array of temperature readings at each simulation cell
    static const uint8_t halfLedCount = NUM_LEDS / 2;
    static byte heat[2][halfLedCount];
    
    byte colorindex;
    
    for(uint8_t x = 0; x < 2; x++) {
        // Step 1.  Cool down every cell a little
        for( int i = 0; i < halfLedCount; i++) {
          heat[x][i] = qsub8( heat[x][i],  random8(0, ((cooling * 10) / halfLedCount) + 2));
        }
        
        // Step 2.  Heat from each cell drifts 'up' and diffuses a little
        for( int k= halfLedCount - 1; k >= 2; k--) {
          heat[x][k] = (heat[x][k - 1] + heat[x][k - 2] + heat[x][k - 2] ) / 3;
        }
        
        // Step 3.  Randomly ignite new 'sparks' of heat near the bottom
        if( random8() < sparking ) {
          int y = random8(7);
          heat[x][y] = qadd8( heat[x][y], random8(160,255) );
        }
        
        // Step 4.  Map from heat cells to LED colors
        for( int j = 0; j < halfLedCount; j++) {
            // Scale the heat value from 0-255 down to 0-240
            // for best results with color palettes.
            colorindex = scale8(heat[x][j], 240);
            
            CRGB color = ColorFromPalette(palette, colorindex);
            
            if(up) {
                if(x == 0) {
                    leds[(halfLedCount - 1) - j] = color;
                }
                else {
                    leds[halfLedCount + j] = color;
                }
            }
            else {
                if(x == 0) {
                    leds[j] = color;
                }
                else {
                    leds[(NUM_LEDS - 1) - j] = color;
                }
            }
        }
    }
}

int oldSecTime = 0;
int oldSec = 0;

void drawAnalogClock(byte second, byte minute, byte hour, boolean drawMillis, boolean drawSecond) {
    if(Time.second() != oldSec){
