/** Download the parameters of the current category from the AeroQuad */
  private void downloadSettings() {
    AQSerial mAQSerial = ((MainApplication) getActivity().getApplication()).getAQSerial();

    String[] values;

    switch (UiEnum.fromValue(CurrentUiR)) {
      case RateMode:
        values = new String[6];
        values = mAQSerial.readRateMode();

        if (values == null) break;

        SetParameter("pid_ratemode_rpv_preference", values[0]);
        SetParameter("pid_ratemode_riv_preference", values[1]);
        SetParameter("pid_ratemode_rdv_preference", values[2]);
        SetParameter("pid_ratemode_ppv_preference", values[3]);
        SetParameter("pid_ratemode_piv_preference", values[4]);
        SetParameter("pid_ratemode_pdv_preference", values[5]);
        break;

        // TODO : The others
      case AltitudeMode:
        values = new String[13];
        values = mAQSerial.readAltitudeMode();

        if (values == null) break;

        SetParameter("pid_altimode_rapv_preference", values[0]);
        SetParameter("pid_altimode_raiv_preference", values[1]);
        SetParameter("pid_altimode_radv_preference", values[2]);
        SetParameter("pid_altimode_papv_preference", values[3]);
        SetParameter("pid_altimode_paiv_preference", values[4]);
        SetParameter("pid_altimode_padv_preference", values[5]);
        SetParameter("pid_altimode_rgpv_preference", values[6]);
        SetParameter("pid_altimode_rgiv_preference", values[7]);
        SetParameter("pid_altimode_rgdv_preference", values[8]);
        SetParameter("pid_altimode_pgpv_preference", values[9]);
        SetParameter("pid_altimode_pgiv_preference", values[10]);
        SetParameter("pid_altimode_pgdv_preference", values[11]);
        SetParameter("pid_altimode_windupguard_preference", values[12]);
        break;

      case YawConfiguration:
        values = new String[7];
        values = mAQSerial.readYawConfig();

        if (values == null) break;

        SetParameter("pid_yawconfig_ypv_preference", values[0]);
        SetParameter("pid_yawconfig_yiv_preference", values[1]);
        SetParameter("pid_yawconfig_ydv_preference", values[2]);
        SetParameter("pid_yawconfig_hhpv_preference", values[3]);
        SetParameter("pid_yawconfig_hhiv_preference", values[4]);
        SetParameter("pid_yawconfig_hhdv_preference", values[5]);
        SetParameter("pid_yawconfig_hhc_preference", values[6]);
        break;

      case AltitudeHold:
        values = new String[12];
        values = mAQSerial.readAltitudeHold();

        if (values == null) break;

        SetParameter("pid_altihold_apv_preference", values[0]);
        SetParameter("pid_altihold_aiv_preference", values[1]);
        SetParameter("pid_altihold_adv_preference", values[2]);
        SetParameter("pid_altihold_awindupguard_preference", values[3]);
        SetParameter("pid_altihold_tminav_preference", values[4]);
        SetParameter("pid_altihold_tbv_preference", values[5]);
        SetParameter("pid_altihold_tpv_preference", values[6]);
        SetParameter("pid_altihold_tmaxav_preference", values[7]);
        SetParameter("pid_altihold_asf_preference", values[8]);
        SetParameter("pid_altihold_zdpv_preference", values[9]);
        SetParameter("pid_altihold_zdiv_preference", values[10]);
        SetParameter("pid_altihold_zddv_preference", values[11]);
        break;

      case MiscConfiguration:
        values = new String[2];
        values = mAQSerial.readMiscConfig();

        if (values == null) break;

        // TODO: Watch changes while gyro smooth was deleted from dev branch on git.
        SetParameter("pid_miscconfig_vrv_preference", values[0]);
        SetParameter("pid_miscconfig_minatv_preference", values[1]);
        break;

      case TransmitterSmoothing:
        values = new String[9];
        values = mAQSerial.readTransSmooth();

        if (values == null) break;

        SetParameter("pid_transsmth_tfv_preference", values[0]);
        SetParameter("pid_transsmth_rsv_preference", values[1]);
        SetParameter("pid_transsmth_psv_preference", values[2]);
        SetParameter("pid_transsmth_ysv_preference", values[3]);
        SetParameter("pid_transsmth_tsv_preference", values[4]);
        SetParameter("pid_transsmth_msv_preference", values[5]);
        SetParameter("pid_transsmth_asv_one_preference", values[6]);
        SetParameter("pid_transsmth_asv_two_preference", values[7]);
        SetParameter("pid_transsmth_asv_three_preference", values[8]);
        break;

      case BatteryMonitor:
        values = new String[3];
        values = mAQSerial.readBattMon();

        if (values == null) break;

        SetParameter("pid_battmon_avv_preference", values[0]);
        SetParameter("pid_battmon_ttv_preference", values[1]);
        SetParameter("pid_battmon_gdtv_preference", values[2]);
        break;

      case CameraStabilization:
        values = new String[13];
        values = mAQSerial.readCameraStab();

        if (values == null) break;

        SetParameter("pid_camstab_mv_preference", values[0]);
        SetParameter("pid_camstab_pcv_preference", values[1]);
        SetParameter("pid_camstab_rcv_preference", values[2]);
        SetParameter("pid_camstab_ycv_preference", values[3]);
        SetParameter("pid_camstab_psav_preference", values[4]);
        SetParameter("pid_camstab_rsav_preference", values[5]);
        SetParameter("pid_camstab_ysav_preference", values[6]);
        SetParameter("pid_camstab_mininpsv_preference", values[7]);
        SetParameter("pid_camstab_mininrsv_preference", values[8]);
        SetParameter("pid_camstab_mininysv_preference", values[9]);
        SetParameter("pid_camstab_maxpsv_preference", values[10]);
        SetParameter("pid_camstab_maxrsv_preference", values[11]);
        SetParameter("pid_camstab_maxysv_preference", values[12]);
        break;

      default:
        break;
    }
  }
  /** Upload the parameters of the current category to the AeroQuad */
  private void uploadSettings() {
    AQSerial mAQSerial = ((MainApplication) getActivity().getApplication()).getAQSerial();

    String[] values;

    switch (UiEnum.fromValue(CurrentUiR)) {
      case RateMode:
        values = new String[6];
        values[0] = GetParameter("pid_ratemode_rpv_preference");
        values[1] = GetParameter("pid_ratemode_riv_preference");
        values[2] = GetParameter("pid_ratemode_rdv_preference");
        values[3] = GetParameter("pid_ratemode_ppv_preference");
        values[4] = GetParameter("pid_ratemode_piv_preference");
        values[5] = GetParameter("pid_ratemode_pdv_preference");
        mAQSerial.writeRateMode(values);

        // TODO: Check if upload was successful

        break;

        // TODO : The others
      case AltitudeMode:
        values = new String[13];
        values[0] = GetParameter("pid_altimode_rapv_preference");
        values[1] = GetParameter("pid_altimode_raiv_preference");
        values[2] = GetParameter("pid_altimode_radv_preference");
        values[3] = GetParameter("pid_altimode_papv_preference");
        values[4] = GetParameter("pid_altimode_paiv_preference");
        values[5] = GetParameter("pid_altimode_padv_preference");
        values[6] = GetParameter("pid_altimode_rgpv_preference");
        values[7] = GetParameter("pid_altimode_rgiv_preference");
        values[8] = GetParameter("pid_altimode_rgdv_preference");
        values[9] = GetParameter("pid_altimode_pgpv_preference");
        values[10] = GetParameter("pid_altimode_pgiv_preference");
        values[11] = GetParameter("pid_altimode_pgdv_preference");
        values[12] = GetParameter("pid_altimode_windupguard_preference");
        mAQSerial.writeAltitudeMode(values);
        break;

      case YawConfiguration:
        values = new String[7];
        values[0] = GetParameter("pid_yawconfig_ypv_preference");
        values[1] = GetParameter("pid_yawconfig_yiv_preference");
        values[2] = GetParameter("pid_yawconfig_ydv_preference");
        values[3] = GetParameter("pid_yawconfig_hhpv_preference");
        values[4] = GetParameter("pid_yawconfig_hhiv_preference");
        values[5] = GetParameter("pid_yawconfig_hhdv_preference");
        values[6] = GetParameter("pid_yawconfig_hhc_preference");
        mAQSerial.writeYawConfig(values);

      case AltitudeHold:
        values = new String[12];
        values[0] = GetParameter("pid_altihold_apv_preference");
        values[1] = GetParameter("pid_altihold_aiv_preference");
        values[2] = GetParameter("pid_altihold_adv_preference");
        values[3] = GetParameter("pid_altihold_awindupguard_preference");
        values[4] = GetParameter("pid_altihold_tminav_preference");
        values[5] = GetParameter("pid_altihold_tbv_preference");
        values[6] = GetParameter("pid_altihold_tpv_preference");
        values[7] = GetParameter("pid_altihold_tmaxav_preference");
        values[8] = GetParameter("pid_altihold_asf_preference");
        values[9] = GetParameter("pid_altihold_zdpv_preference");
        values[10] = GetParameter("pid_altihold_zdiv_preference");
        values[11] = GetParameter("pid_altihold_zddv_preference");
        mAQSerial.writeAltitudeHold(values);
        break;

      case MiscConfiguration:
        values = new String[2];
        values[0] = GetParameter("pid_miscconfig_vrv_preference");
        values[1] = GetParameter("pid_miscconfig_minatv_preference");
        mAQSerial.writeMiscConfig(values);
        break;

      case TransmitterSmoothing:
        values = new String[9];
        values[0] = GetParameter("pid_transsmth_tfv_preference");
        values[1] = GetParameter("pid_transsmth_rsv_preference");
        values[2] = GetParameter("pid_transsmth_psv_preference");
        values[3] = GetParameter("pid_transsmth_ysv_preference");
        values[4] = GetParameter("pid_transsmth_tsv_preference");
        values[5] = GetParameter("pid_transsmth_msv_preference");
        values[6] = GetParameter("pid_transsmth_asv_one_preference");
        values[7] = GetParameter("pid_transsmth_asv_two_preference");
        values[8] = GetParameter("pid_transsmth_asv_three_preference");
        mAQSerial.writeTransSmooth(values);
        break;

      case BatteryMonitor:
        values = new String[3];
        values[0] = GetParameter("pid_battmon_avv_preference");
        values[1] = GetParameter("pid_battmon_ttv_preference");
        values[2] = GetParameter("pid_battmon_gdtv_preference");
        mAQSerial.writeBattMon(values);
        break;

      case CameraStabilization:
        values = new String[13];
        values[0] = GetParameter("pid_camstab_mv_preference");
        values[1] = GetParameter("pid_camstab_pcv_preference");
        values[2] = GetParameter("pid_camstab_rcv_preference");
        values[3] = GetParameter("pid_camstab_ycv_preference");
        values[4] = GetParameter("pid_camstab_psav_preference");
        values[5] = GetParameter("pid_camstab_rsav_preference");
        values[6] = GetParameter("pid_camstab_ysav_preference");
        values[7] = GetParameter("pid_camstab_mininpsv_preference");
        values[8] = GetParameter("pid_camstab_mininrsv_preference");
        values[9] = GetParameter("pid_camstab_mininysv_preference");
        values[10] = GetParameter("pid_camstab_maxpsv_preference");
        values[11] = GetParameter("pid_camstab_maxrsv_preference");
        values[12] = GetParameter("pid_camstab_maxysv_preference");
        mAQSerial.writeCameraStab(values);
        break;

      default:
        break;
    }
  }