// Setup one blinking LED.
// Setup a 16 LED neoPixle ring.
// Setup a second 16 LED neoPixle ring off the dataline of the first. 
// ON the first ring setup a pixle pattern of 3-RED, 4;YELLOW, 5-GREEN.
// On the second ring setup the same pattern.
// The first ring rotates it's pattern (red leading) one pixle clockwise every 1/4 second.
// The second rung rotates it's pattern (Also red leading) one pixle COUNTER-clockwise every 1/3 second.

#include <blinker.h>
#include <chainPixels.h>

class firstRing : public pixelGroup {

  public:
          firstRing(int numPixles);
  virtual ~firstRing(void);

  virtual void draw(void);

          bool    init;
          timeObj stepTimer;
};

class secondRing : public pixelGroup {

  public:
          secondRing(int numPixles);
  virtual ~secondRing(void);

  virtual void draw(void);

          bool    init;
          timeObj stepTimer;
};





firstRing::firstRing(int numPixles)
  : pixelGroup(numPixles) {
  
  init = false;
  stepTimer.setTime(250);
}


firstRing::~firstRing(void) {  }


void firstRing::draw(void) {

  if (!init) {
    setPixels(&black);
    for(int i=0;i<3;i++) setPixelColor(i,&red);
    for(int i=3;i<7;i++) setPixelColor(i,&red);
    for(int i=7;i<12;i++) setPixelColor(i,&green);
    init = true;
  } else {
    if (stepTimer.ding()) {
      roll();
      stepTimer.stepTime();
    }
  }
}




secondRing::secondRing(int numPixles)
  : pixelGroup(numPixles) {
  
  init = false;
  stepTimer.setTime(333);
}


secondRing::~secondRing(void) {  }


void secondRing::draw(void) {

  if (!init) {
    setPixels(&black);
    for(int i=0;i<5;i++) setPixelColor(i,&green);
    for(int i=5;i<9;i++) setPixelColor(i,&red);
    for(int i=9;i<12;i++) setPixelColor(i,&red);
    init = true;
  } else {
    if (stepTimer.ding()) {
      roll(false);
      stepTimer.stepTime();
    }
  }
}        









blinker     aBLinker(3);
chainPixels theRings(2);
firstRing  firstRingObj(16);
secondRing  secondRingObj(16);

void setup() {
  aBLinker.setOnOff(true);
  theRings.addGroup(&secondRingObj);
  theRings.addGroup(&firstRingObj);
  theRings.hookup();
}

void loop() { idle(); }