     while(ctrl.control_code != ctrl.NAV_CODE){
         if (millis() - lastMidTime > midPeriod) {
             lastMidTime = millis();
-            checkRX();
+            rx_check();
         }
     }
     print("Connected\n");

    mx_pavg = mx_avg; my_pavg = my_avg; mz_pavg = mz_avg;
    delay(5);
  }while(!stable);

  accel.setRestingPosition(0.0, 0.0, 1.0);
  //accel.setRestingPosition(233.5522003, 255.8198547, 8202.2744141);
  accel.update(int(ax_avg), int(ay_avg), int(az_avg));
  gyro.init(gx_avg, gy_avg, gz_avg, accel.x, accel.y, accel.z); // gyro offset xyz, accel starting rotation xyz
  #ifdef DEBUG
    Serial.printf("\tresting accel vector %0.3f %0.3f %0.3f \n", ax_avg, ay_avg, az_avg);
    Serial.printf("\tcurrent accel angle %0.3f %0.3f %0.3f \n", accel.x, accel.y, accel.z);
    Serial.printf("\tgyro offset %0.3f %0.3f %0.3f \n", gx_avg, gy_avg, gz_avg);
  #endif
}

void calibrateESC(){
    esc.update(motorPin_FL, throttleMax);
    esc.update(motorPin_FR, throttleMax);
    esc.update(motorPin_BR, throttleMax);

  long ax_sum = 0; long ay_sum = 0; long az_sum = 0; // sum
  float ax_avg = 0; float ay_avg = 0; float az_avg = 0; // average
  float ax_pavg = 0; float ay_pavg = 0; float az_pavg = 0; // previous average
  
  // vector from compass
  long mx_sum = 0; long my_sum = 0; long mz_sum = 0; // sum
  float mx_avg = 0; float my_avg = 0; float mz_avg = 0; // average
  float mx_pavg = 0; float my_pavg = 0; float mz_pavg = 0; // previous average

  bool stable = false;
  float g_epsilon = 0.01;
  float a_epsilon = 0.1;
  float m_epsilon = 0.01;
  float count = 0.0;
