feat:增加圆环参数
This commit is contained in:
@@ -6,7 +6,7 @@ uint8_t bt_buffer; // 接收字符存入
|
|||||||
uint8_t bt_run_flag = 0;
|
uint8_t bt_run_flag = 0;
|
||||||
uint8_t bt_fly_flag = 0;
|
uint8_t bt_fly_flag = 0;
|
||||||
uint32_t bt_run = 0;
|
uint32_t bt_run = 0;
|
||||||
uint32_t bt_fly = 250;
|
float bt_fly = 250.f;
|
||||||
enum bt_order {
|
enum bt_order {
|
||||||
Fly_ctrl = 0x01, // 起飞转换
|
Fly_ctrl = 0x01, // 起飞转换
|
||||||
Fly_up = 0x02, // 起飞程度增加
|
Fly_up = 0x02, // 起飞程度增加
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ extern uint8_t bt_buffer; // 接收字符存入
|
|||||||
extern uint8_t bt_run_flag;
|
extern uint8_t bt_run_flag;
|
||||||
extern uint8_t bt_fly_flag;
|
extern uint8_t bt_fly_flag;
|
||||||
extern uint32_t bt_run;
|
extern uint32_t bt_run;
|
||||||
extern uint32_t bt_fly;
|
extern float bt_fly;
|
||||||
|
|
||||||
void jj_bt_init();
|
void jj_bt_init();
|
||||||
void jj_bt_run();
|
void jj_bt_run();
|
||||||
|
|||||||
137
app/jj_motion.c
137
app/jj_motion.c
@@ -10,58 +10,62 @@
|
|||||||
PID_TypeDef far_angle_pid;
|
PID_TypeDef far_angle_pid;
|
||||||
PID_TypeDef angle_pid;
|
PID_TypeDef angle_pid;
|
||||||
PID_TypeDef far_gyro_pid;
|
PID_TypeDef far_gyro_pid;
|
||||||
PID_TypeDef near_pos_pid;
|
|
||||||
PID_TypeDef speed_pid;
|
PID_TypeDef speed_pid;
|
||||||
|
// 弯道后面风扇角度环
|
||||||
float an_Kp0 = 45.0f;
|
float an_Kp0 = 51.0f;
|
||||||
float an_Ki0 = 0.0f;
|
float an_Ki0 = 0.0f;
|
||||||
float an_Kd0 = 0.0f;
|
float an_Kd0 = 0.0f;
|
||||||
|
// 直道后面风扇角度环
|
||||||
float an_Kp1 = 45.0f;
|
float an_Kp1 = 42.0f;
|
||||||
float an_Ki1 = 0.0f;
|
float an_Ki1 = 0.0f;
|
||||||
float an_Kd1 = 0.0f;
|
float an_Kd1 = 0.0f;
|
||||||
|
// 圆环后面风扇角度环
|
||||||
|
float yu_Kp0 = 40.0f;
|
||||||
|
float yu_Ki0 = 0.0f;
|
||||||
|
float yu_Kd0 = 0.0f;
|
||||||
|
// 弯道侧面风扇角度环
|
||||||
|
float cn_Kp1 = 420.0f;
|
||||||
|
float cn_Ki1 = 0.f;
|
||||||
|
float cn_Kd1 = 0.0f;
|
||||||
|
// 直道侧面风扇角度环
|
||||||
|
float po_Kp1 = 600.0f;
|
||||||
|
float po_Ki1 = 0.0f;
|
||||||
|
float po_Kd1 = 0.0f;
|
||||||
|
// 期望和当前量
|
||||||
float in_angle;
|
float in_angle;
|
||||||
float set_angle = 0.0f;
|
float set_angle = 0.0f;
|
||||||
float out_angle;
|
float out_angle;
|
||||||
float cn_Kp1 = 45.0f;
|
|
||||||
float cn_Ki1 = 0.f;
|
|
||||||
float cn_Kd1 = 0.0f;
|
|
||||||
|
|
||||||
float out_cangle;
|
|
||||||
|
|
||||||
float gy_Kp0 = 4.0f;
|
|
||||||
float gy_Ki0 = 0.0f;
|
|
||||||
float gy_Kd0 = 0.0f;
|
|
||||||
|
|
||||||
float gy_Kp1 = 4.0f;
|
|
||||||
float gy_Ki1 = 0.0f;
|
|
||||||
float gy_Kd1 = 0.0f;
|
|
||||||
float in_gyro;
|
|
||||||
float out_gyro;
|
|
||||||
// float set_gyro = 0.0f;
|
|
||||||
|
|
||||||
float po_Kp0 = 0.0f;
|
|
||||||
float po_Ki0 = 0.0f;
|
|
||||||
float po_Kd0 = 0.0f;
|
|
||||||
|
|
||||||
float po_Kp1 = 200.0f;
|
|
||||||
float po_Ki1 = 2.0f;
|
|
||||||
float po_Kd1 = 0.0f;
|
|
||||||
float in_pos;
|
float in_pos;
|
||||||
float out_pos;
|
float out_pos;
|
||||||
float set_pos = 0.0f;
|
float set_pos = 0.0f;
|
||||||
|
// 弯道角速度环
|
||||||
|
float gy_Kp0 = 2.50f;
|
||||||
|
float gy_Ki0 = 0.0f;
|
||||||
|
float gy_Kd0 = 0.0f;
|
||||||
|
// 直道角速度环
|
||||||
|
float gy_Kp1 = 4.2f;
|
||||||
|
float gy_Ki1 = 0.0f;
|
||||||
|
float gy_Kd1 = 0.0f;
|
||||||
|
// 圆环角速度环
|
||||||
|
float ygy_Kp0 = 0.0f;
|
||||||
|
float ygy_Ki0 = 0.0f;
|
||||||
|
float ygy_Kd0 = 0.0f;
|
||||||
|
// 当前和输入量
|
||||||
|
float in_gyro;
|
||||||
|
float out_gyro;
|
||||||
|
// float set_gyro = 0.0f;
|
||||||
|
// 速度环
|
||||||
float sp_Kp = 16.0f;
|
float sp_Kp = 16.0f;
|
||||||
float sp_Ki = 10.f;
|
float sp_Ki = 42.f;
|
||||||
float sp_Kd = 0.0f;
|
float sp_Kd = 0.0f;
|
||||||
|
|
||||||
float in_speed;
|
float in_speed;
|
||||||
float out_speed;
|
float out_speed;
|
||||||
|
|
||||||
float temp_data = 0;
|
float set_speed;
|
||||||
float set_speed = 100.0f;
|
float set_speed0 = 520.0f;
|
||||||
float set_speed0 = 200.0f;
|
float set_speed1 = 900.0f;
|
||||||
float set_speed1 = 300.0f;
|
float set_speed2 = 550.f;
|
||||||
float set_speed2 = 500.f;
|
|
||||||
int cnt1 = 0;
|
int cnt1 = 0;
|
||||||
int cnt2 = 0;
|
int cnt2 = 0;
|
||||||
int cnt3 = 0;
|
int cnt3 = 0;
|
||||||
@@ -70,7 +74,7 @@ uint8_t cnt3_flag = 0;
|
|||||||
uint8_t in_state = 0;
|
uint8_t in_state = 0;
|
||||||
uint8_t in_stop = 0;
|
uint8_t in_stop = 0;
|
||||||
uint8_t last_state = 0;
|
uint8_t last_state = 0;
|
||||||
|
uint8_t stop_flag = 0;
|
||||||
uint32_t pwm_duty_ls;
|
uint32_t pwm_duty_ls;
|
||||||
uint32_t pwm_duty_rs;
|
uint32_t pwm_duty_rs;
|
||||||
uint32_t pwm_duty_lb;
|
uint32_t pwm_duty_lb;
|
||||||
@@ -97,20 +101,29 @@ float sport_get_speed(void)
|
|||||||
#undef ALPHA
|
#undef ALPHA
|
||||||
}
|
}
|
||||||
|
|
||||||
void sport_motion(void)
|
void sport_motion()
|
||||||
{
|
{
|
||||||
|
|
||||||
imu660ra_get_gyro();
|
imu660ra_get_gyro();
|
||||||
|
imu660ra_get_acc();
|
||||||
in_gyro = imu660ra_gyro_z;
|
in_gyro = imu660ra_gyro_z;
|
||||||
// 停车
|
// 停车
|
||||||
if (1 == in_stop) {
|
if (imu660ra_acc_z <= 1000) {
|
||||||
bt_fly_flag = bt_run_flag = 0;
|
bt_fly_flag = bt_run_flag = 0;
|
||||||
}
|
}
|
||||||
|
if (1 == in_stop) {
|
||||||
|
stop_flag = 1;
|
||||||
|
}
|
||||||
|
if (stop_flag == 1) {
|
||||||
|
cnt4++;
|
||||||
|
if (cnt4 >= 200) {
|
||||||
|
bt_fly_flag = bt_run_flag = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
/* 动力风扇设置 */
|
/* 动力风扇设置 */
|
||||||
if (1 == bt_run_flag) {
|
if (1 == bt_run_flag) {
|
||||||
cnt1++;
|
cnt1++;
|
||||||
cnt2++;
|
cnt2++;
|
||||||
cnt4++;
|
|
||||||
// pid参数切换
|
// pid参数切换
|
||||||
if ((last_state != in_state) && (in_state == 0 || in_state == 2)) { // 直道
|
if ((last_state != in_state) && (in_state == 0 || in_state == 2)) { // 直道
|
||||||
cnt3_flag = 0;
|
cnt3_flag = 0;
|
||||||
@@ -119,6 +132,8 @@ void sport_motion(void)
|
|||||||
set_speed = set_speed1;
|
set_speed = set_speed1;
|
||||||
PID_SetTunings(&far_angle_pid, an_Kp1, an_Ki1, an_Kd1);
|
PID_SetTunings(&far_angle_pid, an_Kp1, an_Ki1, an_Kd1);
|
||||||
PID_SetTunings(&far_gyro_pid, gy_Kp1, gy_Ki1, gy_Kd1);
|
PID_SetTunings(&far_gyro_pid, gy_Kp1, gy_Ki1, gy_Kd1);
|
||||||
|
|
||||||
|
PID_SetTunings(&angle_pid, po_Kp1, po_Ki1, po_Kd1);
|
||||||
}
|
}
|
||||||
if ((last_state != in_state) && in_state == 1) { // 弯道
|
if ((last_state != in_state) && in_state == 1) { // 弯道
|
||||||
bt_printf("to 入弯");
|
bt_printf("to 入弯");
|
||||||
@@ -126,13 +141,17 @@ void sport_motion(void)
|
|||||||
cnt3_flag = 1;
|
cnt3_flag = 1;
|
||||||
PID_SetTunings(&far_angle_pid, an_Kp0, an_Ki0, an_Kd0);
|
PID_SetTunings(&far_angle_pid, an_Kp0, an_Ki0, an_Kd0);
|
||||||
PID_SetTunings(&far_gyro_pid, gy_Kp0, gy_Ki0, gy_Kd0);
|
PID_SetTunings(&far_gyro_pid, gy_Kp0, gy_Ki0, gy_Kd0);
|
||||||
|
|
||||||
|
PID_SetTunings(&angle_pid, cn_Kp1, cn_Ki1, cn_Kd1);
|
||||||
}
|
}
|
||||||
if ((last_state != in_state) && in_state == 3) { // 弯道
|
if ((last_state != in_state) && in_state == 3) { // 圆环
|
||||||
bt_printf("to 圆环");
|
bt_printf("to 圆环");
|
||||||
set_speed = set_speed2;
|
set_speed = set_speed2;
|
||||||
cnt3_flag = 1;
|
cnt3_flag = 1;
|
||||||
PID_SetTunings(&far_angle_pid, an_Kp0, an_Ki0, an_Kd0);
|
PID_SetTunings(&far_angle_pid, an_Kp0, an_Ki0, an_Kd0);
|
||||||
PID_SetTunings(&far_gyro_pid, gy_Kp0, gy_Ki0, gy_Kd0);
|
PID_SetTunings(&far_angle_pid, an_Kp0, an_Ki0, an_Kd0);
|
||||||
|
|
||||||
|
PID_SetTunings(&angle_pid, cn_Kp1, cn_Ki1, cn_Kd1);
|
||||||
}
|
}
|
||||||
last_state = in_state;
|
last_state = in_state;
|
||||||
if (cnt3_flag == 1 && (in_state == 1 || in_state == 3)) {
|
if (cnt3_flag == 1 && (in_state == 1 || in_state == 3)) {
|
||||||
@@ -150,16 +169,12 @@ void sport_motion(void)
|
|||||||
cnt1 = 0;
|
cnt1 = 0;
|
||||||
}
|
}
|
||||||
if (cnt2 >= 10) {
|
if (cnt2 >= 10) {
|
||||||
cnt2 = 0;
|
|
||||||
PID_Compute(&near_pos_pid);
|
|
||||||
}
|
|
||||||
if (cnt4 >= 10) {
|
|
||||||
in_speed = sport_get_speed();
|
in_speed = sport_get_speed();
|
||||||
PID_Compute(&speed_pid);
|
PID_Compute(&speed_pid);
|
||||||
|
|
||||||
PID_Compute(&far_angle_pid);
|
PID_Compute(&far_angle_pid);
|
||||||
PID_Compute(&angle_pid);
|
PID_Compute(&angle_pid);
|
||||||
cnt4 = 0;
|
cnt2 = 0;
|
||||||
}
|
}
|
||||||
if (in_state == 0 || in_state == 2) {
|
if (in_state == 0 || in_state == 2) {
|
||||||
pwm_duty_ls = (int32_t)myclip_f(-out_pos, 0.0f, 6000.f);
|
pwm_duty_ls = (int32_t)myclip_f(-out_pos, 0.0f, 6000.f);
|
||||||
@@ -168,25 +183,11 @@ void sport_motion(void)
|
|||||||
pwm_duty_rb = (int32_t)myclip_f(out_speed - out_gyro, 0.0f, 6000.f);
|
pwm_duty_rb = (int32_t)myclip_f(out_speed - out_gyro, 0.0f, 6000.f);
|
||||||
} else if (in_state == 1 || in_state == 3) {
|
} else if (in_state == 1 || in_state == 3) {
|
||||||
|
|
||||||
pwm_duty_ls = (int32_t)myclip_f(-out_cangle, -6000.0f, 6000.f);
|
pwm_duty_ls = (int32_t)myclip_f(-out_pos, -6000.0f, 6000.f);
|
||||||
pwm_duty_rs = (int32_t)myclip_f(out_cangle, -6000.0f, 6000.f);
|
pwm_duty_rs = (int32_t)myclip_f(out_pos, -6000.0f, 6000.f);
|
||||||
pwm_duty_lb = (int32_t)myclip_f(out_speed + out_gyro, -6000.0f, 6000.f);
|
pwm_duty_lb = (int32_t)myclip_f(out_speed + out_gyro, -6000.0f, 6000.f);
|
||||||
pwm_duty_rb = (int32_t)myclip_f(out_speed - out_gyro, -6000.0f, 6000.f);
|
pwm_duty_rb = (int32_t)myclip_f(out_speed - out_gyro, -6000.0f, 6000.f);
|
||||||
|
|
||||||
}
|
}
|
||||||
// else if (in_state == 3) {
|
|
||||||
// if (out_gyro > 0) {
|
|
||||||
// pwm_duty_ls = (int32_t)myclip_f(-out_cangle, -6000.0f, 6000.f);
|
|
||||||
// pwm_duty_rs = (int32_t)myclip_f(out_cangle, -6000.0f, 6000.f);
|
|
||||||
// pwm_duty_lb = (int32_t)myclip_f(out_speed + out_gyro, 0.0f, 6000.f);
|
|
||||||
// pwm_duty_rb = (int32_t)myclip_f(out_speed, 0.0f, 6000.f);
|
|
||||||
// } else {
|
|
||||||
// pwm_duty_ls = (int32_t)myclip_f(-out_cangle, -6000.0f, 6000.f);
|
|
||||||
// pwm_duty_rs = (int32_t)myclip_f(out_cangle, -6000.0f, 6000.f);
|
|
||||||
// pwm_duty_lb = (int32_t)myclip_f(out_speed, 0.0f, 6000.f);
|
|
||||||
// pwm_duty_rb = (int32_t)myclip_f(out_speed - out_gyro, 0.0f, 6000.f);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
by_pwm_power_duty((int32_t)pwm_duty_ls, (int32_t)pwm_duty_rs, (int32_t)pwm_duty_lb, (int32_t)pwm_duty_rb);
|
by_pwm_power_duty((int32_t)pwm_duty_ls, (int32_t)pwm_duty_rs, (int32_t)pwm_duty_lb, (int32_t)pwm_duty_rb);
|
||||||
} else {
|
} else {
|
||||||
@@ -218,7 +219,7 @@ void sport_pid_init()
|
|||||||
PID_SetSampleTime(&far_angle_pid, 10);
|
PID_SetSampleTime(&far_angle_pid, 10);
|
||||||
PID_SetOutputLimits(&far_angle_pid, -3000.0f, 3000.0f);
|
PID_SetOutputLimits(&far_angle_pid, -3000.0f, 3000.0f);
|
||||||
|
|
||||||
PID(&angle_pid, &in_angle, &out_cangle, &set_angle, cn_Kp1, cn_Ki1, cn_Kd1, _PID_P_ON_E, _PID_CD_REVERSE);
|
PID(&angle_pid, &in_angle, &out_pos, &set_pos, po_Kp1, po_Ki1, po_Kd1, _PID_P_ON_E, _PID_CD_REVERSE);
|
||||||
PID_SetMode(&angle_pid, _PID_MODE_AUTOMATIC);
|
PID_SetMode(&angle_pid, _PID_MODE_AUTOMATIC);
|
||||||
PID_SetSampleTime(&angle_pid, 10);
|
PID_SetSampleTime(&angle_pid, 10);
|
||||||
PID_SetOutputLimits(&angle_pid, -6000.0f, 6000.0f);
|
PID_SetOutputLimits(&angle_pid, -6000.0f, 6000.0f);
|
||||||
@@ -229,17 +230,9 @@ void sport_pid_init()
|
|||||||
PID_SetSampleTime(&far_gyro_pid, 10);
|
PID_SetSampleTime(&far_gyro_pid, 10);
|
||||||
PID_SetOutputLimits(&far_gyro_pid, -5000.0f, 5000.0f);
|
PID_SetOutputLimits(&far_gyro_pid, -5000.0f, 5000.0f);
|
||||||
|
|
||||||
/* 近点控制 */
|
|
||||||
PID(&near_pos_pid, &in_angle, &out_pos, &set_pos, po_Kp1, po_Ki1, po_Kd1, _PID_P_ON_E, _PID_CD_REVERSE);
|
|
||||||
PID_SetMode(&near_pos_pid, _PID_MODE_AUTOMATIC);
|
|
||||||
PID_SetSampleTime(&near_pos_pid, 10);
|
|
||||||
PID_SetOutputLimits(&near_pos_pid, -5000.0f, 5000.0f);
|
|
||||||
// PID_Init(&near_pos_pid);
|
|
||||||
|
|
||||||
/* 速度控制 */
|
/* 速度控制 */
|
||||||
PID(&speed_pid, &in_speed, &out_speed, &set_speed, sp_Kp, sp_Ki, sp_Kd, _PID_P_ON_M, _PID_CD_DIRECT);
|
PID(&speed_pid, &in_speed, &out_speed, &set_speed, sp_Kp, sp_Ki, sp_Kd, _PID_P_ON_M, _PID_CD_DIRECT);
|
||||||
PID_SetMode(&speed_pid, _PID_MODE_AUTOMATIC);
|
PID_SetMode(&speed_pid, _PID_MODE_AUTOMATIC);
|
||||||
PID_SetSampleTime(&speed_pid, 10);
|
PID_SetSampleTime(&speed_pid, 10);
|
||||||
PID_SetOutputLimits(&speed_pid, -4000.0f, 5000.0f);
|
PID_SetOutputLimits(&speed_pid, -4000.0f, 5000.0f);
|
||||||
// PID_Init(&speed_pid);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,17 +24,18 @@ extern float gy_Kd0;
|
|||||||
extern float in_gyro;
|
extern float in_gyro;
|
||||||
extern float out_gyro;
|
extern float out_gyro;
|
||||||
extern float set_gyro;
|
extern float set_gyro;
|
||||||
extern float out_cangle;
|
|
||||||
extern float po_Kp1;
|
extern float po_Kp1;
|
||||||
extern float po_Ki1;
|
extern float po_Ki1;
|
||||||
extern float po_Kd1;
|
extern float po_Kd1;
|
||||||
extern float po_Kp0;
|
extern float yu_Kp0;
|
||||||
extern float po_Ki0;
|
extern float yu_Ki0;
|
||||||
extern float po_Kd0;
|
extern float yu_Kd0;
|
||||||
extern float in_pos;
|
extern float in_pos;
|
||||||
extern float out_pos;
|
extern float out_pos;
|
||||||
extern float set_pos;
|
extern float set_pos;
|
||||||
|
extern float ygy_Kp0;
|
||||||
|
extern float ygy_Ki0;
|
||||||
|
extern float ygy_Kd0;
|
||||||
extern float sp_Kp;
|
extern float sp_Kp;
|
||||||
extern float sp_Ki;
|
extern float sp_Ki;
|
||||||
extern float sp_Kd;
|
extern float sp_Kd;
|
||||||
@@ -42,6 +43,7 @@ extern float in_speed;
|
|||||||
extern float out_speed;
|
extern float out_speed;
|
||||||
extern float set_speed0;
|
extern float set_speed0;
|
||||||
extern float set_speed1;
|
extern float set_speed1;
|
||||||
|
extern float set_speed2;
|
||||||
extern float set_speed ;
|
extern float set_speed ;
|
||||||
extern uint32_t pwm_duty_ls;
|
extern uint32_t pwm_duty_ls;
|
||||||
extern uint32_t pwm_duty_rs;
|
extern uint32_t pwm_duty_rs;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include "./page/page.h"
|
#include "./page/page.h"
|
||||||
#include "zf_common_headfile.h"
|
#include "zf_common_headfile.h"
|
||||||
#include "jj_motion.h"
|
#include "jj_motion.h"
|
||||||
|
#include "jj_blueteeth.h"
|
||||||
|
|
||||||
PARAM_INFO Param_Data[DATA_NUM];
|
PARAM_INFO Param_Data[DATA_NUM];
|
||||||
soft_iic_info_struct eeprom_param;
|
soft_iic_info_struct eeprom_param;
|
||||||
@@ -25,13 +26,11 @@ void jj_param_eeprom_init(void)
|
|||||||
PARAM_REG(gyro_Ki0, &gy_Ki0, EFLOAT, 1, "gy_I0:"); // 注冊
|
PARAM_REG(gyro_Ki0, &gy_Ki0, EFLOAT, 1, "gy_I0:"); // 注冊
|
||||||
PARAM_REG(gyro_Kd0, &gy_Kd0, EFLOAT, 1, "gy_D0:");
|
PARAM_REG(gyro_Kd0, &gy_Kd0, EFLOAT, 1, "gy_D0:");
|
||||||
|
|
||||||
PARAM_REG(speed_Kp, &sp_Kp, EFLOAT, 1, "sp_P:"); // 注冊
|
PARAM_REG(can_Kp1, &cn_Kp1, EFLOAT, 1, "cn_P1:"); // 注冊
|
||||||
PARAM_REG(speed_Ki, &sp_Ki, EFLOAT, 1, "sp_I:"); // 注冊
|
PARAM_REG(can_Ki1, &cn_Ki1, EFLOAT, 1, "cn_I1:"); // 注冊
|
||||||
PARAM_REG(speed_Kd, &sp_Kd, EFLOAT, 1, "sp_D:");
|
PARAM_REG(can_Kd1, &cn_Kd1, EFLOAT, 1, "cn_D1:");
|
||||||
|
|
||||||
PARAM_REG(pos_Kp0, &po_Kp0, EFLOAT, 1, "po_P0:"); // 注冊
|
PARAM_REG(fly_pwm, &bt_fly, EFLOAT, 1, "fly:");
|
||||||
PARAM_REG(pos_Ki0, &po_Ki0, EFLOAT, 1, "po_I0:"); // 注冊
|
|
||||||
PARAM_REG(pos_Kd0, &po_Kd0, EFLOAT, 1, "po_D0:");
|
|
||||||
|
|
||||||
PARAM_REG(param_set_speed0, &set_speed0, EFLOAT, 1, "rate0:");
|
PARAM_REG(param_set_speed0, &set_speed0, EFLOAT, 1, "rate0:");
|
||||||
|
|
||||||
@@ -47,12 +46,23 @@ void jj_param_eeprom_init(void)
|
|||||||
PARAM_REG(pos_Ki1, &po_Ki1, EFLOAT, 1, "po_I1:"); // 注冊
|
PARAM_REG(pos_Ki1, &po_Ki1, EFLOAT, 1, "po_I1:"); // 注冊
|
||||||
PARAM_REG(pos_Kd1, &po_Kd1, EFLOAT, 1, "po_D1:");
|
PARAM_REG(pos_Kd1, &po_Kd1, EFLOAT, 1, "po_D1:");
|
||||||
|
|
||||||
PARAM_REG(can_Kp1, &cn_Kp1, EFLOAT, 1, "cn_P1:"); // 注冊
|
|
||||||
PARAM_REG(can_Ki1, &cn_Ki1, EFLOAT, 1, "cn_I1:"); // 注冊
|
|
||||||
PARAM_REG(can_Kd1, &cn_Kd1, EFLOAT, 1, "cn_D1:");
|
|
||||||
PARAM_REG(param_set_speed1, &set_speed1, EFLOAT, 1, "rate1:");
|
PARAM_REG(param_set_speed1, &set_speed1, EFLOAT, 1, "rate1:");
|
||||||
|
|
||||||
|
PARAM_REG(yuan_Kp0, &yu_Kp0, EFLOAT, 1, "an_P0:"); // 注冊
|
||||||
|
PARAM_REG(yuan_Ki0, &yu_Ki0, EFLOAT, 1, "an_I0:"); // 注冊
|
||||||
|
PARAM_REG(yuan_Kd0, &yu_Kd0, EFLOAT, 1, "an_D0:");
|
||||||
|
|
||||||
|
PARAM_REG(yugyro_Kp0, &ygy_Kp0, EFLOAT, 1, "gy_P0:"); // 注冊
|
||||||
|
PARAM_REG(yugyro_Ki0, &ygy_Ki0, EFLOAT, 1, "gy_I0:"); // 注冊
|
||||||
|
PARAM_REG(yugyro_Kd0, &ygy_Kd0, EFLOAT, 1, "gy_D0:");
|
||||||
|
|
||||||
|
PARAM_REG(speed_Kp, &sp_Kp, EFLOAT, 1, "sp_P:"); // 注冊
|
||||||
|
PARAM_REG(speed_Ki, &sp_Ki, EFLOAT, 1, "sp_I:"); // 注冊
|
||||||
|
PARAM_REG(speed_Kd, &sp_Kd, EFLOAT, 1, "sp_D:");
|
||||||
|
|
||||||
|
PARAM_REG(param_set_speed2, &set_speed2, EFLOAT, 1, "rate2:");
|
||||||
|
|
||||||
jj_param_read(); // 注冊
|
jj_param_read(); // 注冊
|
||||||
set_speed=set_speed1;
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @brief 参数写入
|
* @brief 参数写入
|
||||||
|
|||||||
@@ -17,36 +17,50 @@
|
|||||||
typedef enum {
|
typedef enum {
|
||||||
|
|
||||||
Page1_head = 0,
|
Page1_head = 0,
|
||||||
|
// 完道pid
|
||||||
angle_Kp0 = Page1_head,
|
angle_Kp0 = Page1_head,
|
||||||
angle_Ki0,
|
angle_Ki0,
|
||||||
angle_Kd0,
|
angle_Kd0,
|
||||||
|
|
||||||
gyro_Kp0,
|
gyro_Kp0,
|
||||||
gyro_Ki0,
|
gyro_Ki0,
|
||||||
gyro_Kd0,
|
gyro_Kd0,
|
||||||
speed_Kp,
|
|
||||||
speed_Ki,
|
|
||||||
speed_Kd,
|
|
||||||
pos_Kp0,
|
|
||||||
pos_Ki0,
|
|
||||||
pos_Kd0,
|
|
||||||
param_set_speed0,
|
|
||||||
|
|
||||||
|
can_Kp1,
|
||||||
|
can_Ki1,
|
||||||
|
can_Kd1,
|
||||||
|
fly_pwm,
|
||||||
|
param_set_speed0,
|
||||||
|
// 直道pid
|
||||||
Page2_head,
|
Page2_head,
|
||||||
angle_Kp1 = Page2_head,
|
angle_Kp1 = Page2_head,
|
||||||
angle_Ki1,
|
angle_Ki1,
|
||||||
angle_Kd1,
|
angle_Kd1,
|
||||||
|
|
||||||
gyro_Kp1,
|
gyro_Kp1,
|
||||||
gyro_Ki1,
|
gyro_Ki1,
|
||||||
gyro_Kd1,
|
gyro_Kd1,
|
||||||
|
|
||||||
pos_Kp1,
|
pos_Kp1,
|
||||||
pos_Ki1,
|
pos_Ki1,
|
||||||
pos_Kd1,
|
pos_Kd1,
|
||||||
can_Kp1,
|
|
||||||
can_Ki1,
|
|
||||||
can_Kd1,
|
|
||||||
param_set_speed1,
|
|
||||||
|
|
||||||
|
param_set_speed1,
|
||||||
|
// 圆环皮带
|
||||||
|
Page3_head,
|
||||||
|
yuan_Kp0 = Page3_head,
|
||||||
|
yuan_Ki0,
|
||||||
|
yuan_Kd0,
|
||||||
|
|
||||||
|
yugyro_Kp0,
|
||||||
|
yugyro_Ki0,
|
||||||
|
yugyro_Kd0,
|
||||||
|
|
||||||
|
speed_Kp,
|
||||||
|
speed_Ki,
|
||||||
|
speed_Kd,
|
||||||
|
|
||||||
|
param_set_speed2,
|
||||||
DATA_IN_FLASH_NUM,
|
DATA_IN_FLASH_NUM,
|
||||||
|
|
||||||
delta_x,
|
delta_x,
|
||||||
|
|||||||
@@ -124,12 +124,11 @@ void Page_Run(void)
|
|||||||
void Page_Init(void)
|
void Page_Init(void)
|
||||||
{
|
{
|
||||||
PAGE_REG(page_menu);
|
PAGE_REG(page_menu);
|
||||||
// PAGE_REG(page_rtcam);
|
|
||||||
PAGE_REG(page_param_pid0);
|
PAGE_REG(page_param_pid0);
|
||||||
PAGE_REG(page_param_pid1);
|
PAGE_REG(page_param_pid1);
|
||||||
// PAGE_REG(page_argv);
|
PAGE_REG(page_param_pid2);
|
||||||
// PAGE_REG(page_sys);
|
|
||||||
// PAGE_REG(page_run);
|
|
||||||
PAGE_REG(page_dparam);
|
PAGE_REG(page_dparam);
|
||||||
Page_Shift(page_menu);
|
Page_Shift(page_menu);
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ enum PageID {
|
|||||||
// page_rtcam,
|
// page_rtcam,
|
||||||
page_param_pid0,
|
page_param_pid0,
|
||||||
page_param_pid1,
|
page_param_pid1,
|
||||||
|
page_param_pid2,
|
||||||
page_dparam,
|
page_dparam,
|
||||||
// page_argv,
|
// page_argv,
|
||||||
// page_sys,
|
// page_sys,
|
||||||
|
|||||||
@@ -44,14 +44,14 @@ static void Loop()
|
|||||||
{
|
{
|
||||||
ips200_show_string(0, 0, "sta:");
|
ips200_show_string(0, 0, "sta:");
|
||||||
ips200_show_float(80, 0, in_state, 4, 1);
|
ips200_show_float(80, 0, in_state, 4, 1);
|
||||||
ips200_show_string(0, 20, "outca:");
|
ips200_show_string(0, 20, "outsp:");
|
||||||
ips200_show_float(80, 20, out_cangle, 4, 1);
|
ips200_show_float(80, 20, out_speed, 4, 1);
|
||||||
ips200_show_string(0, 40, "angle");
|
ips200_show_string(0, 40, "angle");
|
||||||
ips200_show_float(80, 40, in_angle, 4, 1);
|
ips200_show_float(80, 40, in_angle, 4, 1);
|
||||||
ips200_show_string(0, 60, "near");
|
ips200_show_string(0, 60, "accz");
|
||||||
ips200_show_float(80, 60, in_pos, 4, 1);
|
ips200_show_float(80, 60, (float)imu660ra_acc_z, 6, 1);
|
||||||
ips200_show_string(0, 80, "gyroz");
|
ips200_show_string(0, 80, "accy");
|
||||||
ips200_show_float(80, 80, in_gyro, 4, 2);
|
ips200_show_float(80, 80, (float)imu660ra_acc_y, 4, 2);
|
||||||
ips200_show_string(0, 100, "speed");
|
ips200_show_string(0, 100, "speed");
|
||||||
ips200_show_float(80, 100, in_speed, 4, 4);
|
ips200_show_float(80, 100, in_speed, 4, 4);
|
||||||
ips200_show_string(0, 120, "outang");
|
ips200_show_string(0, 120, "outang");
|
||||||
|
|||||||
@@ -5,13 +5,14 @@
|
|||||||
#include "jj_blueteeth.h"
|
#include "jj_blueteeth.h"
|
||||||
|
|
||||||
#define LINE_HEAD 1
|
#define LINE_HEAD 1
|
||||||
#define LINE_END 5
|
#define LINE_END 4
|
||||||
|
|
||||||
static char Text[] = "Menu";
|
static char Text[] = "Menu";
|
||||||
|
|
||||||
static int8_t Curser = LINE_HEAD; // 定义光标位置
|
static int8_t Curser = LINE_HEAD; // 定义光标位置
|
||||||
static int8_t Curser_Last = LINE_HEAD; // 定义光标位置
|
static int8_t Curser_Last = LINE_HEAD; // 定义光标位置
|
||||||
uint32_t cnt = 0;
|
uint32_t cnt = 0;
|
||||||
|
uint8_t go_flag = 0;
|
||||||
uint32_t reset[3];
|
uint32_t reset[3];
|
||||||
static void Print_Menu_p(void);
|
static void Print_Menu_p(void);
|
||||||
/***************************************************************************************
|
/***************************************************************************************
|
||||||
@@ -49,6 +50,14 @@ static void Exit()
|
|||||||
*/
|
*/
|
||||||
static void Loop()
|
static void Loop()
|
||||||
{
|
{
|
||||||
|
if (go_flag == 1) {
|
||||||
|
system_delay_ms(1000);
|
||||||
|
bt_fly_flag = 1;
|
||||||
|
system_delay_ms(1000);
|
||||||
|
bt_run_flag = 1;
|
||||||
|
|
||||||
|
go_flag = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -70,21 +79,8 @@ static void Event(page_event event)
|
|||||||
Page_Shift(Curser); // 切换到光标选中的页面
|
Page_Shift(Curser); // 切换到光标选中的页面
|
||||||
}
|
}
|
||||||
} else if (page_event_press_long == event) {
|
} else if (page_event_press_long == event) {
|
||||||
if(cnt==0)
|
go_flag = 1;
|
||||||
{
|
ips200_clear();
|
||||||
by_frame_send(reset);
|
|
||||||
cnt=1;
|
|
||||||
}
|
|
||||||
else if(cnt==1)
|
|
||||||
{
|
|
||||||
cnt=2;
|
|
||||||
bt_fly_flag=1;
|
|
||||||
}else if(cnt==2)
|
|
||||||
{
|
|
||||||
cnt=0;
|
|
||||||
bt_run_flag=1;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Curser < LINE_HEAD) {
|
if (Curser < LINE_HEAD) {
|
||||||
|
|||||||
@@ -4,9 +4,9 @@
|
|||||||
#include "page.h"
|
#include "page.h"
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#define LINE_HEAD 0
|
#define LINE_HEAD 1
|
||||||
#define LINE_END Page2_head - 1
|
#define LINE_END Page2_head
|
||||||
static char Text[] = "Param_pid0";
|
static char Text[] = "turn_pid";
|
||||||
static int event_flag = 0;
|
static int event_flag = 0;
|
||||||
static int index_power = 0;
|
static int index_power = 0;
|
||||||
static int8_t Curser = LINE_HEAD; // 定义光标位置
|
static int8_t Curser = LINE_HEAD; // 定义光标位置
|
||||||
@@ -25,13 +25,14 @@ static void jj_param_show();
|
|||||||
static void Setup()
|
static void Setup()
|
||||||
{
|
{
|
||||||
ips200_clear();
|
ips200_clear();
|
||||||
|
ips200_show_string(0, 2,"turn");
|
||||||
Print_Curser(Curser, Curser_Last, RGB565_PURPLE);
|
Print_Curser(Curser, Curser_Last, RGB565_PURPLE);
|
||||||
for (int16 i = 0; i <= LINE_END; i++) {
|
for (int16 i = 0; i < LINE_END; i++) {
|
||||||
ips200_show_string(0, i * 18 + 2, Param_Data[i].text);
|
ips200_show_string(0, i * 18 + 20, Param_Data[i].text);
|
||||||
if (Param_Data[i].type == EINT32)
|
if (Param_Data[i].type == EINT32)
|
||||||
ips200_show_int(50, i * 18 + 2, *((int32 *)(Param_Data[i].p_data)), 5);
|
ips200_show_int(50, i * 18 + 20, *((int32 *)(Param_Data[i].p_data)), 5);
|
||||||
else if (Param_Data[i].type == EFLOAT)
|
else if (Param_Data[i].type == EFLOAT)
|
||||||
ips200_show_float(50, i * 18 + 2, *((float *)(Param_Data[i].p_data)), 4, 5);
|
ips200_show_float(50, i * 18 + 20, *((float *)(Param_Data[i].p_data)), 4, 5);
|
||||||
}
|
}
|
||||||
ips200_show_int(100, 2, index_power, 5);
|
ips200_show_int(100, 2, index_power, 5);
|
||||||
}
|
}
|
||||||
@@ -87,20 +88,20 @@ static void Event(page_event event)
|
|||||||
Print_Curser(Curser, Curser_Last, RGB565_PURPLE);
|
Print_Curser(Curser, Curser_Last, RGB565_PURPLE);
|
||||||
} else if (1 == event_flag) {
|
} else if (1 == event_flag) {
|
||||||
if (page_event_forward == event) {
|
if (page_event_forward == event) {
|
||||||
if (Param_Data[Curser].type == EFLOAT) {
|
if (Param_Data[Curser-1].type == EFLOAT) {
|
||||||
*((float *)(Param_Data[Curser].p_data)) += powf(10.0f, (float)index_power);
|
*((float *)(Param_Data[Curser-1].p_data)) += powf(10.0f, (float)index_power);
|
||||||
} else if (Param_Data[Curser].type == EINT32) {
|
} else if (Param_Data[Curser-1].type == EINT32) {
|
||||||
*((int32 *)(Param_Data[Curser].p_data)) += 1;
|
*((int32 *)(Param_Data[Curser-1].p_data)) += 1;
|
||||||
} else if (Param_Data[Curser].type == EUINT32) {
|
} else if (Param_Data[Curser-1].type == EUINT32) {
|
||||||
*((uint32 *)(Param_Data[Curser].p_data)) += 1;
|
*((uint32 *)(Param_Data[Curser-1].p_data)) += 1;
|
||||||
}
|
}
|
||||||
} else if (page_event_backward == event) {
|
} else if (page_event_backward == event) {
|
||||||
if (Param_Data[Curser].type == EFLOAT) {
|
if (Param_Data[Curser-1].type == EFLOAT) {
|
||||||
*((float *)(Param_Data[Curser].p_data)) -= powf(10.0f, (float)index_power);
|
*((float *)(Param_Data[Curser-1].p_data)) -= powf(10.0f, (float)index_power);
|
||||||
} else if (Param_Data[Curser].type == EINT32) {
|
} else if (Param_Data[Curser-1].type == EINT32) {
|
||||||
*((int32 *)(Param_Data[Curser].p_data)) -= 1;
|
*((int32 *)(Param_Data[Curser-1].p_data)) -= 1;
|
||||||
} else if (Param_Data[Curser].type == EUINT32) {
|
} else if (Param_Data[Curser-1].type == EUINT32) {
|
||||||
*((uint32 *)(Param_Data[Curser].p_data)) -= 1;
|
*((uint32 *)(Param_Data[Curser-1].p_data)) -= 1;
|
||||||
}
|
}
|
||||||
} else if (page_event_press_short == event) {
|
} else if (page_event_press_short == event) {
|
||||||
index_power++;
|
index_power++;
|
||||||
@@ -117,12 +118,12 @@ static void Event(page_event event)
|
|||||||
}
|
}
|
||||||
static void jj_param_show()
|
static void jj_param_show()
|
||||||
{
|
{
|
||||||
if (EINT32 == Param_Data[Curser].type)
|
if (EINT32 == Param_Data[Curser-1].type)
|
||||||
ips200_show_int(50, Curser * 18 + 2, *((int32 *)(Param_Data[Curser].p_data)), 5);
|
ips200_show_int(50, Curser * 18 + 2, *((int32 *)(Param_Data[Curser-1].p_data)), 5);
|
||||||
else if (EUINT32 == Param_Data[Curser].type)
|
else if (EUINT32 == Param_Data[Curser-1].type)
|
||||||
ips200_show_uint(50, Curser * 18 + 2, *((int32 *)(Param_Data[Curser].p_data)), 5);
|
ips200_show_uint(50, Curser * 18 + 2, *((int32 *)(Param_Data[Curser-1].p_data)), 5);
|
||||||
else if (EFLOAT == Param_Data[Curser].type)
|
else if (EFLOAT == Param_Data[Curser-1].type)
|
||||||
ips200_show_float(50, Curser * 18 + 2, *((float *)(Param_Data[Curser].p_data)), 4, 5);
|
ips200_show_float(50, Curser * 18 + 2, *((float *)(Param_Data[Curser-1].p_data)), 4, 5);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @brief 页面注册函数
|
* @brief 页面注册函数
|
||||||
|
|||||||
@@ -4,9 +4,10 @@
|
|||||||
#include "page.h"
|
#include "page.h"
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#define LINE_HEAD 0
|
#define LINE_HEAD 1
|
||||||
#define LINE_END DATA_IN_FLASH_NUM - 1 - Page2_head
|
#define LINE_END Page3_head - Page2_head
|
||||||
static char Text[] = "Param_pid1";
|
#define Strat_param Page2_head
|
||||||
|
static char Text[] = "stra_pid";
|
||||||
static int event_flag = 0;
|
static int event_flag = 0;
|
||||||
static int index_power = 0;
|
static int index_power = 0;
|
||||||
static int8_t Curser = LINE_HEAD; // 定义光标位置
|
static int8_t Curser = LINE_HEAD; // 定义光标位置
|
||||||
@@ -25,13 +26,14 @@ static void jj_param_show();
|
|||||||
static void Setup()
|
static void Setup()
|
||||||
{
|
{
|
||||||
ips200_clear();
|
ips200_clear();
|
||||||
|
ips200_show_string(0, 2,"straight");
|
||||||
Print_Curser(Curser, Curser_Last, RGB565_PURPLE);
|
Print_Curser(Curser, Curser_Last, RGB565_PURPLE);
|
||||||
for (int16 i = 0; i < 13; i++) {
|
for (int16 i = 0; i < LINE_END; i++) {
|
||||||
ips200_show_string(0, i * 18 + 2, Param_Data[i + 13].text);
|
ips200_show_string(0, i * 18 + 20, Param_Data[i +Strat_param ].text);
|
||||||
if (Param_Data[i + 13].type == EINT32)
|
if (Param_Data[i + Strat_param].type == EINT32)
|
||||||
ips200_show_int(50, i * 18 + 2, *((int32 *)(Param_Data[i + 13].p_data)), 5);
|
ips200_show_int(50, i * 18 + 20, *((int32 *)(Param_Data[i + Strat_param].p_data)), 5);
|
||||||
else if (Param_Data[i + 13].type == EFLOAT)
|
else if (Param_Data[i + Strat_param].type == EFLOAT)
|
||||||
ips200_show_float(50, i * 18 + 2, *((float *)(Param_Data[i + 13].p_data)), 4, 5);
|
ips200_show_float(50, i * 18 + 20, *((float *)(Param_Data[i + Strat_param].p_data)), 4, 5);
|
||||||
}
|
}
|
||||||
ips200_show_int(100, 2, index_power, 5);
|
ips200_show_int(100, 2, index_power, 5);
|
||||||
}
|
}
|
||||||
@@ -87,20 +89,20 @@ static void Event(page_event event)
|
|||||||
Print_Curser(Curser, Curser_Last, RGB565_PURPLE);
|
Print_Curser(Curser, Curser_Last, RGB565_PURPLE);
|
||||||
} else if (1 == event_flag) {
|
} else if (1 == event_flag) {
|
||||||
if (page_event_forward == event) {
|
if (page_event_forward == event) {
|
||||||
if (Param_Data[Curser + 13].type == EFLOAT) {
|
if (Param_Data[Curser + Strat_param-1].type == EFLOAT) {
|
||||||
*((float *)(Param_Data[Curser + 13].p_data)) += powf(10.0f, (float)index_power);
|
*((float *)(Param_Data[Curser + Strat_param-1].p_data)) += powf(10.0f, (float)index_power);
|
||||||
} else if (Param_Data[Curser + 13].type == EINT32) {
|
} else if (Param_Data[Curser + Strat_param-1].type == EINT32) {
|
||||||
*((int32 *)(Param_Data[Curser + 13].p_data)) += 1;
|
*((int32 *)(Param_Data[Curser + Strat_param-1].p_data)) += 1;
|
||||||
} else if (Param_Data[Curser + 13].type == EUINT32) {
|
} else if (Param_Data[Curser + Strat_param-1].type == EUINT32) {
|
||||||
*((uint32 *)(Param_Data[Curser + Page2_head].p_data)) += 1;
|
*((uint32 *)(Param_Data[Curser + Strat_param-1].p_data)) += 1;
|
||||||
}
|
}
|
||||||
} else if (page_event_backward == event) {
|
} else if (page_event_backward == event) {
|
||||||
if (Param_Data[Curser + Page2_head].type == EFLOAT) {
|
if (Param_Data[Curser + Strat_param-1].type == EFLOAT) {
|
||||||
*((float *)(Param_Data[Curser + Page2_head].p_data)) -= powf(10.0f, (float)index_power);
|
*((float *)(Param_Data[Curser + Strat_param-1].p_data)) -= powf(10.0f, (float)index_power);
|
||||||
} else if (Param_Data[Curser + Page2_head].type == EINT32) {
|
} else if (Param_Data[Curser + Strat_param-1].type == EINT32) {
|
||||||
*((int32 *)(Param_Data[Curser + Page2_head].p_data)) -= 1;
|
*((int32 *)(Param_Data[Curser + Strat_param-1].p_data)) -= 1;
|
||||||
} else if (Param_Data[Curser + Page2_head].type == EUINT32) {
|
} else if (Param_Data[Curser + Strat_param-1].type == EUINT32) {
|
||||||
*((uint32 *)(Param_Data[Curser + Page2_head].p_data)) -= 1;
|
*((uint32 *)(Param_Data[Curser + Strat_param-1].p_data)) -= 1;
|
||||||
}
|
}
|
||||||
} else if (page_event_press_short == event) {
|
} else if (page_event_press_short == event) {
|
||||||
index_power++;
|
index_power++;
|
||||||
@@ -117,12 +119,12 @@ static void Event(page_event event)
|
|||||||
}
|
}
|
||||||
static void jj_param_show()
|
static void jj_param_show()
|
||||||
{
|
{
|
||||||
if (EINT32 == Param_Data[Curser + 13].type)
|
if (EINT32 == Param_Data[Curser + Strat_param-1].type)
|
||||||
ips200_show_int(50, Curser * 18 + 2, *((int32 *)(Param_Data[Curser + 13].p_data)), 5);
|
ips200_show_int(50, Curser * 18 + 2, *((int32 *)(Param_Data[Curser + Strat_param-1].p_data)), 5);
|
||||||
else if (EUINT32 == Param_Data[Curser + 13].type)
|
else if (EUINT32 == Param_Data[Curser + Strat_param-1].type)
|
||||||
ips200_show_uint(50, Curser * 18 + 2, *((int32 *)(Param_Data[Curser + 13].p_data)), 5);
|
ips200_show_uint(50, Curser * 18 + 2, *((int32 *)(Param_Data[Curser + Strat_param-1].p_data)), 5);
|
||||||
else if (EFLOAT == Param_Data[Curser + 13].type)
|
else if (EFLOAT == Param_Data[Curser + Strat_param-1].type)
|
||||||
ips200_show_float(50, Curser * 18 + 2, *((float *)(Param_Data[Curser + 13].p_data)), 4, 5);
|
ips200_show_float(50, Curser * 18 + 2, *((float *)(Param_Data[Curser + Strat_param-1].p_data)), 4, 5);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @brief 页面注册函数
|
* @brief 页面注册函数
|
||||||
|
|||||||
137
app/page/page_param_pid2.c
Normal file
137
app/page/page_param_pid2.c
Normal file
@@ -0,0 +1,137 @@
|
|||||||
|
#include "jj_param.h"
|
||||||
|
#include "page_ui_widget.h"
|
||||||
|
#include "jj_motion.h"
|
||||||
|
#include "page.h"
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#define LINE_HEAD 1
|
||||||
|
#define LINE_END DATA_IN_FLASH_NUM - Page3_head
|
||||||
|
#define Strat_param Page3_head
|
||||||
|
static char Text[] = "cir_pid";
|
||||||
|
static int event_flag = 0;
|
||||||
|
static int index_power = 0;
|
||||||
|
static int8_t Curser = LINE_HEAD; // 定义光标位置
|
||||||
|
static int8_t Curser_Last = LINE_HEAD; // 定义光标位置
|
||||||
|
static void jj_param_show();
|
||||||
|
/***************************************************************************************
|
||||||
|
*
|
||||||
|
* 以下为页面模板函数
|
||||||
|
*
|
||||||
|
***************************************************************************************/
|
||||||
|
/**
|
||||||
|
* @brief 页面初始化事件
|
||||||
|
* @param 无
|
||||||
|
* @retval 无
|
||||||
|
*/
|
||||||
|
static void Setup()
|
||||||
|
{
|
||||||
|
ips200_clear();
|
||||||
|
ips200_show_string(0, 2,"circle");
|
||||||
|
Print_Curser(Curser, Curser_Last, RGB565_PURPLE);
|
||||||
|
for (int16 i = 0; i < LINE_END; i++) {
|
||||||
|
ips200_show_string(0, i * 18 + 20, Param_Data[i +Strat_param ].text);
|
||||||
|
if (Param_Data[i + Strat_param].type == EINT32)
|
||||||
|
ips200_show_int(50, i * 18 + 20, *((int32 *)(Param_Data[i + Strat_param].p_data)), 5);
|
||||||
|
else if (Param_Data[i + Strat_param].type == EFLOAT)
|
||||||
|
ips200_show_float(50, i * 18 + 20, *((float *)(Param_Data[i + Strat_param].p_data)), 4, 5);
|
||||||
|
}
|
||||||
|
ips200_show_int(100, 2, index_power, 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 页面退出事件
|
||||||
|
* @param 无
|
||||||
|
* @retval 无
|
||||||
|
*/
|
||||||
|
static void Exit()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 页面循环执行的内容
|
||||||
|
* @param 无
|
||||||
|
* @retval 无
|
||||||
|
*/
|
||||||
|
static void Loop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief 页面事件
|
||||||
|
* @param btn:发出事件的按键
|
||||||
|
* @param event:事件编号
|
||||||
|
* @retval 无
|
||||||
|
*/
|
||||||
|
static void Event(page_event event)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (0 == event_flag) {
|
||||||
|
|
||||||
|
Curser_Last = Curser;
|
||||||
|
if (page_event_forward == event) {
|
||||||
|
Curser--; // 光标上移
|
||||||
|
} else if (page_event_backward == event) {
|
||||||
|
Curser++; // 光标下移
|
||||||
|
} else if (page_event_press_short == event) {
|
||||||
|
event_flag = 1; // 选中参数
|
||||||
|
Print_Curser(Curser, Curser_Last, RGB565_RED);
|
||||||
|
return;
|
||||||
|
} else if (page_event_press_long == event) {
|
||||||
|
jj_param_write();
|
||||||
|
sport_pid_init();
|
||||||
|
Page_Shift(page_menu);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (Curser < LINE_HEAD) {
|
||||||
|
Curser = LINE_END;
|
||||||
|
} else if (Curser > LINE_END) {
|
||||||
|
Curser = LINE_HEAD;
|
||||||
|
}
|
||||||
|
Print_Curser(Curser, Curser_Last, RGB565_PURPLE);
|
||||||
|
} else if (1 == event_flag) {
|
||||||
|
if (page_event_forward == event) {
|
||||||
|
if (Param_Data[Curser + Strat_param-1].type == EFLOAT) {
|
||||||
|
*((float *)(Param_Data[Curser + Strat_param-1].p_data)) += powf(10.0f, (float)index_power);
|
||||||
|
} else if (Param_Data[Curser + Strat_param-1].type == EINT32) {
|
||||||
|
*((int32 *)(Param_Data[Curser + Strat_param-1].p_data)) += 1;
|
||||||
|
} else if (Param_Data[Curser + Strat_param-1].type == EUINT32) {
|
||||||
|
*((uint32 *)(Param_Data[Curser + Strat_param-1].p_data)) += 1;
|
||||||
|
}
|
||||||
|
} else if (page_event_backward == event) {
|
||||||
|
if (Param_Data[Curser + Strat_param-1].type == EFLOAT) {
|
||||||
|
*((float *)(Param_Data[Curser + Strat_param-1].p_data)) -= powf(10.0f, (float)index_power);
|
||||||
|
} else if (Param_Data[Curser + Strat_param-1].type == EINT32) {
|
||||||
|
*((int32 *)(Param_Data[Curser + Strat_param-1].p_data)) -= 1;
|
||||||
|
} else if (Param_Data[Curser + Strat_param-1].type == EUINT32) {
|
||||||
|
*((uint32 *)(Param_Data[Curser + Strat_param-1].p_data)) -= 1;
|
||||||
|
}
|
||||||
|
} else if (page_event_press_short == event) {
|
||||||
|
index_power++;
|
||||||
|
if (index_power > 2) {
|
||||||
|
index_power = -2;
|
||||||
|
}
|
||||||
|
ips200_show_int(100, 2, index_power, 5);
|
||||||
|
} else if (page_event_press_long == event) {
|
||||||
|
event_flag = 0;
|
||||||
|
Print_Curser(Curser, Curser_Last, RGB565_PURPLE);
|
||||||
|
}
|
||||||
|
jj_param_show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static void jj_param_show()
|
||||||
|
{
|
||||||
|
if (EINT32 == Param_Data[Curser + Strat_param-1].type)
|
||||||
|
ips200_show_int(50, Curser * 18 + 2, *((int32 *)(Param_Data[Curser + Strat_param-1].p_data)), 5);
|
||||||
|
else if (EUINT32 == Param_Data[Curser + Strat_param-1].type)
|
||||||
|
ips200_show_uint(50, Curser * 18 + 2, *((int32 *)(Param_Data[Curser + Strat_param-1].p_data)), 5);
|
||||||
|
else if (EFLOAT == Param_Data[Curser + Strat_param-1].type)
|
||||||
|
ips200_show_float(50, Curser * 18 + 2, *((float *)(Param_Data[Curser + Strat_param-1].p_data)), 4, 5);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief 页面注册函数
|
||||||
|
*
|
||||||
|
* @param pageID
|
||||||
|
*/
|
||||||
|
void PageRegister_page_param_pid2(unsigned char pageID)
|
||||||
|
{
|
||||||
|
Page_Register(pageID, Text, Setup, Loop, Exit, Event);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user