   delay(10);  
 }
 
+
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
 /**
  * Command handlers for commands  that can be sent to this board via Serial, RF, or some other comm channel
  */
 
+
+/*
+ * Passes a byte from Serial "API" into the command handlers
+ */
+void cmd_handle_from_serial(byte commandByte ) {
+  switch(commandByte) {
+    case 'L': cmd_poof(0x01); break;
+    case 'R': cmd_poof(0x02); break;
+    case 'B': cmd_poof(0x03); break;
+    case 'A': cmd_save_current_seesaw_angle(); break;
+    default:
+      LOGN("Unsupported command from serial.");
+      break;
+  }
+}
+
 /*
  * Calibrates the trigger angles of the seesaw.
  */
+
 void cmd_save_current_seesaw_angle() {
   // NOTE: could call loop() here to update angle, but assuming its been updated recently as it is always called inside loop()
+  LOGN(F("Handling Command: Save SeeSaw Angle"));
   accelerometer->storeCurrentAngleForSide();
 }
 

	Serial.begin(9600);     // Begin serial
  relay_setup();          // call before delay because relays are active low so we want to set to be HIGH as soon as possible

#if MAD_LOGGING
  Serial.println(F("It's a MAD World!"));
#endif
  
  blinkLEDOnBootup();     // Blink the LED to give some time to reset Teensy if needed
  
  loadConfig(); // load important values about angles and other app settings that need to persist

#if MAD_LOGGING
  Serial.println(F("Begin Accelerometer Setup"));
  delay(100);
#endif

  // Initalize the Accelerometer module
  accelerometer = new Accelerometer();
  accelerometer->setup();

#if MAD_LOGGING
  if ( accelerometer->working ) {
    Serial.println(F("Accelerometer setup complete"));    
  } else {
    Serial.println(F("Accelerometer setup failed."));
  }
#endif
}

void loop() {

 * 0x03 : Both Relays
 */
void cmd_poof(byte which) {

  // Just logging
  LOG(F("Handling Command: Poof "));
  if (( which & 0x01) && (which & 0x02)) {
    LOGN(F("Both"));
  } else if ( which & 0x01 ) {
    LOGN(F("LEFT 0x01"));
  } else if ( which & 0x02 ) {
    LOGN(F("RIGHT 0x02"));
  }

  // Handle the command
  if ( which & 0x01 ) {
    r0->setOnWithPattern(SINGLE_BUTTON_PRESS);    
  }
  if ( which & 0x02 ) {
    r1->setOnWithPattern(SINGLE_BUTTON_PRESS);    
  }

  // Call loop so the relays update internally
  r0->loop();
  r1->loop();
}
