 //  //digitalWrite(LED_PIN_OUT, LOW);
 //}
 
+// @ToDo: Q: What do the expressions "1st pulse", etc. mean? Is this a
+// leftover from trying to combine the RC controls into a single stream?
 /*---------------------------------------------------------------------------------------*/
 byte processRC (unsigned long *results){
+  // Each use of a particular results element is guarded by a check of RC_Done
+  // for that element, to see if we have begun receiving any data for that element.
   // 1st pulse is aileron (position 5 on receiver; controlled by Right left/right joystick on transmitter)
   //     used for Steering
-    //    Serial.print("\tTurn Cmd "); Serial.println(results[RC_TURN]);
   /* 2nd pulse is aux (position 1 on receiver; controlled by flap/gyro toggle on transmitter)
      will be used for selecting remote control or autonomous control. */
-  //    Serial.print("In processRC, received results[RC_AUTO] = "); Serial.println(results[RC_AUTO]);
-  if (NUMBER_CHANNELS > 5)
-    results[RC_AUTO] = (results[RC_AUTO] > MIDDLE ? HIGH : LOW);
-  //    Serial.print("processed results[RC_AUTO] = "); Serial.println(results[RC_AUTO]);
+  if (RC_Done[RC_AUTO]) {
+    if (NUMBER_CHANNELS > 5) {
+      results[RC_AUTO] = (results[RC_AUTO] > MIDDLE ? HIGH : LOW);
+    }
+  }
 
   /* 4th pulse is gear (position 2 on receiver; controlled by gear/mode toggle on transmitter)
     will be used for emergency stop. D38 */
-  Serial.println(results[RC_ESTP]);
-  results[RC_ESTP] = (results[RC_ESTP] > MIDDLE ? HIGH : LOW);
-
-  if (results[RC_ESTP] == HIGH){
-    Serial.println("Exiting processRC due to E-stop.");
-    E_Stop();  // already done at interrupt level
-    if ((results[RC_AUTO] == LOW)  && (NUMBER_CHANNELS > 5)) // under RC control
-      ;//steer(results[RC_TURN]);
-    return 0x00;
-  }
-
-
-  if ((results[RC_AUTO] == HIGH)  && (NUMBER_CHANNELS > 5))
-  {
-            Serial.println("Calling processHighLevel.");
-    return 0x01;  // not under RC control
-  } else {
-         Serial.println("Continuing processRC as under RC control.");
-  }
-  
+  if (RC_Done[RC_ESTP]) {
+    results[RC_ESTP] = (results[RC_ESTP] > MIDDLE ? HIGH : LOW);
+
+    if (results[RC_ESTP] == HIGH){
+      // Serial.println("Exiting processRC due to E-stop.");
+      E_Stop();  // already done at interrupt level
+      if (RC_Done[RC_AUTO]) {
+      // if ((results[RC_AUTO] == LOW)  && (NUMBER_CHANNELS > 5)) // under RC control
+      //   {
+      //     ;//steer(results[RC_TURN]);
+      //   }
+      // }
+      }
+      return 0x00;
+    }
+  }
+
+  if (RC_Done[RC_AUTO]) {
+    if ((results[RC_AUTO] == HIGH)  && (NUMBER_CHANNELS > 5))
+    {
+      return 0x01;  // not under RC control
+    }
+  }
+
   /*  6th pulse is marked throttle (position 6 on receiver; controlled by Left up/down joystick on transmitter).
     It will be used for shifting from Drive to Reverse . D40
   */
-  //results[RC_RVS] = (results[RC_RVS] > MIDDLE? HIGH: LOW);
+  //if (RC_Done[RC_RVS]) {
+  //  //results[RC_RVS] = (results[RC_RVS] > MIDDLE? HIGH: LOW);
+  //}
 
   // TO DO: Select Forward / reverse based on results[RC_RVS]
 
   /*   3rd pulse is elevator (position 4 on receiver; controlled by Right up/down.
      will be used for throttle/brake: RC_Throttle
   */
-  int aileron = results[RC_TURN];
-  //    Serial.print("\tTurn input "); Serial.print(aileron);
-  results[RC_TURN] = convertTurn(aileron);
+  if (RC_Done[RC_TURN]) {
+    results[RC_TURN] = convertTurn(results[RC_TURN]);
+  }
 
   
   // Braking or Throttle
-  Serial.println(results[RC_GO]);
-  if (liveBrake(results[RC_GO])){
-    Serial.print("Braking: "); Serial.println(results[RC_GO]);
-    brake(convertBrake(results[RC_GO]));
-  }
-  else {
-    brake(MIN_BRAKE_OUT);
+  if (RC_Done[RC_GO]) {
+    if (liveBrake(results[RC_GO])){
+      brake(convertBrake(results[RC_GO]));
+    }
+    else {
+      brake(MIN_BRAKE_OUT);
+    }
   }
 
   //Accelerating
-  if (liveThrottle(results[RC_RDR])){
-    int going = convertThrottle(results[RC_RDR]);
-    moveVehicle(going);
-  }
-  else if(doRoutine(results[RC_RDR])){
-    moveVehicle(MIN_ACC_OUT);
-    squareRoutine(5, results[RC_AUTO]);
-  }
-  else {
-    moveVehicle(MIN_ACC_OUT);
-  }
-
-  steer(results[RC_TURN]);
+  if (RC_Done[RC_RDR]) {
+    if (liveThrottle(results[RC_RDR])){
+      int going = convertThrottle(results[RC_RDR]);
+      moveVehicle(going);
+    }
+    // @ToDo: Move test code out. Will eventually want to have a separate
+    // module execute the tests.
+    else {
+      if (RC_Done[RC_AUTO]) {
+        if(doRoutine(results[RC_RDR])){
+          moveVehicle(MIN_ACC_OUT);
+          squareRoutine(5, results[RC_AUTO]);
+        } else {
+          moveVehicle(MIN_ACC_OUT);
+        }
+      }
+    }
+  }
+
+  if (RC_Done[RC_TURN]) {
+    steer(results[RC_TURN]);
+  }
 
   /* 5th pulse is rudder (position 3 on receiver; controlled by Left left/right joystick on transmitter)
     Not used */
-  //    results[RC_RDR] = (results[RC_RDR] > MIDDLE? HIGH: LOW);  // could be analog
-  //    Serial.println(results[RC_RDR]);
-  //    if (results[RC_RDR] >= HubAtZero)
-  //        HubSpeed_kmPh = 0;
-  //    else
-  //        HubSpeed_kmPh = HubSpeed2kmPh / results[RC_RDR];
-
-  //  Serial.println("");  // New line
+  // if (RC_Done[RC_RDR]) {
+  //   results[RC_RDR] = (results[RC_RDR] > MIDDLE? HIGH: LOW);  // could be analog
+  //   if (results[RC_RDR] >= HubAtZero)
+  //     HubSpeed_kmPh = 0;
+  //   else
+  //     HubSpeed_kmPh = HubSpeed2kmPh / results[RC_RDR];
+  // }
+
   return 0x00;
 }
 /*---------------------------------------------------------------------------------------*/

const int SelectCD = 49; // Select IC 3 DAC (channels C and D)
const int SelectAB = 53; // Select IC 2 DAC (channels A and B)

const unsigned long INVALID_DATA = 0;
volatile int rc_index = 0;
volatile unsigned long RC_rise[7];
volatile unsigned long RC_elapsed[7];
volatile boolean synced = false;
volatile unsigned long last_fallingedge_time = 4294967295; // max long
volatile bool RC_Done[7] = {0, 0, 0, 0, 0, 0, 0};
volatile bool flipping;

long speed_errors[ERROR_HISTORY];
long old_turn_degx1000;
unsigned long calibrationTime_ms;
unsigned long stoppedTime_ms;
unsigned long straightTime_ms;
int  throttle_control = MIN_ACC_OUT;
int  brake_control = MIN_BRAKE_OUT;
int  steer_control = STRAIGHT_TURN_OUT;

  Serial.println("(m) Distance");
}

// @ToDo: Remove all code that does not directly pertain to the actual
// operation of the low-level controller. If we want to execute a pattern
// of movement as a test, put this in a separate module, running on a
// separate Arduino, and have that *send in commands* over the serial line
// just as C3 will do.
/*---------------------------------------------------------------------------------------*/
//circleRoutine
void circleRoutine(unsigned long seconds, unsigned long &rcAuto) {
