| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228 |
- #include "params.h"
- #include "control_throttle.h"
- #include "my_math.h"
- #include "soft_flash.h"
- #include "soft_imu.h"
- enum
- {
- PARAM_READ = 0,
- PARAM_WRITE = 1
- };
- /* 参数存储表 */
- /* static int16_t param_list_buff[128]; */
- /*----------------------- duplicating --------------------*/
- struct FEI_CAN_DATA conf_par;
- struct VER_DATA ver_par;
- // 参数分两套data记录,是因为数据上传转换为float后再下传会有精度损失
- struct data_pid pidinf; // 参数配置
- struct data_ver verinf; // 版本信息
- struct data_conf confinf; // 机型参数配置
- struct data_cam caminf; // 拍照参数配置
- struct data_par parinf; // 备用参数
- /*--------------------------------------------------------*/
- /**
- * @brief
- * @param uint16_t num 设置项序号
- * @param int16_t value 设置的值
- * @param uint8_t wr 读取还是写入,0 为读取,1 为写入
- */
- static int16_t _params_read_wirte(ParamsEnumType num, int16_t value, uint8_t wr)
- {
- int16_t retval = 0;
- switch (num)
- {
- // 机型参数
- case ParamNum_APType:
- if (wr)
- {
- retval = value;
- if (thr_lock_status == LOCKED)
- {
- confinf._jixing = value;
- write_conf_information = true;
- }
- }
- else
- {
- retval = confinf._jixing;
- }
- break;
- // 电台失联时间
- case ParamNum_RadioLinkLostTimeS:
- if (wr)
- {
- retval = value;
- confinf._lostlink_time = value;
- write_conf_information = true;
- }
- else
- {
- retval = confinf._lostlink_time;
- }
- break;
- // 低电压动作
- case ParamNum_LowVoltAction1:
- if (wr)
- {
- retval = value;
- confinf._lowvolt_flag = value;
- write_conf_information = true;
- }
- else
- {
- retval = confinf._lowvolt_flag;
- }
- break;
- // 低电压阈值
- case ParamNum_LowVoltValue1:
- if (wr)
- {
- retval = value;
- confinf._lowvolt_value = value;
- write_conf_information = true;
- }
- else
- {
- retval = confinf._lowvolt_value;
- }
- break;
- // 盘旋半径
- case ParamNum_APCircleRadiusM:
- if (wr)
- {
- retval = value;
- confinf._circle_radius = value;
- write_conf_information = true;
- }
- else
- {
- retval = confinf._circle_radius;
- }
- break;
- // 返航高度
- case ParamNum_APRthAltM:
- if (wr)
- {
- retval = value;
- confinf._rth_alt = value;
- write_conf_information = true;
- }
- else
- {
- retval = confinf._rth_alt;
- }
- break;
- // 起飞高度
- case ParamNum_APTakeoffAltM:
- if (wr)
- {
- retval = value;
- confinf._takeoff_alt = value;
- write_conf_information = true;
- }
- else
- {
- retval = confinf._takeoff_alt;
- }
- break;
- // 磁偏角
- case ParamNum_MagDeclinationDeg:
- if (wr)
- {
- retval = value;
- confinf._mag_offset = value;
- write_conf_information = true;
- }
- else
- {
- retval = confinf._mag_offset;
- }
- break;
- // 雷达灵敏度
- case ParamNum_LidarObavoidAction:
- if (wr)
- {
- retval = value;
- confinf._enable_infrared = value;
- write_conf_information = true;
- }
- else
- {
- retval = confinf._enable_infrared;
- }
- break;
- // imu 滤波参数
- case ParamNum_ImuFilterLever:
- if (wr)
- {
- retval = value;
- if (thr_lock_status == LOCKED)
- {
- uint8_t calib_value[3] = {0, 0, 0};
- calib_value[0] = value;
- send_calibration_msg_to_imu(FILTER_PARAM_CALIB, calib_value, 1);
- }
- }
- else
- {
- retval = ins.imu_conf.filter_param;
- }
- break;
- // 安装方向
- case ParamNum_ImuAssembleDirection:
- if (wr)
- {
- retval = value;
- if (thr_lock_status == LOCKED)
- {
- uint8_t calib_value[3] = {value, 0, 0};
- send_calibration_msg_to_imu(ASSEMBLE_CALIB, calib_value, 1);
- }
- }
- else
- {
- retval = ins.imu_conf.assemble_direction_param;
- }
- break;
- // 怠速等级
- case ParamNum_APIdleSpeed:
- if (wr)
- {
- retval = value;
- if (thr_lock_status == LOCKED)
- {
- if (value >= 1050 && value <= 1300)
- {
- confinf._idle_speed_level = (value - 1050) / 50 + 1;
- write_conf_information = true;
- }
- }
- }
- else
- {
- retval = (confinf._idle_speed_level - 1) * 50 + 1050;
- }
- break;
- // 安装 x 补偿
- case ParamNum_Gps1PosCalibX:
- if (wr)
- {
- retval = value;
- if (thr_lock_status == LOCKED)
- {
- int8_t gps_pos_param[6];
- for (uint8_t i = 0; i < 6; ++i)
- {
- gps_pos_param[i] = ins.imu_conf.gps_pos_param[i];
- }
- gps_pos_param[0] = value;
- send_calibration_msg_to_imu(GPS_POS_CALIB, (uint8_t *)gps_pos_param, 6);
- }
- }
- else
- {
- retval = ins.imu_conf.gps_pos_param[0];
- }
- break;
- // 安装 y 补偿
- case ParamNum_Gps1PosCalibY:
- if (wr)
- {
- retval = value;
- if (thr_lock_status == LOCKED)
- {
- int8_t gps_pos_param[6];
- for (uint8_t i = 0; i < 6; ++i)
- {
- gps_pos_param[i] = ins.imu_conf.gps_pos_param[i];
- }
- gps_pos_param[1] = value;
- send_calibration_msg_to_imu(GPS_POS_CALIB, (uint8_t *)gps_pos_param, 6);
- }
- }
- else
- {
- retval = ins.imu_conf.gps_pos_param[1];
- }
- break;
- // 安装 z 补偿
- case ParamNum_Gps1PosCalibZ:
- if (wr)
- {
- retval = value;
- if (thr_lock_status == LOCKED)
- {
- int8_t gps_pos_param[6];
- for (uint8_t i = 0; i < 6; ++i)
- {
- gps_pos_param[i] = ins.imu_conf.gps_pos_param[i];
- }
- gps_pos_param[2] = value;
- send_calibration_msg_to_imu(GPS_POS_CALIB, (uint8_t *)gps_pos_param, 6);
- }
- }
- else
- {
- retval = ins.imu_conf.gps_pos_param[2];
- }
- break;
- // 串口 4 功能复用
- case ParamNum_Port4Multiplexing:
- if (wr)
- {
- retval = value;
- if (thr_lock_status == LOCKED)
- {
- confinf._port4_af_function = value;
- write_conf_information = true;
- }
- }
- else
- {
- retval = confinf._port4_af_function;
- }
- break;
- // 差分双天线安装方向
- case ParamNum_DgpsAssembleDirection:
- if (wr)
- {
- retval = value;
- if (thr_lock_status == LOCKED)
- {
- uint8_t calib_value[3] = {value, 0, 0};
- send_calibration_msg_to_imu(DGPS_DIRECTION_CALIB,
- calib_value,
- 1);
- }
- }
- else
- {
- retval = ins.imu_conf.dgps_direction_param;
- }
- break;
- // 最大倾斜角度
- case ParamNum_APMaxTilteAngleDeg:
- if (wr)
- {
- retval = value;
- parinf._par_maxangle = value;
- write_par_information = true;
- }
- else
- {
- retval = parinf._par_maxangle;
- }
- break;
- // gps 模式推干最大目标水平速度
- case ParamNum_APMaxHorizonalSpeedGpsModeDms:
- if (wr)
- {
- retval = value;
- parinf._par_maxhspeed = value;
- write_par_information = true;
- }
- else
- {
- retval = parinf._par_maxhspeed;
- }
- break;
- // GPS 模式推干最大目标上升速度
- case ParamNum_APMaxClimbSpeedGpsModeDms:
- if (wr)
- {
- retval = value;
- parinf._par_maxupspeed = value;
- write_par_information = true;
- }
- else
- {
- retval = parinf._par_maxupspeed;
- }
- break;
- // GPS 模式推干最大目标下降速度
- case ParamNum_APMaxDeclineSpeedGpsModeDms:
- if (wr)
- {
- retval = value;
- parinf._par_maxdownspeed = value;
- write_par_information = true;
- }
- else
- {
- retval = parinf._par_maxdownspeed;
- }
- break;
- // 悬停油门
- case ParamNum_APHoverThrottle:
- if (wr)
- {
- retval = value;
- parinf._par_hover_throttle = value;
- write_par_information = true;
- }
- else
- {
- retval = parinf._par_hover_throttle;
- }
- break;
- // 一级高度限制
- case ParamNum_AltRestrictionA:
- if (wr)
- {
- retval = value;
- parinf._par_alt_fs_rth = value;
- write_par_information = true;
- }
- else
- {
- retval = parinf._par_alt_fs_rth;
- }
- break;
- // 二级高度限制
- case ParamNum_AltRestrictionB:
- if (wr)
- {
- retval = value;
- parinf._par_alt_fs_land = value;
- write_par_information = true;
- }
- else
- {
- retval = parinf._par_alt_fs_land;
- }
- break;
- // 最大航向锁尾角速度
- case ParamNum_APMaxYawRate:
- if (wr)
- {
- retval = value;
- parinf._par_maxyawrate = value;
- write_par_information = true;
- }
- else
- {
- retval = parinf._par_maxyawrate;
- }
- break;
- // 电压比例校准系数0
- case ParamNum_VoltCalibKp0:
- if (wr)
- {
- retval = value;
- parinf._par_volt_kp[0] = value;
- write_par_information = true;
- }
- else
- {
- retval = parinf._par_volt_kp[0];
- }
- break;
- // 电压比例校准系数1
- case ParamNum_VoltCalibKp1:
- if (wr)
- {
- retval = value;
- parinf._par_volt_kp[1] = value;
- write_par_information = true;
- }
- else
- {
- retval = parinf._par_volt_kp[1];
- }
- break;
- // 电压比例校准系数2
- case ParamNum_VoltCalibKp2:
- if (wr)
- {
- retval = value;
- parinf._par_volt_kp[2] = value;
- write_par_information = true;
- }
- else
- {
- retval = parinf._par_volt_kp[2];
- }
- break;
- // 电压校准偏移系数 0
- case ParamNum_VoltCalibOffset0:
- if (wr)
- {
- retval = value;
- parinf._par_volt_offset[0] = value;
- write_par_information = true;
- }
- else
- {
- retval = parinf._par_volt_offset[0];
- }
- break;
- // 电压校准偏移系数 1
- case ParamNum_VoltCalibOffset1:
- if (wr)
- {
- retval = value;
- parinf._par_volt_offset[1] = value;
- write_par_information = true;
- }
- else
- {
- retval = parinf._par_volt_offset[1];
- }
- break;
- // 电压校准偏移系数 2
- case ParamNum_VoltCalibOffset2:
- if (wr)
- {
- retval = value;
- parinf._par_volt_offset[2] = value;
- write_par_information = true;
- }
- else
- {
- retval = parinf._par_volt_offset[2];
- }
- break;
- // 跟随距离
- case ParamNum_FollowDistM:
- if (wr)
- {
- retval = value;
- parinf._fllow_dist = value;
- write_par_information = true;
- }
- else
- {
- retval = parinf._fllow_dist;
- }
- break;
- // 自动模式最大爬升速度
- case ParamNum_APMaxClimbSpeedAutoModeDms:
- if (wr)
- {
- retval = value;
- parinf._par_max_climb_rate_automode = value;
- write_par_information = true;
- }
- else
- {
- retval = parinf._par_max_climb_rate_automode;
- }
- break;
- // 自动模式最大下降速度
- case ParamNum_APMaxDeclineSpeedAutoModeDms:
- if (wr)
- {
- retval = value;
- parinf._par_max_approach_rate_automode = value;
- write_par_information = true;
- }
- else
- {
- retval = parinf._par_max_approach_rate_automode;
- }
- break;
- // 自动模式最小降落速度
- case ParamNum_APMinLandingRateAutoModeDms:
- if (wr)
- {
- retval = value;
- parinf._par_min_landing_rate_automode = value;
- write_par_information = true;
- }
- else
- {
- retval = parinf._par_min_landing_rate_automode;
- }
- break;
- // 飞机最远水平距离
- case ParamNum_MaxHorizonalDistanceM:
- if (wr)
- {
- retval = value;
- parinf._max_horizonal_distance = value;
- write_par_information = true;
- }
- else
- {
- retval = parinf._max_horizonal_distance;
- }
- break;
- // 拍照信号类型
- case ParamNum_CameraSignalType:
- if (wr)
- {
- retval = value;
- caminf._signal_type = value;
- write_cam_information = true;
- }
- else
- {
- retval = caminf._signal_type;
- }
- break;
- // 拍照信号持续时间
- case ParamNum_CameraSignalInterval:
- if (wr)
- {
- retval = value;
- caminf._signal_interval = value;
- write_cam_information = true;
- }
- else
- {
- retval = caminf._signal_interval;
- }
- break;
- // 拍照信号pwm on
- case ParamNum_CameraSignalPwmOn:
- if (wr)
- {
- retval = value;
- caminf._signal_pwm_takephoto_on = value;
- write_cam_information = true;
- }
- else
- {
- retval = caminf._signal_pwm_takephoto_on;
- }
- break;
- // 拍照信号 pwm off
- case ParamNum_CameraSignalPwmOff:
- if (wr)
- {
- retval = value;
- caminf._signal_pwm_takephoto_off = value;
- write_cam_information = true;
- }
- else
- {
- retval = caminf._signal_pwm_takephoto_off;
- }
- break;
- // 横滚姿态感度
- case ParamNum_RollAngleKp:
- if (wr)
- {
- retval = value;
- pidinf._Roll_Angle_P = value;
- write_pid_information = true;
- }
- else
- {
- retval = pidinf._Roll_Angle_P;
- }
- break;
- // 横滚基础感度
- case ParamNum_RollGyroKp:
- if (wr)
- {
- retval = value;
- pidinf._Roll_Gyro_P = value;
- write_pid_information = true;
- }
- else
- {
- retval = pidinf._Roll_Gyro_P;
- }
- break;
- // 横滚姿态增稳系数
- case ParamNum_RollGyroKd:
- if (wr)
- {
- retval = value;
- pidinf._Roll_Gyro_D = value;
- write_pid_information = true;
- }
- else
- {
- retval = pidinf._Roll_Gyro_D;
- }
- break;
- // 俯仰姿态感度
- case ParamNum_PitchAngleKp:
- if (wr)
- {
- retval = value;
- pidinf._Pitch_Angle_P = value;
- write_pid_information = true;
- }
- else
- {
- retval = pidinf._Pitch_Angle_P;
- }
- break;
- // 俯仰基础感度
- case ParamNum_PitchGyroKp:
- if (wr)
- {
- retval = value;
- pidinf._Pitch_Gyro_P = value;
- write_pid_information = true;
- }
- else
- {
- retval = pidinf._Pitch_Gyro_P;
- }
- break;
- // 俯仰姿态增稳系数
- case ParamNum_PitchGyroKd:
- if (wr)
- {
- retval = value;
- pidinf._Pitch_Gyro_D = value;
- write_pid_information = true;
- }
- else
- {
- retval = pidinf._Pitch_Gyro_D;
- }
- break;
- // 航向姿态感度
- case ParamNum_YawAngleKp:
- if (wr)
- {
- retval = value;
- pidinf._Yaw_Angle_P = value;
- write_pid_information = true;
- }
- else
- {
- retval = pidinf._Yaw_Angle_P;
- }
- break;
- // 航向基础感度
- case ParamNum_YawGyroKp:
- if (wr)
- {
- retval = value;
- pidinf._Yaw_Gyro_P = value;
- write_pid_information = true;
- }
- else
- {
- retval = pidinf._Yaw_Gyro_P;
- }
- break;
- // 航向姿态增稳系数
- case ParamNum_YawGyroKd:
- if (wr)
- {
- retval = value;
- pidinf._Yaw_Gyro_D = value;
- write_pid_information = true;
- }
- else
- {
- retval = pidinf._Yaw_Gyro_D;
- }
- break;
- // 定高位置系数
- case ParamNum_AltholdDistKp:
- if (wr)
- {
- retval = value;
- pidinf._AltHold_Dist_P = value;
- write_pid_information = true;
- }
- else
- {
- retval = pidinf._AltHold_Dist_P;
- }
- break;
- // 定高速度系数
- case ParamNum_AltholdSpeedKp:
- if (wr)
- {
- retval = value;
- pidinf._AltHold_Speed_P = value;
- write_pid_information = true;
- }
- else
- {
- retval = pidinf._AltHold_Speed_P;
- }
- break;
- // 定高加速度系数
- case ParamNum_AltholdAccKp:
- if (wr)
- {
- retval = value;
- pidinf._AltHold_Acc_P = value;
- write_pid_information = true;
- }
- else
- {
- retval = pidinf._AltHold_Acc_P;
- }
- break;
- // 定高积分补偿系数
- case ParamNum_AltholdAccKi:
- if (wr)
- {
- retval = value;
- pidinf._AltHold_Acc_I = value;
- write_pid_information = true;
- }
- else
- {
- retval = pidinf._AltHold_Acc_I;
- }
- break;
- // 水平位置系数
- case ParamNum_LoiterDistKp:
- if (wr)
- {
- retval = value;
- pidinf._Loiter_Dist_P = value;
- write_pid_information = true;
- }
- else
- {
- retval = pidinf._Loiter_Dist_P;
- }
- break;
- // 水平速度系数
- case ParamNum_LoiterSpeedKp:
- if (wr)
- {
- retval = value;
- pidinf._Loiter_Speed_P = value;
- write_pid_information = true;
- }
- else
- {
- retval = pidinf._Loiter_Speed_P;
- }
- break;
- // 水平加速度系数
- case ParamNum_LoiterAccKp:
- if (wr)
- {
- retval = value;
- pidinf._Loiter_Acc_P = value;
- write_pid_information = true;
- }
- else
- {
- retval = pidinf._Loiter_Acc_P;
- }
- break;
- // 水平积分补偿系数
- case ParamNum_LoiterAccKi:
- if (wr)
- {
- retval = value;
- pidinf._Loiter_Acc_I = value;
- write_pid_information = true;
- }
- else
- {
- retval = pidinf._Loiter_Acc_I;
- }
- break;
- // 最大巡航水平速度
- case ParamNum_APRthSpeedDms:
- if (wr)
- {
- retval = value;
- parinf._par_max_rth_horizontal_speed = value;
- write_par_information = true;
- }
- else
- {
- retval = parinf._par_max_rth_horizontal_speed;
- }
- break;
- // 陀螺刹车系数
- case ParamNum_GyroBrakeRatio:
- if (wr)
- {
- retval = value;
- pidinf._Loiter_Brake_Gyro = retval;
- write_pid_information = true;
- }
- else
- {
- retval = pidinf._Loiter_Brake_Gyro;
- }
- break;
- /* 2 级低电压动作 */
- case ParamNum_LowVoltAction2:
- if (wr)
- {
- retval = value;
- confinf._lowvolt_flag2 = value;
- write_conf_information = true;
- }
- else
- {
- retval = confinf._lowvolt_flag2;
- }
- break;
- /* 2 级低电压阈值 */
- case ParamNum_LowVoltValue2:
- if (wr)
- {
- retval = value;
- confinf._lowvolt_value2 = value;
- write_conf_information = true;
- }
- else
- {
- retval = confinf._lowvolt_value2;
- }
- break;
- /* 遥控器失控悬停等待时间 */
- case ParamNum_RcFailLoiterTimeS:
- if (wr)
- {
- retval = value;
- confinf._rc_fail_loiter_time = value;
- write_conf_information = true;
- }
- else
- {
- retval = confinf._rc_fail_loiter_time;
- }
- break;
- /* Gps 2 安装 X 补偿 */
- case ParamNum_Gps2PosCalibX:
- if (wr)
- {
- retval = value;
- if (thr_lock_status == LOCKED)
- {
- int8_t gps_pos_param[6];
- for (uint8_t i = 0; i < 6; ++i)
- {
- gps_pos_param[i] = ins.imu_conf.gps_pos_param[i];
- }
- gps_pos_param[3] = value;
- send_calibration_msg_to_imu(GPS_POS_CALIB, (uint8_t *)gps_pos_param, 6);
- }
- }
- else
- {
- retval = ins.imu_conf.gps_pos_param[3];
- }
- break;
- /* Gps 2 安装 Y 补偿 */
- case ParamNum_Gps2PosCalibY:
- if (wr)
- {
- retval = value;
- if (thr_lock_status == LOCKED)
- {
- int8_t gps_pos_param[6];
- for (uint8_t i = 0; i < 6; ++i)
- {
- gps_pos_param[i] = ins.imu_conf.gps_pos_param[i];
- }
- gps_pos_param[4] = value;
- send_calibration_msg_to_imu(GPS_POS_CALIB, (uint8_t *)gps_pos_param, 6);
- }
- }
- else
- {
- retval = ins.imu_conf.gps_pos_param[4];
- }
- break;
- /* Gps 2 安装 Z 补偿 */
- case ParamNum_Gps2PosCalibZ:
- if (wr)
- {
- retval = value;
- if (thr_lock_status == LOCKED)
- {
- int8_t gps_pos_param[6];
- for (uint8_t i = 0; i < 6; ++i)
- {
- gps_pos_param[i] = ins.imu_conf.gps_pos_param[i];
- }
- gps_pos_param[5] = value;
- send_calibration_msg_to_imu(GPS_POS_CALIB, (uint8_t *)gps_pos_param, 6);
- }
- }
- else
- {
- retval = ins.imu_conf.gps_pos_param[5];
- }
- break;
- /* 跟随前向距离 */
- case ParamNum_VehicleFollowForwardDistDM:
- if (wr)
- {
- retval = value;
- parinf._vehicle_forward_dist_dm = value;
- write_par_information = true;
- }
- else
- {
- retval = parinf._vehicle_forward_dist_dm;
- }
- break;
- /* 跟随右向距离 */
- case ParamNum_VehicleFollowRightDistDM:
- if (wr)
- {
- retval = value;
- parinf._vehicle_right_dist_dm = value;
- write_par_information = true;
- }
- else
- {
- retval = parinf._vehicle_right_dist_dm;
- }
- break;
- /* 跟随机头夹角 */
- case ParamNum_VehicleFollowIncYawAngleDeg:
- if (wr)
- {
- retval = value;
- parinf._vehicle_yaw_included_angle =
- constrain_int16(value, -180, 180);
- write_par_information = true;
- }
- else
- {
- retval = parinf._vehicle_yaw_included_angle;
- }
- break;
- /* 跟随天向距离 */
- case ParamNum_VehicleFollowUpDistDM:
- if (wr)
- {
- retval = value;
- parinf._vehicle_up_dist = value;
- write_par_information = true;
- }
- else
- {
- retval = parinf._vehicle_up_dist;
- }
- break;
- /* 基站磁偏角 */
- case ParamNum_BaseDgpsYawDeclination:
- if (wr)
- {
- if (thr_lock_status == LOCKED)
- {
- retval = value;
- parinf._vehicle_base_dgps_yaw_dec =
- constrain_int16(value, -90 * 10, 90 * 10);
- write_par_information = true;
- }
- }
- else
- {
- retval = parinf._vehicle_base_dgps_yaw_dec;
- }
- break;
- case ParamNum_ImitatingFlightSensibility:
- if (wr)
- {
- retval = value;
- confinf._imitate_sensibility = constrain_int16(value, 0, 100);
- write_conf_information = true;
- }
- else
- {
- retval = constrain_int16(confinf._imitate_sensibility, 0, 100);
- }
- break;
- case ParamNum_ObstacleHoldDistCm:
- if (wr)
- {
- retval = value;
- parinf._obstacle_dist_cm = constrain_int16(value, 200, 800);
- write_par_information = true;
- }
- else
- {
- retval = constrain_int16(parinf._obstacle_dist_cm, 200, 800);
- }
- break;
- case ParamNum_SbusOAfCofig:
- if (wr)
- {
- retval = value;
- parinf._sbuso_af_config = value;
- write_par_information = true;
- }
- else
- {
- retval = parinf._sbuso_af_config;
- }
- break;
- case ParamNum_LinklostAction:
- if (wr)
- {
- retval = value;
- if (value <= 1)
- {
- parinf._linklost_action = value;
- write_par_information = true;
- }
- }
- else
- {
- retval = parinf._linklost_action;
- }
- break;
- case ParamNum_MaxHorJet:
- if (wr)
- {
- retval = value;
- if (value >= 4 && value <= 50)
- {
- parinf._max_hor_jet = value;
- write_par_information = true;
- }
- }
- else
- {
- if (parinf._max_hor_jet < 4 || parinf._max_hor_jet > 50)
- {
- retval = 50;
- }
- else
- {
- retval = parinf._max_hor_jet;
- }
- }
- break;
- case ParamNum_BmsLowCapcityPercentage:
- if (wr)
- {
- retval = value;
- if (value >= 0 && value <= 80)
- {
- parinf._bms_low_capacity_percentage = value;
- write_par_information = true;
- }
- }
- else
- {
- if (parinf._max_hor_jet < 0 || parinf._max_hor_jet > 80)
- {
- retval = 20;
- }
- else
- {
- retval = parinf._bms_low_capacity_percentage;
- }
- }
- break;
- case ParamNUm_TPAFCONF:
- if (wr)
- {
- retval = value;
- if (value <= 1)
- {
- parinf._tp_afconfig = value;
- write_par_information = true;
- }
- }
- else
- {
- if (parinf._tp_afconfig > 1)
- {
- retval = 0;
- }
- else
- {
- retval = parinf._tp_afconfig;
- }
- }
- break;
- case ParamNum_ServoFailsafe:
- if (wr)
- {
- retval = value;
- if (value <= 2)
- {
- parinf._motor_failsafe_action = value;
- write_par_information = true;
- }
- }
- else
- {
- if (parinf._motor_failsafe_action > 2)
- {
- retval = 0;
- }
- else
- {
- retval = parinf._motor_failsafe_action;
- }
- }
- break;
- case ParamNum_BmsLowCapcityPercentage2:
- if (wr)
- {
- retval = value;
- if (value >= 0 && value <= 80)
- {
- parinf._bms_low_capacity_percentage2 = value;
- write_par_information = true;
- }
- }
- else
- {
- if (parinf._max_hor_jet < 0 || parinf._max_hor_jet > 80)
- {
- retval = 20;
- }
- else
- {
- retval = parinf._bms_low_capacity_percentage2;
- }
- }
- break;
- default:
- break;
- }
- return retval;
- }
- void params_set_value(uint16_t param_num, int16_t param_value)
- {
- _params_read_wirte((ParamsEnumType)param_num, param_value, PARAM_WRITE);
- }
- int16_t params_get_value(uint16_t param_num)
- {
- int16_t retval =
- _params_read_wirte((ParamsEnumType)param_num, 0, PARAM_READ);
- return retval;
- }
|