   yaw_error = pid_yaw_setpoint - pid_yaw_in;
 }
 
+
 void pid_calculate_AS_Int_and_Der(){
   //la partie integrale
   AS_Integral_roll_error += (AS_roll_error + AS_last_roll_error);

void AS_errors(){
  AS_roll_error = pid_roll_setpoint - roll_angle * AS_K;
  AS_pitch_error = pid_pitch_setpoint - pitch_angle * AS_K;

//fonction qui prend la position du joystick
void pid_setpoint_update(){
  //Ici on regarde si le stick est au milieu et on laisse une marge
  //d'erreur pour que quand on le lache, il donne une erraur nulle.
  if (input[0] > THROTTLE_RMID - 20 && input[0] < THROTTLE_RMID + 20)
    pid_roll_setpoint = 0;
  else
    pid_roll_setpoint = map(input[0], ROLL_RMIN, ROLL_RMAX, ROLL_WMIN, ROLL_WMAX);
  //PITCH rx at mid level? +-20ms
  if (input[1] > THROTTLE_RMID - 20 && input[1] < THROTTLE_RMID + 20)
    pid_pitch_setpoint = 0;
  else
    pid_pitch_setpoint = map(input[1], PITCH_RMIN, PITCH_RMAX, PITCH_WMIN, PITCH_WMAX);
  //YAW rx mid +-20ms
  if (input[3] > THROTTLE_RMID - 20 && input[3] < THROTTLE_RMID + 20)
    pid_yaw_setpoint = 0;
  else
    pid_yaw_setpoint = map(input[3], YAW_RMIN, YAW_RMAX, YAW_WMIN, YAW_WMAX);
}

    pid_errors_update();
    pid_calculate_Int_and_Der();
  }

  if(pid_roll_out > ROLL_PID_MAX) pid_roll_out = ROLL_PID_MAX;
  else if(pid_roll_out < ROLL_PID_MIN) pid_roll_out = ROLL_PID_MIN;
