 
 void processColor() {
   gradientThread.disable(); // cut off anything else
-  gradientLoop = false;  
-  char colorInput[] = {inputBuffer[1], //premature
-                       inputBuffer[2], //optimization
-                       inputBuffer[3], //but also
-                       inputBuffer[4], //laziness
-                       inputBuffer[5],
-                       inputBuffer[6],
-                       inputBuffer[7],'\0'};
+  gradientLoop = false;
+  char colorInput[8];
+  arrayCopy(colorInput,&inputBuffer[1],7);
   if (debugMode) {
     Serial.print("Serial input:"); 
     Serial.println(colorInput);  }
   decodeHex(colorInput,rgb);
-  setOutput(rgb);
+  outputColor(rgb);
   printColors();
   if (debugMode) {
     Serial.println("Color set.  Results:");

 *  Change SINGLE_LED and the color pins to match your hardware.
 *  You can toggle a handy debug mode with "d".
 */
// TO DO: implement start/stop flashing
// TO DO: implement smooth gradients

#include <stdarg.h>


  }
}

void processFlash() {
// start flashing between A and B every timeval seconds: "F#000000:#123456:timeVal"
  if ((inputBuffer[1]!='#' || inputBuffer[9]!='#')) {
    Serial.println("Error: invalid flash request");
    Serial.println(inputBuffer);
  } else {
    char hex1[8], hex2[8];
    char timev[8];
    for (int x = 0; x<7; x++) {
      hex1[x] = inputBuffer[1+x];
      hex2[x] = inputBuffer[9+x];
      timev[x] = inputBuffer[17+x];
    }
    int col1[4],col2[4];
    int *col1p[4] = {&col1[0],&col1[1],&col1[2],0};
    int *col2p[4] = {&col2[0],&col2[1],&col2[2],0};    
    decodeHex(hex1,col1p);
    decodeHex(hex2,col2p);
    float timeVal = atol(timev); //use strtol or sscanf instead
    flashSetup(col1,col2,timeVal);
  }
}

void flashSetup (const int col1[3],const int col2[3], float timev) {
  flashTime = (float) timev*1000;
  for (int x=0; x<3; x++) {
    flashcol1[x]=col1[x];
    flashcol2[x]=col2[x];
  }
  
  flashThread.setInterval(flashTime);
  flashThread.reset();
  flashThread.enable();
  if (debugMode) {
    Serial.println("Flash setup done, gradient thread enabled.");
  }
}

void flash() {
  outputColor( flashFirstColor ? flashcol1 : flashcol2 );
  flashFirstColor = !flashFirstColor;
}

void timeoutAction() {
  
  if (debugMode) { Serial.println("Processing timeout."); }
  if (!recentActivity) {
    Serial.print("No recent activity for "); Serial.print(TIMEOUT); Serial.println(" seconds.");
    // maybe timeout and timeout behavior should be configurable over serial.
    // low priority, bc this will mostly be running before serial comms have
    // been established.
    gradientPulseSetup(OFF, WHITE, 2);
    gradientLoop = true;
  } 
}

void gradientPulseSetup (const int col1[3],const int col2[3], float timev) { // timev is now in seconds
  flashThread.disable();
  gradDelayPerTick = (float) timev*1000/numdivs;
  gradPercPerTick = (float) 1/numdivs;
  gradPerc = 0;
