 }
 
 void write_rpms(){
-  if (half_revolutions >= 6) {
+  if (half_revolutions >= 2) {
      rpm = 30 * 1000/(millis() - timeold) * half_revolutions;
+     rpm_decay = rpm;
      timeold = millis();
      half_revolutions = 0;
      commander.sendBinCmd(cmd_rpm, rpm);
   }
 }
-
-// void monitor_for_emergency_stop(){
-//   if ((sonar_distance[0] + sonar_distance[1])/2 <=  min(120, (40 + rpm/10)) && 
-//     rpm >= ROLLING_RPM) {
-//     commander.sendCmd(cmd_info, "OH SHIT");
-//     commander.sendCmd(cmd_info, String("  --RPM: ") + rpm);
-//     commander.sendCmd(cmd_info, String("  --TP: ") + throttle_pos);
-//     commander.sendCmd(cmd_info, String("  --LP: ") + sonar_distance[0]);
-//     commander.sendCmd(cmd_info, String("  --RP: ") + sonar_distance[1]);
-
-//     //emergency break
-//     set_throttle_position(-100);
-//     delay(3000);
-//     set_throttle_position(0);
-//     rpm = 0;
-
-//     //require arming
-//     // enter_arming_mode();
-//   }
-// }

float steer_input = STEER_BASE;
float throttle_input = THROTTLE_BASE;

int throttle_pos;
int steering_angle;


//make sure we have a transmitter so that we can safety stop the car


//when using the transmitter, map the throttle to the TX output
void set_throttle_position_manual(float sp) {
  
//  //dont set unless a delta has been acheived
//  if (abs(throttle_pos - pos)/2.0 < THROTTLE_SENSITIVITY){
//    if (abs(pos) <= 5){
//      pos = 0;
//    }
//    else {
//      //not a big of change to change noise
//      return;
//    }
//
//    //if this value has already been set zero, no reason to set it again
//    if (throttle_pos == 0) {
//      return;
//    }
//  }

  
  float map_throttle = map(sp, THROTTLE_MIN, THROTTLE_MAX, -100, 100);
  set_throttle_position(map_throttle);
}

