   }
 }
 
-// Candle flicker.
-void flicker(int8_t dir){
-  setStartEnd(dir);
+// Candle flicker, blown out, + ember glow
+void flicker(){
   static uint16_t i = 0;
   static uint8_t rnd = 0;
-  uint8_t stair = 0;
+  uint8_t r = 0, g = 0, b = 0;
+  int8_t stair = 0;
   gBright = 0;
-  for(gStair=gStairStart; (dir == 1 && gStair < gStairEnd ) || (dir == -1 && gStair >= gStairEnd && gStair <= gStairStart+1 ); gStair+=(2*dir)) {
+  for(gStair=0; gStair < NUM_LEDS; gStair+=2) {
     for( i = 0; i <= 18; i++ ) {
-      for (stair = gStairStart; (dir == 1 && stair <= gStair ) || ( dir == -1 && stair >= gStair && stair <= gStairStart+1); stair+=(2*dir)) {
+      for (stair = 0; stair <= gStair; stair+=2) {
         rnd = random8(1, 4);
         if ( rnd == 2 ){
           gBright = random8(90,140);
-          leds[stair] = CHSV( 60, 200, gBright );
-          leds[stair + 1*dir] = CHSV( 60, 200, gBright );
+          leds[gUpDown[stair]] = CHSV( 60, 200, gBright );
+          leds[gUpDown[stair + 1]] = CHSV( 60, 200, gBright );
         }
         FastLED.show();
       }
     }
   }
   // Wait
-  Serial.println("Wait");
   for ( i=0; i<=300; i++) {
     for( gStair = 0; gStair < NUM_LEDS; gStair+=2) {  
       rnd = random8(1, 4);

  rainbow();
  addGlitter(80);
}

void addGlitter( fract8 chanceOfGlitter) 
{
  if( random8() < chanceOfGlitter) {

 * teal to blue
 * red to blue
 */
  fill_solid( gPalette, 16, CRGB::Red);
  gPalette[0] = CRGB( 60, 100, 100 ); // Jenn cool white
  gPalette[1] = CRGB( 0, 90, 90 );    // Jenn teal
  gPalette[2] = CRGB( 60, 10, 100 );  // Jenn violet
  gPalette[3] = CRGB( 60, 0, 50 );    // Jenn purple
  gPalette[4] = CRGB( 0, 0, 81);      // Jenn blue
  gPalette[5] = CRGB( 100, 0, 0);     // Red
  gPalette[6] = CRGB( 0, 0, 100);     // Blue
  gPalette[7] = CRGB( 120, 0, 120);
  // Random fill the rest.
  for (uint8_t i = 8; i<16; i++){
    gPalette[i] = CRGB(random8(3,100), random8(3,100), random8(3,100));
  }
}

// Walk the stairs adding random effects.
void walk() {
  static uint8_t valTop = 200;
  static int i = 0;
  // Pick two colors from the palette. 
  choosePalette();
  CRGB c1 = gPalette[gLastPalette];
  CRGB c2 = gPalette[gLastPalette+1];
  if ( random8( 5 ) == 3 ){
    c1 = CRGB(random8(100),random8(100),random8(100));
    c2 = CRGB(random8(100),random8(100),random8(100));
  }
  CRGB trans = CRGB::Black;
  CRGB trans2 = CRGB::Black;
  //(r2-r1)/ticks * tick)
  
  for(gStair=0; gStair < NUM_LEDS; gStair+=2) {
    // Fade in step
    for (gBright=0; gBright<=valTop; gBright+=2) {
      // Fade in from off
      trans.r = 0 + int16_t((c1.r*gBright)/valTop);
      trans.g = 0 + int16_t((c1.g*gBright)/valTop);
      trans.b = 0 + int16_t((c1.b*gBright)/valTop);
      leds[gUpDown[gStair]] = trans;
      leds[gUpDown[gStair + 1]] = trans;
      if (  gStair >= 2 ) { // shift last to stairs to the 2nd color.
        trans2.r = c1.r + int16_t(((c2.r - c1.r)*gBright)/valTop);
        trans2.g = c1.g + int16_t(((c2.g - c1.g)*gBright)/valTop);
        trans2.b = c1.b + int16_t(((c2.b - c1.b)*gBright)/valTop);
        leds[gUpDown[gStair - 1]] = trans2;
        leds[gUpDown[gStair - 2]] = trans2;
      }
      FastLED.show();
      FastLED.delay(1); 
    }
  }
  
  // Hue shift the last two stairs
  for (gBright=0; gBright<=valTop; gBright+=2) {
    trans2.r = c1.r + int16_t(((c2.r - c1.r)*gBright)/valTop);
    trans2.g = c1.g + int16_t(((c2.g - c1.g)*gBright)/valTop);
    trans2.b = c1.b + int16_t(((c2.b - c1.b)*gBright)/valTop);
    leds[gUpDown[NUM_LEDS - 1]] = trans2;
    leds[gUpDown[NUM_LEDS - 2]] = trans2;
    FastLED.show();
    FastLED.delay(1); 
  }

  // Delay + random effects
  randomEffect(c1, c2);
  
  // Turn off steps
  for(gStair=0; gStair < NUM_LEDS; gStair+=2) {
    for (gBright=0; gBright<=valTop; gBright++) { 
      leds[gUpDown[gStair]].fadeToBlackBy( valTop );
      leds[gUpDown[gStair + 1]].fadeToBlackBy( valTop );
      FastLED.show();
    }
    leds[gUpDown[gStair]] = CRGB( 0, 0, 0);
    leds[gUpDown[gStair + 1]] = CRGB( 0, 0, 0);
    FastLED.show();
  }
  lightsOn = LOW;  
}

// Random effects for the walk() stair function.
void randomEffect(CRGB c1, CRGB c2){
  uint8_t var = random8( 1, 5 );
  int i = 0, x = 0;
  CRGB trans2 = CRGB::Black;
  FastLED.delay(500); // Wait for it...
  switch (var) {
    case 1:
      //sparkle
      {
        for ( i=0; i<=500; i++){
          fill_solid(leds, NUM_LEDS, c2);
          addGlitter(80);
          FastLED.show();
          FastLED.delay(8.5);
        }        
        fill_solid(leds, NUM_LEDS, c2);
        FastLED.show();
      }
      break;
    case 2:
      //pulsate between colors
      {
        CRGBPalette16 z;
        z[0] = c2;
        z[1] = c1;
        z[2] = CRGB(random8(1,100),random8(1,100),random8(1,100));
        z[3] = c1;
        uint8_t ticks = 200;
        for (i=0; i<4; i++){
          for (x = 0; x<ticks; x++){
            trans2.r = z[i].r + int16_t(((z[i+1].r - z[i].r)*x)/ticks);
            trans2.g = z[i].g + int16_t(((z[i+1].g - z[i].g)*x)/ticks);
            trans2.b = z[i].b + int16_t(((z[i+1].b - z[i].b)*x)/ticks);
            fill_solid(leds, NUM_LEDS, trans2);
            FastLED.show();
            FastLED.delay(10);
          }
        }
      }
      break;
    default: 
      //Flash then solid 
      {
        for(gStair=0; gStair < NUM_LEDS; gStair+=2) {
          leds[gUpDown[gStair]] = CRGB( 100, 100, 100);
          leds[gUpDown[gStair + 1]] = CRGB( 100, 100, 100);
          FastLED.show();
        }
        for(gStair=0; gStair < NUM_LEDS; gStair+=2) {
          leds[gUpDown[gStair]] = c2;
          leds[gUpDown[gStair+1]] = c2;
          FastLED.show();
        }
        FastLED.show();
        FastLED.delay(5000);
      }
  } 
}

// startup rainbow
