 // first communication pin for neo pixel string
 const unsigned int BASE_PIN = 2;
 
-const unsigned int NUM_STRINGS = 1;
+const unsigned int NUM_STRINGS = 6;
 //#define NUM_STRINGS 8 // one for each resonator
 
-const uint16_t LEDS_PER_STRAND = 240;
+const uint16_t LEDS_PER_STRAND = 108;
 const bool RGBW_SUPPORT = true;
 const unsigned int QUEUE_SIZE = 3;
 

  Serial.begin(115200);
}

bool collect_serial(void)
{
  while ( Serial.available() > 0 )
  {
    int8_t ch = Serial.read();
    if ( ch == '\n' )
    {
      command[in_index] = 0; // terminate
      if ( in_index > 0 )
      {
        in_index = 0;
        return true;
      }
    }
    else if (ch != '\r') // ignore CR
    {
      command[in_index] = ch;
      if ( in_index < (sizeof(command)/sizeof(command[0])) - 2 ) {
        in_index++;
      }
      //if( in_index >= 32 ) //sizeof(command) )
      //  in_index = 0;
    }
  }
  return false;
}

uint8_t getPercent(const char *buffer)

            case 'e':
            case 'R':
            case 'r':
                int len;
                len = strlen(command);
                if (len != 3) {
                    Serial.print("Invalid length of command \"");Serial.print(command);Serial.print("\": ");Serial.println(len, DEC);
                    break;
                }
                newOwner = (cmd & CASE_MASK) == 'E' ? enlightened : resistance;
                percent = getPercent(&command[1]);
                break;

            case 'N':
            case 'n':
                newOwner = neutral;
                break;

            default:
                Serial.print("Unkwown command "); Serial.println(cmd);
                break;
        }

        // Check for ownership change
        if (newOwner != owner) {
            owner = newOwner;
            Color c;
            switch (owner) {
                case enlightened:
                case resistance:
                    uint8_t red, green, blue, white;
                    c = ToColor(0x00, 
                            owner == enlightened ? 0xff : 0x00,
                            owner == resistance ? 0xff : 0x00,
                            0x00);
                    for (int i = 0; i < NUM_STRINGS; i++) {
                        QueueType& animationQueue = animationQueues[i];
                        animationQueue.setTo(&animations.pulse);
                        unsigned int stateIdx = animationQueue.lastIdx();
                        double initialPhase = ((double) i) / NUM_STRINGS;
                        animations.pulse.init(states[i][stateIdx], strip, c, initialPhase);
                    }
                    break;

                case neutral:
                    percent = 20;
                    if (RGBW_SUPPORT) {
                        c = ToColor(0x00, 0x00, 0x00, 0xff);
                    } else {
                        c = ToColor(0xff, 0xff, 0xff);
                    }
                    for (int i = 0; i < NUM_STRINGS; i++) {
                        QueueType& animationQueue = animationQueues[i];
                        animationQueue.setTo(&animations.redFlash);
                        unsigned int stateIdx = animationQueue.lastIdx();
                        animations.redFlash.init(states[i][stateIdx], strip, RGBW_SUPPORT);
                        animationQueue.add(&animations.solid);
                        stateIdx = animationQueue.lastIdx();
                        animations.solid.init(states[i][stateIdx], strip, c);
                    }
                    break;

                default:
                    Serial.print("Invalid owner "); Serial.println(owner);
                    break;
            }
        }
        Serial.print((char *)command); Serial.print(" - ");Serial.print(command[0],DEC);Serial.print(": "); 
        Serial.print("owner "); Serial.print(owner,DEC); Serial.print(", percent "); Serial.println(percent,DEC); 
    }

    // If we're in the process of getting a serial command, don't service the LEDs: this process disables interrupts,
    // which can cause us to miss characters
    if (status == IDLE) {
        strip.setPin(dir + BASE_PIN);  // pick the string

        QueueType& animationQueue = animationQueues[dir];
        unsigned int queueSize = animationQueue.size();
        if (queueSize > 1) {
            if (animationQueue.peek()->done(states[dir][animationQueue.currIdx()])) {
                animationQueue.remove();
                queueSize--;
                animationQueue.peek()->start(states[dir][animationQueue.currIdx()]);
            }
        }
        if (queueSize > 0) {
            //strip.setBrightness(255);
            strip.setBrightness((uint8_t)((uint16_t)(255*(percent/100.0))));
            //pCurrAnimation->doFrame(states[0], strip);
            animationQueue.peek()->doFrame(states[dir][animationQueue.currIdx()], strip);
        }

        // Update one strand each time through the loop
        dir = (dir + 1) % NUM_STRINGS;
    }
}


