Compare commits
28 Commits
ff88b5a3fe
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 83f13f3901 | |||
| 9a4caf7b7c | |||
| c825014599 | |||
| 06004e9e0b | |||
| 92eaf372ff | |||
| 53d06467d6 | |||
| 936f775dbd | |||
| 7b6b73d196 | |||
| 5a0c3ef803 | |||
| 73a30fc187 | |||
| 0313c90c28 | |||
| 9f9aa26197 | |||
| dda2649f6d | |||
| 34aae6602a | |||
| e842452ec6 | |||
| 8b5799302b | |||
| 50b5cd3f2d | |||
| ac05ce6f32 | |||
| fad2a71e3a | |||
| f04b21f738 | |||
| 66162b9094 | |||
| ad2ba36b54 | |||
| 8d4580f225 | |||
| f33ab5ab4b | |||
| 81f0e13eae | |||
| 5dd6ddd802 | |||
| 55cc6b31f3 | |||
| 6b1f345ead |
@@ -68,10 +68,9 @@
|
||||
"libList": [
|
||||
"libraries/zf_device"
|
||||
],
|
||||
"sourceDirList": [],
|
||||
"defineList": []
|
||||
}
|
||||
}
|
||||
},
|
||||
"version": "3.3"
|
||||
"version": "3.4"
|
||||
}
|
||||
@@ -2,22 +2,14 @@
|
||||
#include "by_fan_control.h"
|
||||
#include "zf_common_headfile.h"
|
||||
#include "jj_blueteeth.h"
|
||||
|
||||
#include "jj_motion.h"
|
||||
#define FAN_LL_PWM_PIN TIM8_PWM_MAP1_CH1_B6 // 左升力风扇
|
||||
#define FAN_RL_PWM_PIN TIM8_PWM_MAP1_CH2_B7 // 右升力风扇
|
||||
// M4
|
||||
#define FAN_LS_PWM_A_PIN TIM10_PWM_MAP3_CH1_D1 // 左侧动力风扇
|
||||
#define FAN_LS_PWM_B_PIN TIM10_PWM_MAP3_CH2_D3 // 左侧动力风扇
|
||||
// M1
|
||||
#define FAN_RS_PWM_A_PIN TIM4_PWM_MAP1_CH1_D12 // 右侧动力风扇
|
||||
#define FAN_RS_PWM_B_PIN TIM4_PWM_MAP1_CH2_D13 // 右侧动力风扇
|
||||
// M3
|
||||
#define FAN_LB_PWM_A_PIN TIM10_PWM_MAP3_CH3_D5 // 左后动力风扇
|
||||
#define FAN_LB_PWM_B_PIN TIM10_PWM_MAP3_CH4_D7 // 左后动力风扇
|
||||
// M2
|
||||
#define FAN_RB_PWM_A_PIN TIM4_PWM_MAP1_CH3_D14 // 右后动力风扇
|
||||
#define FAN_RB_PWM_B_PIN TIM4_PWM_MAP1_CH4_D15 // 右后动力风扇
|
||||
|
||||
#define FAN_RB_PWM_PIN TIM10_PWM_MAP3_CH4_D7
|
||||
#define FAN_LB_PWM_PIN TIM4_PWM_MAP1_CH2_D13
|
||||
#define FAN_LS_PWM_PIN TIM1_PWM_MAP0_CH4_A11
|
||||
#define FAN_RS_PWM_PIN TIM1_PWM_MAP0_CH1_A8
|
||||
int32_t pwm_duty_ls_g;
|
||||
int32_t pwm_duty_rs_g;
|
||||
int32_t pwm_duty_lb_g;
|
||||
@@ -41,59 +33,17 @@ inline static float clip_f32(float x, float low, float up)
|
||||
: x);
|
||||
}
|
||||
|
||||
#define FIX_DRIVE 0
|
||||
void by_pwm_init(void)
|
||||
{
|
||||
gpio_init(D4, GPO, 1, GPO_PUSH_PULL);
|
||||
gpio_init(C8, GPO, 1, GPO_PUSH_PULL);
|
||||
pwm_init(FAN_LL_PWM_PIN, 50, 500);
|
||||
pwm_init(FAN_RL_PWM_PIN, 50, 500);
|
||||
|
||||
// 测试鸣叫
|
||||
pwm_init(FAN_LS_PWM_A_PIN, 1500, 100);
|
||||
pwm_init(FAN_LS_PWM_B_PIN, 4000, 0);
|
||||
pwm_init(FAN_RS_PWM_A_PIN, 1500, 100);
|
||||
pwm_init(FAN_RS_PWM_B_PIN, 4000, 0);
|
||||
pwm_init(FAN_LB_PWM_A_PIN, 1500, 100);
|
||||
pwm_init(FAN_LB_PWM_B_PIN, 4000, 0);
|
||||
pwm_init(FAN_RB_PWM_A_PIN, 1500, 100);
|
||||
pwm_init(FAN_RB_PWM_B_PIN, 4000, 0);
|
||||
system_delay_ms(300);
|
||||
pwm_init(FAN_LS_PWM_A_PIN, 2000, 100);
|
||||
pwm_init(FAN_LS_PWM_B_PIN, 4000, 0);
|
||||
pwm_init(FAN_RS_PWM_A_PIN, 2000, 100);
|
||||
pwm_init(FAN_RS_PWM_B_PIN, 4000, 0);
|
||||
pwm_init(FAN_LB_PWM_A_PIN, 2000, 100);
|
||||
pwm_init(FAN_LB_PWM_B_PIN, 4000, 0);
|
||||
pwm_init(FAN_RB_PWM_A_PIN, 2000, 100);
|
||||
pwm_init(FAN_RB_PWM_B_PIN, 4000, 0);
|
||||
system_delay_ms(300);
|
||||
pwm_init(FAN_LS_PWM_A_PIN, 2500, 100);
|
||||
pwm_init(FAN_LS_PWM_B_PIN, 4000, 0);
|
||||
pwm_init(FAN_RS_PWM_A_PIN, 2500, 100);
|
||||
pwm_init(FAN_RS_PWM_B_PIN, 4000, 0);
|
||||
pwm_init(FAN_LB_PWM_A_PIN, 2500, 100);
|
||||
pwm_init(FAN_LB_PWM_B_PIN, 4000, 0);
|
||||
pwm_init(FAN_RB_PWM_A_PIN, 2500, 100);
|
||||
pwm_init(FAN_RB_PWM_B_PIN, 4000, 0);
|
||||
system_delay_ms(300);
|
||||
|
||||
pwm_init(FAN_LS_PWM_A_PIN, 4000, 0);
|
||||
pwm_init(FAN_LS_PWM_B_PIN, 4000, 0);
|
||||
pwm_init(FAN_RS_PWM_A_PIN, 4000, 0);
|
||||
pwm_init(FAN_RS_PWM_B_PIN, 4000, 0);
|
||||
pwm_init(FAN_LB_PWM_A_PIN, 4000, 0);
|
||||
pwm_init(FAN_LB_PWM_B_PIN, 4000, 0);
|
||||
pwm_init(FAN_RB_PWM_A_PIN, 4000, 0);
|
||||
pwm_init(FAN_RB_PWM_B_PIN, 4000, 0);
|
||||
// system_delay_ms(3000);
|
||||
// // pwm_init(FAN_LS_PWM_PIN, 50, 1000); // 动力风扇左 1
|
||||
// // pwm_init(FAN_RS_PWM_PIN, 50, 1000); // 动力风扇右 1
|
||||
// // pwm_init(FAN_LB_PWM_PIN, 50, 1000); // 动力风扇左 2
|
||||
// // pwm_init(FAN_RB_PWM_PIN, 50, 1000); // 动力风扇右 2
|
||||
// // system_delay_ms(5000);
|
||||
// pwm_set_duty(FAN_LS_PWM_PIN, 600);
|
||||
// pwm_set_duty(FAN_RS_PWM_PIN, 600);
|
||||
// pwm_set_duty(FAN_LB_PWM_PIN, 600);
|
||||
// pwm_set_duty(FAN_RB_PWM_PIN, 600);
|
||||
// while(1);
|
||||
pwm_init(FAN_LS_PWM_PIN, 50, 500);
|
||||
pwm_init(FAN_RS_PWM_PIN, 50, 500);
|
||||
pwm_init(FAN_LB_PWM_PIN, 300, 300);
|
||||
pwm_init(FAN_RB_PWM_PIN, 300, 300);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -118,47 +68,14 @@ void by_pwm_update_duty(uint32_t update_pwm_duty1, uint32_t update_pwm_duty2)
|
||||
* @param pwm_duty_lb
|
||||
* @param pwm_duty_rb
|
||||
*/
|
||||
void by_pwm_power_duty(int32_t pwm_duty_ls, int32_t pwm_duty_rs, int32_t pwm_duty_lb, int32_t pwm_duty_rb)
|
||||
void by_pwm_power_duty(int32_t bpwm_duty_ls, int32_t bpwm_duty_rs, int32_t bpwm_duty_lb, int32_t bpwm_duty_rb)
|
||||
{
|
||||
pwm_duty_ls = clip_s32(pwm_duty_ls, 0, 8000);
|
||||
pwm_duty_rs = clip_s32(pwm_duty_rs, 0, 8000);
|
||||
pwm_duty_lb = clip_s32(pwm_duty_lb, 0, 8000);
|
||||
pwm_duty_rb = clip_s32(pwm_duty_rb, 0, 8000);
|
||||
|
||||
pwm_duty_ls_g = pwm_duty_ls;
|
||||
pwm_duty_rs_g = pwm_duty_rs;
|
||||
pwm_duty_lb_g = pwm_duty_lb;
|
||||
pwm_duty_rb_g = pwm_duty_rb;
|
||||
|
||||
if (pwm_duty_ls >= 0) {
|
||||
pwm_set_duty(FAN_LS_PWM_A_PIN, pwm_duty_ls);
|
||||
pwm_set_duty(FAN_LS_PWM_B_PIN, 0);
|
||||
} else {
|
||||
pwm_set_duty(FAN_LS_PWM_A_PIN, 0);
|
||||
pwm_set_duty(FAN_LS_PWM_B_PIN, -1 * pwm_duty_ls);
|
||||
}
|
||||
|
||||
if (pwm_duty_rs >= 0) {
|
||||
pwm_set_duty(FAN_RS_PWM_A_PIN, pwm_duty_rs);
|
||||
pwm_set_duty(FAN_RS_PWM_B_PIN, 0);
|
||||
} else {
|
||||
pwm_set_duty(FAN_RS_PWM_A_PIN, 0);
|
||||
pwm_set_duty(FAN_RS_PWM_B_PIN, -1 * pwm_duty_rs);
|
||||
}
|
||||
|
||||
if (pwm_duty_lb >= 0) {
|
||||
pwm_set_duty(FAN_LB_PWM_A_PIN, pwm_duty_lb);
|
||||
pwm_set_duty(FAN_LB_PWM_B_PIN, 0);
|
||||
} else {
|
||||
pwm_set_duty(FAN_LB_PWM_A_PIN, 0);
|
||||
pwm_set_duty(FAN_LB_PWM_B_PIN, -1 * pwm_duty_lb);
|
||||
}
|
||||
|
||||
if (pwm_duty_rb >= 0) {
|
||||
pwm_set_duty(FAN_RB_PWM_A_PIN, pwm_duty_rb);
|
||||
pwm_set_duty(FAN_RB_PWM_B_PIN, 0);
|
||||
} else {
|
||||
pwm_set_duty(FAN_RB_PWM_A_PIN, 0);
|
||||
pwm_set_duty(FAN_RB_PWM_B_PIN, -1 * pwm_duty_rb);
|
||||
}
|
||||
bpwm_duty_ls = clip_s32(bpwm_duty_ls, 500, 999);
|
||||
bpwm_duty_rs = clip_s32(bpwm_duty_rs, 500, 999);
|
||||
bpwm_duty_lb = clip_s32(bpwm_duty_lb, 2500, 6000);
|
||||
bpwm_duty_rb = clip_s32(bpwm_duty_rb, 2500, 6000);
|
||||
pwm_set_duty(FAN_LS_PWM_PIN, bpwm_duty_ls);
|
||||
pwm_set_duty(FAN_RS_PWM_PIN, bpwm_duty_rs);
|
||||
pwm_set_duty(FAN_LB_PWM_PIN, bpwm_duty_lb);
|
||||
pwm_set_duty(FAN_RB_PWM_PIN, bpwm_duty_rb);
|
||||
}
|
||||
@@ -22,7 +22,7 @@ void by_frame_init(void)
|
||||
void by_frame_send(uint32_t* data_array)
|
||||
{
|
||||
uint16_t crc_cal = 0;
|
||||
const uint8_t data_byte_num = BY_FRAME_DATA_NUM * sizeof(uint32_t);
|
||||
const uint8_t data_byte_num = 1 * sizeof(uint32_t);
|
||||
|
||||
frame_buffer_send[0] = BY_FRAME_HEAD_1;
|
||||
frame_buffer_send[1] = BY_FRAME_HEAD_2;
|
||||
|
||||
11
app/isr.c
11
app/isr.c
@@ -130,14 +130,15 @@ void UART7_IRQHandler(void)
|
||||
{
|
||||
if (USART_GetITStatus(UART7, USART_IT_RXNE) != RESET) {
|
||||
wireless_module_uart_handler();
|
||||
uart_query_byte(UART_7, &bt_buffer);
|
||||
bt_rx_flag = true;
|
||||
USART_ClearITPendingBit(UART7, USART_IT_RXNE);
|
||||
}
|
||||
}
|
||||
void UART8_IRQHandler(void)
|
||||
{
|
||||
if (USART_GetITStatus(UART8, USART_IT_RXNE) != RESET) {
|
||||
uart_query_byte(UART_8, &bt_buffer);
|
||||
bt_rx_flag = true;
|
||||
|
||||
USART_ClearITPendingBit(UART8, USART_IT_RXNE);
|
||||
}
|
||||
}
|
||||
@@ -272,8 +273,7 @@ void EXTI15_10_IRQHandler(void)
|
||||
void TIM1_UP_IRQHandler(void)
|
||||
{
|
||||
if (TIM_GetITStatus(TIM1, TIM_IT_Update) != RESET) {
|
||||
by_buzzer_run();
|
||||
sport_motion();
|
||||
|
||||
TIM_ClearITPendingBit(TIM1, TIM_IT_Update);
|
||||
}
|
||||
}
|
||||
@@ -309,7 +309,8 @@ void TIM5_IRQHandler(void)
|
||||
void TIM6_IRQHandler(void)
|
||||
{
|
||||
if (TIM_GetITStatus(TIM6, TIM_IT_Update) != RESET) {
|
||||
// ICM_getEulerianAngles();
|
||||
by_buzzer_run();
|
||||
sport_motion();
|
||||
TIM_ClearITPendingBit(TIM6, TIM_IT_Update);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,13 +6,13 @@ uint8_t bt_buffer; // 接收字符存入
|
||||
uint8_t bt_run_flag = 0;
|
||||
uint8_t bt_fly_flag = 0;
|
||||
uint32_t bt_run = 0;
|
||||
uint32_t bt_fly = 500;
|
||||
float bt_fly = 160.f;
|
||||
enum bt_order {
|
||||
Fly_ctrl = 0x01, // 起飞转换
|
||||
Fly_up = 0x02, // 起飞程度增加
|
||||
Fly_dowm = 0x03, // 起飞程度减小
|
||||
Speed_up = 0x04, // 加速
|
||||
Speed_down = 0x05, // 减速
|
||||
fly_close = 0x04, // 加速
|
||||
run_close = 0x05, // 全关
|
||||
Speed_ctrl = 0x06, // 速度开关
|
||||
Reset,
|
||||
};
|
||||
@@ -24,7 +24,7 @@ void jj_bt_init()
|
||||
{
|
||||
uart_init(BT_UART_INDEX, BT_UART_BAUDRATE, BT_UART_TX_PIN, BT_UART_RX_PIN);
|
||||
// uart_tx_interrupt(UART_2, 1);
|
||||
uart_rx_interrupt(UART_8, ENABLE);
|
||||
uart_rx_interrupt(BT_UART_INDEX, ENABLE);
|
||||
}
|
||||
/**
|
||||
*@brief 蓝牙中断回调函数
|
||||
@@ -34,22 +34,35 @@ void jj_bt_run()
|
||||
if (bt_rx_flag) {
|
||||
switch (bt_buffer) {
|
||||
case Fly_ctrl:
|
||||
bt_fly_flag = !bt_fly_flag;
|
||||
|
||||
if (go_cnt == 0) {
|
||||
go_cnt = 1;
|
||||
bt_fly_flag = 1;
|
||||
}
|
||||
else if (go_cnt == 1) {
|
||||
go_cnt = 0;
|
||||
}
|
||||
|
||||
break;
|
||||
case Speed_ctrl:
|
||||
bt_run_flag = !bt_run_flag;
|
||||
if (go_cnt == 1) {
|
||||
go_cnt = 2;
|
||||
}
|
||||
|
||||
break;
|
||||
case Fly_up:
|
||||
bt_fly += 50;
|
||||
bt_fly += 10;
|
||||
break;
|
||||
case Fly_dowm:
|
||||
bt_fly -= 50;
|
||||
bt_fly -= 10;
|
||||
break;
|
||||
case Speed_up:
|
||||
bt_run += 50;
|
||||
case run_close:
|
||||
bt_run_flag = 0;
|
||||
go_cnt = 0;
|
||||
break;
|
||||
case Speed_down:
|
||||
bt_run -= 50;
|
||||
case fly_close:
|
||||
bt_fly_flag = 0;
|
||||
go_cnt = 0;
|
||||
break;
|
||||
case Reset:
|
||||
NVIC_SystemReset();
|
||||
@@ -70,8 +83,7 @@ void bt_printf(const char *format, ...)
|
||||
va_end(args);
|
||||
|
||||
for (uint16_t i = 0; i < strlen(sbuf); i++) {
|
||||
while (USART_GetFlagStatus((USART_TypeDef *)uart_index[UART_8], USART_FLAG_TC) == RESET)
|
||||
;
|
||||
USART_SendData((USART_TypeDef *)uart_index[UART_8], sbuf[i]);
|
||||
while (USART_GetFlagStatus((USART_TypeDef *)uart_index[UART_7], USART_FLAG_TC) == RESET);
|
||||
USART_SendData((USART_TypeDef *)uart_index[UART_7], sbuf[i]);
|
||||
}
|
||||
}
|
||||
@@ -4,17 +4,18 @@
|
||||
#include "stdio.h"
|
||||
#include "zf_driver_uart.h"
|
||||
|
||||
#define BT_UART_INDEX UART_8
|
||||
#define BT_UART_INDEX UART_7
|
||||
#define BT_UART_BAUDRATE 115200
|
||||
#define BT_UART_TX_PIN UART8_MAP0_TX_C4
|
||||
#define BT_UART_RX_PIN UART8_MAP0_RX_C5
|
||||
#define BT_UART_TX_PIN UART7_MAP1_TX_A6
|
||||
#define BT_UART_RX_PIN UART7_MAP1_RX_A7
|
||||
|
||||
extern bool bt_rx_flag;
|
||||
extern uint8_t bt_buffer; // 接收字符存入
|
||||
extern uint8_t bt_run_flag;
|
||||
extern uint8_t bt_fly_flag;
|
||||
extern uint8_t bt_ce_flag;
|
||||
extern uint32_t bt_run;
|
||||
extern uint32_t bt_fly;
|
||||
extern float bt_fly;
|
||||
|
||||
void jj_bt_init();
|
||||
void jj_bt_run();
|
||||
|
||||
368
app/jj_motion.c
368
app/jj_motion.c
@@ -1,68 +1,138 @@
|
||||
#include "jj_motion.h"
|
||||
|
||||
#include <math.h>
|
||||
#include "zf_common_headfile.h"
|
||||
#include "pid.h"
|
||||
|
||||
#include "jj_voltage.h"
|
||||
#include "jj_blueteeth.h"
|
||||
#include "by_fan_control.h"
|
||||
#include "by_imu.h"
|
||||
#include "by_frame.h"
|
||||
|
||||
PID_TypeDef far_angle_pid;
|
||||
PID_TypeDef pos_pid;
|
||||
PID_TypeDef far_gyro_pid;
|
||||
PID_TypeDef near_pos_pid;
|
||||
PID_TypeDef speed_pid;
|
||||
PID_TypeDef cir_pos_pid;
|
||||
///////////////////////////////////////////
|
||||
// 直道后面风扇角度环
|
||||
float an_Kp1 = 46.0f;
|
||||
float an_Ki1 = 0.0f;
|
||||
float an_Kd1 = 0.0f;
|
||||
// 直道角速度环
|
||||
float gy_Kp1 = 1.530f;
|
||||
float gy_Ki1 = 0.0f;
|
||||
float gy_Kd1 = 0.0f;
|
||||
// 直道侧面风扇角度环
|
||||
float po_Kp1 = 2.10f;
|
||||
float po_Ki1 = 0.0f;
|
||||
float po_Kd1 = 0.0f;
|
||||
////////////////////////////////////
|
||||
// 弯道后面风扇角度环
|
||||
float an_Kp0 = 53.0f;
|
||||
float an_Ki0 = 0.0f;
|
||||
float an_Kd0 = 0.0f;
|
||||
|
||||
float an_Kp0 = 80.0f;
|
||||
float an_Ki0 = 1.4f;
|
||||
float an_Kd0 = 8.0f;
|
||||
// 弯道角速度环
|
||||
float gy_Kp0 = 2.2180f;
|
||||
float gy_Ki0 = 0.0f;
|
||||
float gy_Kd0 = 0.0f;
|
||||
|
||||
float an_Kp1 = 80.0f;
|
||||
float an_Ki1 = 1.4f;
|
||||
float an_Kd1 = 8.0f;
|
||||
// 弯道侧面风扇角度环
|
||||
float cn_Kp1 = 7.0f;
|
||||
float cn_Ki1 = 0.f;
|
||||
float cn_Kd1 = 0.0f;
|
||||
////////////////////////////////////////
|
||||
// 避障后面角度环
|
||||
float za_Kp = 55.f;
|
||||
float za_Ki = 0;
|
||||
float za_Kd = 0;
|
||||
|
||||
float zg_Kp = 2.f;
|
||||
float zg_Ki = 0;
|
||||
float zg_Kd = 0;
|
||||
|
||||
float zp_Kp = 6.f;
|
||||
float zp_Ki = 0;
|
||||
float zp_Kd = 0;
|
||||
///////////////////////////////////////
|
||||
// 圆环后面风扇角度环
|
||||
float yu_Kp0 = 58.0f;
|
||||
float yu_Ki0 = 0.0f;
|
||||
float yu_Kd0 = 0.0f;
|
||||
// 圆环角速度环
|
||||
float ygy_Kp0 = 2.20f;
|
||||
float ygy_Ki0 = 0.0f;
|
||||
float ygy_Kd0 = 0.0f;
|
||||
// 圆环侧面角度环
|
||||
float yuc_Kp = 4.4f;
|
||||
// 速度环
|
||||
float sp_Kp = 3.40f;
|
||||
float sp_Ki = 3.6f;
|
||||
float sp_Kd = 0.0f;
|
||||
////////////////////////////////////////////////////
|
||||
// 当前和输入量
|
||||
float in_gyro;
|
||||
float out_gyro;
|
||||
// 期望和当前量
|
||||
float in_angle;
|
||||
float set_angle = 0.0f;
|
||||
float out_angle;
|
||||
|
||||
float gy_Kp0 = 2.0f;
|
||||
float gy_Ki0 = 0.0f;
|
||||
float gy_Kd0 = 0.3f;
|
||||
|
||||
float gy_Kp1 = 2.0f;
|
||||
float gy_Ki1 = 0.0f;
|
||||
float gy_Kd1 = 0.3f;
|
||||
float in_gyro;
|
||||
float out_gyro;
|
||||
// float set_gyro = 0.0f;
|
||||
|
||||
float po_Kp0 = 827.0f;
|
||||
float po_Ki0 = 16.0f;
|
||||
float po_Kd0 = 13.0f;
|
||||
|
||||
float po_Kp1 = 500.0f;
|
||||
float po_Ki1 = 2.0f;
|
||||
float po_Kd1 = 1.0f;
|
||||
float in_pos;
|
||||
float out_pos;
|
||||
float set_pos = 0.0f;
|
||||
|
||||
float sp_Kp = 19.0f;
|
||||
float sp_Ki = 0.5f;
|
||||
float sp_Kd = 0.0f;
|
||||
// float set_gyro = 0.0f;
|
||||
float rate_K1 = 0;
|
||||
float rate_K2 = 0;
|
||||
float in_speed;
|
||||
float out_speed;
|
||||
|
||||
float set_speed0 = 460.0f;
|
||||
float set_speed1 = 460.0f;
|
||||
float last_angle;
|
||||
float set_speed;
|
||||
float set_speed0 = 657.0f;
|
||||
float set_speed1 = 1111.0f;
|
||||
float set_speed2 = 815.f;
|
||||
float set_speed3 = 666.f;
|
||||
float set_speed4 = 720.f;
|
||||
int cnt1 = 0;
|
||||
int cnt2 = 0;
|
||||
int cnt3 = 0;
|
||||
int cnt4 = 0; //
|
||||
int cnt5 = 0;
|
||||
int cnt6 = 0; //
|
||||
int cnt7 = 0;
|
||||
int cnt8 = 0;
|
||||
int cnt9 = 0; //
|
||||
int cnt10 = 0; //
|
||||
int if_start = 0;
|
||||
|
||||
uint8_t in_state = 0;
|
||||
uint8_t in_stop = 0;
|
||||
|
||||
uint32_t pwm_duty_ls;
|
||||
uint32_t pwm_duty_rs;
|
||||
uint32_t pwm_duty_lb;
|
||||
uint32_t pwm_duty_rb;
|
||||
|
||||
uint8_t last_state = 0;
|
||||
uint8_t stop_flag = 0;
|
||||
int32_t pwm_duty_ls;
|
||||
int32_t pwm_duty_rs;
|
||||
int32_t pwm_duty_lb;
|
||||
int32_t pwm_duty_rb;
|
||||
int32_t stop_cnt = 0;
|
||||
int32_t last_lb = 0;
|
||||
int32_t last_rb = 0;
|
||||
float start_dis = 0;
|
||||
float set_dis = 1.f;
|
||||
uint8_t go_cnt = 0; // 0 停车 1 测试侧向风扇 2 启动 3成功运行
|
||||
float bug_sw = 0;
|
||||
float out_sw = 0;
|
||||
float sho_sw = 0;
|
||||
uint8_t bug_show_flag = 0;
|
||||
uint8_t out_show_flag = 0;
|
||||
uint8_t up_show_flag = 0;
|
||||
uint8_t finish_show_flag = 0;
|
||||
/*
|
||||
0:无状态
|
||||
1:弯道
|
||||
2:直道
|
||||
3:入环
|
||||
4:环内
|
||||
5:障碍
|
||||
*/
|
||||
static float myclip_f(float x, float low, float up)
|
||||
{
|
||||
return (x > up ? up : x < low ? low
|
||||
@@ -84,56 +154,177 @@ float sport_get_speed(void)
|
||||
#undef ALPHA
|
||||
}
|
||||
|
||||
void sport_motion(void)
|
||||
void sport_motion()
|
||||
{
|
||||
if (1 == in_stop) {
|
||||
imu660ra_get_gyro();
|
||||
imu660ra_get_acc();
|
||||
get_vol();
|
||||
in_gyro = imu660ra_gyro_z;
|
||||
|
||||
////////////////////////////////////////停车任务///////////////////////////////////////////////
|
||||
// 抖动停车,计次50
|
||||
if (imu660ra_acc_z <= 800) {
|
||||
cnt7++;
|
||||
} else {
|
||||
cnt7 = 0;
|
||||
}
|
||||
if (cnt7 >= 50 && (uint8_t)sho_sw == 1) {
|
||||
bt_fly_flag = bt_run_flag = 0;
|
||||
bt_printf("up");
|
||||
up_show_flag = 1;
|
||||
go_cnt = 0;
|
||||
}
|
||||
// 異常值停车
|
||||
if (fabs(in_angle - last_angle) > 45.f && (uint8_t)bug_sw == 1) {
|
||||
bt_fly_flag = bt_run_flag = 0;
|
||||
bt_printf("bug");
|
||||
bug_show_flag = 1;
|
||||
go_cnt = 0;
|
||||
}
|
||||
// 斑马线停车,摄像头识别,屏蔽发车前的十秒钟
|
||||
if (1 == in_stop && if_start == 1) {
|
||||
stop_flag = 1;
|
||||
}
|
||||
if (stop_flag == 1) {
|
||||
bt_printf("finish");
|
||||
finish_show_flag = 1;
|
||||
bt_fly_flag = bt_run_flag = 0;
|
||||
go_cnt = 0;
|
||||
}
|
||||
// 出界停车,已经积分路过斑马线,保证斑马线不会触发
|
||||
if (2 == in_stop && ((start_dis >= set_dis) || bt_run_flag == 0) && (uint8_t)out_sw == 1) {
|
||||
bt_printf("out");
|
||||
out_show_flag = 1;
|
||||
go_cnt = 0;
|
||||
bt_fly_flag = bt_run_flag = 0;
|
||||
}
|
||||
if (0 == in_state || 2 == in_state) {
|
||||
PID_SetTunings(&far_gyro_pid, an_Kp1, an_Ki1, an_Kd1);
|
||||
PID_SetTunings(&near_pos_pid, po_Kp1, po_Ki1, po_Kd1);
|
||||
PID_SetTunings(&far_gyro_pid, gy_Kp1, gy_Ki1, gy_Kd1);
|
||||
} else {
|
||||
PID_SetTunings(&far_gyro_pid, an_Kp0, an_Ki0, an_Kd0);
|
||||
PID_SetTunings(&near_pos_pid, po_Kp0, po_Ki0, po_Kd0);
|
||||
PID_SetTunings(&far_gyro_pid, gy_Kp0, gy_Ki0, gy_Kd0);
|
||||
}
|
||||
/* 动力风扇设置 */
|
||||
|
||||
//////////////////////////////////////////////// 动力风扇设置 */////////////////////////////////////////////////////////
|
||||
if (1 == bt_run_flag) {
|
||||
cnt1++;
|
||||
cnt2++;
|
||||
cnt5++;
|
||||
// 斑马线积分,系数随便给的
|
||||
start_dis += in_speed * 0.0000018f;
|
||||
if (if_start == 0) {
|
||||
cnt8++;
|
||||
|
||||
imu660ra_get_gyro();
|
||||
in_gyro = imu660ra_gyro_z; // 陀螺仪输入
|
||||
if (cnt8 >= 5000) {
|
||||
if_start = 1;
|
||||
}
|
||||
}
|
||||
// pid参数切换
|
||||
if ((last_state != in_state) && (in_state == 2)) { // 直道
|
||||
|
||||
bt_printf("to 直道");
|
||||
set_speed = set_speed1;
|
||||
|
||||
PID_SetTunings(&far_angle_pid, an_Kp1, an_Ki1, an_Kd1);
|
||||
PID_SetTunings(&far_gyro_pid, gy_Kp1, gy_Ki1, gy_Kd1);
|
||||
PID_SetTunings(&pos_pid, po_Kp1, po_Ki1, po_Kd1);
|
||||
} else if ((last_state != in_state) && in_state == 1) { // 弯道
|
||||
bt_printf("to 入弯");
|
||||
if (fabs(in_pos) <= 12.0f) {
|
||||
set_speed = set_speed0 - fabs(rate_K1 * myclip_f(in_pos, -50.f, 50.f));
|
||||
} else {
|
||||
set_speed = set_speed0 - fabs(rate_K2 * myclip_f(in_pos, -50.f, 50.f));
|
||||
}
|
||||
|
||||
PID_SetTunings(&far_angle_pid, an_Kp0, an_Ki0, an_Kd0);
|
||||
PID_SetTunings(&far_gyro_pid, gy_Kp0, gy_Ki0, gy_Kd0);
|
||||
PID_SetTunings(&pos_pid, cn_Kp1, cn_Ki1, cn_Kd1);
|
||||
} else if ((last_state != in_state) && (in_state == 3 || in_state == 4)) { // 圆环
|
||||
bt_printf("to 圆环");
|
||||
if (in_state == 3)
|
||||
set_speed = set_speed2;
|
||||
else
|
||||
set_speed = set_speed3;
|
||||
|
||||
PID_SetTunings(&far_angle_pid, yu_Kp0, yu_Ki0, yu_Kd0);
|
||||
PID_SetTunings(&far_gyro_pid, ygy_Kp0, ygy_Ki0, ygy_Kd0);
|
||||
PID_SetTunings(&pos_pid, yuc_Kp, cn_Ki1, cn_Kd1);
|
||||
} else if ((last_state != in_state) && in_state == 5) { //
|
||||
bt_printf("to 障碍");
|
||||
set_speed = set_speed4;
|
||||
start_dis = 0;
|
||||
PID_SetTunings(&far_angle_pid, za_Kp, za_Ki, za_Kd);
|
||||
PID_SetTunings(&far_gyro_pid, zg_Kp, zg_Ki, zg_Kd);
|
||||
PID_SetTunings(&pos_pid, zp_Kp, zp_Ki, zp_Kd);
|
||||
}
|
||||
|
||||
if (in_state == 1) {
|
||||
if (fabs(in_pos) <= 12.0f) {
|
||||
set_speed = set_speed0 - fabs(rate_K1 * myclip_f(in_pos, -50.f, 50.f));
|
||||
} else {
|
||||
set_speed = set_speed0 - fabs(rate_K2 * myclip_f(in_pos, -50.f, 50.f));
|
||||
}
|
||||
}
|
||||
// 记录上一次状态
|
||||
last_state = in_state;
|
||||
// pid计算
|
||||
if (cnt1 >= 2) {
|
||||
PID_Compute(&far_gyro_pid);
|
||||
|
||||
if (cnt1 >= 10) {
|
||||
in_speed = -1 * sport_get_speed();
|
||||
PID_Compute(&speed_pid);
|
||||
|
||||
PID_Compute(&near_pos_pid);
|
||||
|
||||
cnt1 = 0;
|
||||
}
|
||||
if (cnt2 >= 20) {
|
||||
if (cnt2 >= 10) {
|
||||
in_speed = sport_get_speed();
|
||||
cnt2 = 0;
|
||||
PID_Compute(&far_angle_pid);
|
||||
}
|
||||
pwm_duty_ls = (uint32_t)myclip_f(-1.5f * out_pos + out_gyro, 0.0f, 8000.f);
|
||||
pwm_duty_rs = (uint32_t)myclip_f(1.5f * out_pos - out_gyro, 0.0f, 8000.f);
|
||||
pwm_duty_lb = (uint32_t)myclip_f(1.f * out_speed + out_gyro, 0.0f, 8000.f);
|
||||
pwm_duty_rb = (uint32_t)myclip_f(1.f * out_speed - out_gyro, 0.0f, 8000.f);
|
||||
if (cnt5 >= 20) {
|
||||
|
||||
by_pwm_power_duty((int32_t)pwm_duty_ls, (int32_t)pwm_duty_rs, (int32_t)pwm_duty_lb, (int32_t)pwm_duty_rb);
|
||||
PID_Compute(&pos_pid);
|
||||
PID_Compute(&speed_pid);
|
||||
cnt5 = 0;
|
||||
}
|
||||
// 并级pid,限幅
|
||||
pwm_duty_ls = (int32_t)myclip_f(240 - out_pos, 100.0f, 500.f);
|
||||
pwm_duty_rs = (int32_t)myclip_f(240 + out_pos, 100.0f, 500.f);
|
||||
// 并级pid的缺点补偿
|
||||
if (out_speed >= 1000) {
|
||||
pwm_duty_lb = (int32_t)myclip_f(out_speed + out_gyro, 1000.0f, 3000.f);
|
||||
pwm_duty_rb = (int32_t)myclip_f(out_speed - out_gyro, 1000.0f, 3000.f);
|
||||
} else {
|
||||
pwm_duty_lb = (int32_t)myclip_f(out_speed + 4 * out_gyro, 1000.0f, 3000.f);
|
||||
pwm_duty_rb = (int32_t)myclip_f(out_speed - 4 * out_gyro, 1000.0f, 3000.f);
|
||||
}
|
||||
|
||||
if (pwm_duty_lb - last_lb > 1000) {
|
||||
pwm_duty_lb = (pwm_duty_lb + last_lb) / 2;
|
||||
}
|
||||
if (pwm_duty_rb - last_rb > 1000) {
|
||||
pwm_duty_rb = (pwm_duty_rb + last_rb) / 2;
|
||||
}
|
||||
|
||||
last_rb = pwm_duty_rb;
|
||||
last_lb = pwm_duty_lb;
|
||||
|
||||
by_pwm_power_duty(500 + pwm_duty_ls, 500 + pwm_duty_rs, 3000 + pwm_duty_lb, 3000 + pwm_duty_rb);
|
||||
} else {
|
||||
by_pwm_power_duty(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
/* 升力风扇设置 */
|
||||
if (bt_fly_flag == 0) {
|
||||
by_pwm_update_duty(0 + 500, 0 + 500);
|
||||
} else {
|
||||
///////////////////////////////////////////////////* 升力风扇设置 */ /////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
if (bt_fly_flag == 1) {
|
||||
by_pwm_update_duty(bt_fly + 500, bt_fly + 500);
|
||||
if (bt_run_flag == 0) {
|
||||
// 测试状态
|
||||
if (1 == go_cnt) {
|
||||
by_pwm_power_duty(600, 600, 3000, 3000);
|
||||
} else if (2 == go_cnt) {
|
||||
cnt3++;
|
||||
if (cnt3 < 2000) {
|
||||
by_pwm_power_duty(600, 600, 3000, 3000);
|
||||
} else if (cnt3 >= 2000 && cnt3 < 3000) {
|
||||
by_pwm_power_duty(600, 600, 4000, 4000);
|
||||
} else if (cnt3 >= 3000) {
|
||||
bt_run_flag = 1;
|
||||
go_cnt = 3;
|
||||
cnt3 = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
by_pwm_update_duty(500, 500);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,28 +337,23 @@ void sport_pid_init()
|
||||
/* 角度控制 */
|
||||
PID(&far_angle_pid, &in_angle, &out_angle, &set_angle, an_Kp1, an_Ki1, an_Kd1, _PID_P_ON_E, _PID_CD_REVERSE);
|
||||
PID_SetMode(&far_angle_pid, _PID_MODE_AUTOMATIC);
|
||||
PID_SetSampleTime(&far_angle_pid, 20);
|
||||
PID_SetOutputLimits(&far_angle_pid, -3000.0f, 3000.0f);
|
||||
// PID_Init(&far_angle_pid);
|
||||
PID_SetSampleTime(&far_angle_pid, 10);
|
||||
PID_SetOutputLimits(&far_angle_pid, -6000.0f, 6000.0f);
|
||||
// 侧面位置环
|
||||
PID(&pos_pid, &in_angle, &out_pos, &set_pos, po_Kp1, po_Ki1, po_Kd1, _PID_P_ON_E, _PID_CD_REVERSE);
|
||||
PID_SetMode(&pos_pid, _PID_MODE_AUTOMATIC);
|
||||
PID_SetSampleTime(&pos_pid, 20);
|
||||
PID_SetOutputLimits(&pos_pid, -260.0f, 260.0f);
|
||||
|
||||
/* 角速度控制 */
|
||||
PID(&far_gyro_pid, &in_gyro, &out_gyro, &out_angle, gy_Kp1, gy_Ki1, gy_Kd1, _PID_P_ON_E, _PID_CD_REVERSE);
|
||||
PID(&far_gyro_pid, &in_gyro, &out_gyro, &out_angle, gy_Kp1, gy_Ki1, gy_Kd1, _PID_P_ON_E, _PID_CD_REVERSE); // m是增量
|
||||
PID_SetMode(&far_gyro_pid, _PID_MODE_AUTOMATIC);
|
||||
PID_SetSampleTime(&far_gyro_pid, 1);
|
||||
PID_SetOutputLimits(&far_gyro_pid, -4000.0f, 4000.0f);
|
||||
// PID_Init(&far_gyro_pid);
|
||||
|
||||
/* 近点控制 */
|
||||
PID(&near_pos_pid, &in_pos, &out_pos, &set_pos, po_Kp1, po_Ki1, po_Kd1, _PID_P_ON_E, _PID_CD_DIRECT);
|
||||
PID_SetMode(&near_pos_pid, _PID_MODE_AUTOMATIC);
|
||||
PID_SetSampleTime(&near_pos_pid, 10);
|
||||
PID_SetOutputLimits(&near_pos_pid, -4000.0f, 4000.0f);
|
||||
// PID_Init(&near_pos_pid);
|
||||
PID_SetSampleTime(&far_gyro_pid, 20);
|
||||
PID_SetOutputLimits(&far_gyro_pid, -2100.0f, 2100.0f);
|
||||
|
||||
/* 速度控制 */
|
||||
PID(&speed_pid, &in_speed, &out_speed, &set_speed1, sp_Kp, sp_Ki, sp_Kd, _PID_P_ON_E, _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_SetSampleTime(&speed_pid, 10);
|
||||
PID_SetOutputLimits(&speed_pid, 0.0f, 2000.0f);
|
||||
// PID_Init(&speed_pid);
|
||||
PID_SetSampleTime(&speed_pid, 20);
|
||||
PID_SetOutputLimits(&speed_pid, -0.0f, 2500.0f);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,9 @@ extern float an_Kd1;
|
||||
extern float in_angle;
|
||||
extern float set_angle;
|
||||
extern float out_angle;
|
||||
|
||||
extern float cn_Kp1;
|
||||
extern float cn_Ki1;
|
||||
extern float cn_Kd1;
|
||||
extern float gy_Kp1;
|
||||
extern float gy_Ki1;
|
||||
extern float gy_Kd1;
|
||||
@@ -22,17 +24,28 @@ extern float gy_Kd0;
|
||||
extern float in_gyro;
|
||||
extern float out_gyro;
|
||||
extern float set_gyro;
|
||||
|
||||
extern float po_Kp1;
|
||||
extern float po_Ki1;
|
||||
extern float po_Kd1;
|
||||
extern float po_Kp0;
|
||||
extern float po_Ki0;
|
||||
extern float po_Kd0;
|
||||
extern float yu_Kp0;
|
||||
extern float yu_Ki0;
|
||||
extern float yu_Kd0;
|
||||
extern float in_pos;
|
||||
extern float out_pos;
|
||||
extern float set_pos;
|
||||
extern float ygy_Kp0;
|
||||
extern float ygy_Ki0;
|
||||
extern float ygy_Kd0;
|
||||
extern float za_Kp;
|
||||
extern float za_Ki;
|
||||
extern float za_Kd;
|
||||
extern float zg_Kp;
|
||||
extern float zg_Ki;
|
||||
extern float zg_Kd;
|
||||
|
||||
extern float zp_Kp;
|
||||
extern float zp_Ki;
|
||||
extern float zp_Kd;
|
||||
extern float sp_Kp;
|
||||
extern float sp_Ki;
|
||||
extern float sp_Kd;
|
||||
@@ -40,13 +53,30 @@ extern float in_speed;
|
||||
extern float out_speed;
|
||||
extern float set_speed0;
|
||||
extern float set_speed1;
|
||||
extern uint32_t pwm_duty_ls;
|
||||
extern uint32_t pwm_duty_rs;
|
||||
extern uint32_t pwm_duty_lb;
|
||||
extern uint32_t pwm_duty_rb;
|
||||
|
||||
extern float set_speed2;
|
||||
extern float set_speed3;
|
||||
extern float set_speed;
|
||||
extern float set_speed4;
|
||||
extern float last_angle;
|
||||
extern float yuc_Kp;
|
||||
extern float rate_K1;
|
||||
extern float rate_K2;
|
||||
extern float start_dis;
|
||||
extern float set_dis;
|
||||
extern int32_t pwm_duty_ls;
|
||||
extern int32_t pwm_duty_rs;
|
||||
extern int32_t pwm_duty_lb;
|
||||
extern int32_t pwm_duty_rb;
|
||||
extern uint8_t go_cnt;
|
||||
extern uint8_t in_state;
|
||||
extern uint8_t in_stop;
|
||||
extern float bug_sw;
|
||||
extern float out_sw;
|
||||
extern float sho_sw;
|
||||
extern uint8_t bug_show_flag;
|
||||
extern uint8_t out_show_flag;
|
||||
extern uint8_t up_show_flag;
|
||||
extern uint8_t finish_show_flag;
|
||||
void sport_pid_init();
|
||||
void sport_motion(void);
|
||||
#endif
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "./page/page.h"
|
||||
#include "zf_common_headfile.h"
|
||||
#include "jj_motion.h"
|
||||
#include "jj_blueteeth.h"
|
||||
|
||||
PARAM_INFO Param_Data[DATA_NUM];
|
||||
soft_iic_info_struct eeprom_param;
|
||||
@@ -16,25 +17,23 @@ TYPE_UNION temp_frame_param[20];
|
||||
void jj_param_eeprom_init(void)
|
||||
{
|
||||
soft_iic_init(&eeprom_param, K24C02_DEV_ADDR, K24C02_SOFT_IIC_DELAY, K24C02_SCL_PIN, K24C02_SDA_PIN); // eeprom初始化
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
PARAM_REG(angle_Kp0, &an_Kp0, EFLOAT, 1, "an_P0:"); // 注冊
|
||||
PARAM_REG(angle_Ki0, &an_Ki0, EFLOAT, 1, "an_I0:"); // 注冊
|
||||
PARAM_REG(angle_Kd0, &an_Kd0, EFLOAT, 1, "an_D0:");
|
||||
|
||||
PARAM_REG(gyro_Kp0, &gy_Kp0, EFLOAT, 1, "gy_P0:"); // 注冊
|
||||
PARAM_REG(gyro_Ki0, &gy_Ki0, EFLOAT, 1, "gy_I0:"); // 注冊
|
||||
PARAM_REG(gyro_Kd0, &gy_Kd0, EFLOAT, 1, "gy_D0:");
|
||||
PARAM_REG(gyro_Kd0, &rate_K2, EFLOAT, 1, "ra_K2:");
|
||||
|
||||
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(can_Kp1, &cn_Kp1, EFLOAT, 1, "cn_P1:"); // 注冊
|
||||
PARAM_REG(can_Ki1, &yuc_Kp, EFLOAT, 1, "yu_P1:"); // 注冊
|
||||
PARAM_REG(can_Kd1, &rate_K1, EFLOAT, 1, "ra_K1:");
|
||||
|
||||
PARAM_REG(pos_Kp0, &po_Kp0, EFLOAT, 1, "po_P0:"); // 注冊
|
||||
PARAM_REG(pos_Ki0, &po_Ki0, EFLOAT, 1, "po_I0:"); // 注冊
|
||||
PARAM_REG(pos_Kd0, &po_Kd0, EFLOAT, 1, "po_D0:");
|
||||
PARAM_REG(fly_pwm, &bt_fly, EFLOAT, 1, "fly:");
|
||||
|
||||
PARAM_REG(param_set_speed0, &set_speed0, EFLOAT, 1, "rate0:");
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
PARAM_REG(angle_Kp1, &an_Kp1, EFLOAT, 1, "an_P1:"); // 注冊
|
||||
PARAM_REG(angle_Ki1, &an_Ki1, EFLOAT, 1, "an_I1:"); // 注冊
|
||||
PARAM_REG(angle_Kd1, &an_Kd1, EFLOAT, 1, "an_D1:");
|
||||
@@ -48,6 +47,40 @@ void jj_param_eeprom_init(void)
|
||||
PARAM_REG(pos_Kd1, &po_Kd1, EFLOAT, 1, "po_D1:");
|
||||
|
||||
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:");
|
||||
PARAM_REG(param_set_speed3, &set_speed3, EFLOAT, 1, "rate3:");
|
||||
/////////////////////////////////////////////////////////////
|
||||
PARAM_REG(zhan_Kp, &za_Kp, EFLOAT, 1, "an_P:"); // 注冊
|
||||
PARAM_REG(zhan_Ki, &za_Ki, EFLOAT, 1, "an_I:"); // 注冊
|
||||
PARAM_REG(zhan_Kd, &za_Kd, EFLOAT, 1, "an_D:");
|
||||
|
||||
PARAM_REG(zhgy_Kp, &zg_Kp, EFLOAT, 1, "gy_P1:"); // 注冊
|
||||
PARAM_REG(zhgy_Ki, &zg_Ki, EFLOAT, 1, "gy_I1:"); // 注冊
|
||||
PARAM_REG(zhgy_Kd, &zg_Kd, EFLOAT, 1, "gy_D1:");
|
||||
|
||||
PARAM_REG(zhpo_Kp, &zp_Kp, EFLOAT, 1, "po_P1:"); // 注冊
|
||||
PARAM_REG(zhpo_Ki, &zp_Ki, EFLOAT, 1, "po_I1:"); // 注冊
|
||||
PARAM_REG(zhpo_Kd, &zp_Kd, EFLOAT, 1, "po_D1:");
|
||||
|
||||
PARAM_REG(param_set_speed4, &set_speed4, EFLOAT, 1, "rate4:");
|
||||
|
||||
PARAM_REG(bug_stop, &bug_sw, EFLOAT, 1, "bug:"); // 注冊
|
||||
PARAM_REG(out_stop, &out_sw, EFLOAT, 1, "out:"); // 注冊
|
||||
PARAM_REG(shock_stop, &sho_sw, EFLOAT, 1, "shock:");
|
||||
PARAM_REG(dis, &set_dis, EFLOAT, 1, "dis:");
|
||||
jj_param_read(); // 注冊
|
||||
}
|
||||
/**
|
||||
|
||||
@@ -17,32 +17,72 @@
|
||||
typedef enum {
|
||||
|
||||
Page1_head = 0,
|
||||
|
||||
// 完道pid
|
||||
angle_Kp0 = Page1_head,
|
||||
angle_Ki0,
|
||||
angle_Kd0,
|
||||
|
||||
gyro_Kp0,
|
||||
gyro_Ki0,
|
||||
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,
|
||||
angle_Kp1 = Page2_head,
|
||||
angle_Ki1,
|
||||
angle_Kd1,
|
||||
|
||||
gyro_Kp1,
|
||||
gyro_Ki1,
|
||||
gyro_Kd1,
|
||||
|
||||
pos_Kp1,
|
||||
pos_Ki1,
|
||||
pos_Kd1,
|
||||
|
||||
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,
|
||||
param_set_speed3,
|
||||
|
||||
Page4_head,
|
||||
zhgy_Kp = Page4_head,
|
||||
zhgy_Ki,
|
||||
zhgy_Kd,
|
||||
|
||||
zhan_Kp,
|
||||
zhan_Ki,
|
||||
zhan_Kd,
|
||||
|
||||
zhpo_Kp,
|
||||
zhpo_Ki,
|
||||
zhpo_Kd,
|
||||
|
||||
param_set_speed4,
|
||||
|
||||
Page5_head,
|
||||
bug_stop = Page5_head,
|
||||
shock_stop,
|
||||
out_stop,
|
||||
dis,
|
||||
|
||||
DATA_IN_FLASH_NUM,
|
||||
|
||||
|
||||
13
app/jj_voltage.c
Normal file
13
app/jj_voltage.c
Normal file
@@ -0,0 +1,13 @@
|
||||
#include "jj_voltage.h"
|
||||
#include "zf_driver_adc.h"
|
||||
|
||||
#define GET_VOL_PIN ADC2_IN5_A5
|
||||
float now_vol;
|
||||
void vol_init(void)
|
||||
{
|
||||
adc_init(GET_VOL_PIN,ADC_12BIT);
|
||||
}
|
||||
void get_vol()
|
||||
{
|
||||
now_vol=0.003377f*adc_convert(GET_VOL_PIN)+0.36f;
|
||||
}
|
||||
9
app/jj_voltage.h
Normal file
9
app/jj_voltage.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#ifndef _JJ_VOLTAGE_H_
|
||||
#define _JJ_VOLTAGE_H_
|
||||
|
||||
#include "stdio.h"
|
||||
#include "zf_driver_uart.h"
|
||||
extern float now_vol;
|
||||
void vol_init();
|
||||
void get_vol();
|
||||
#endif
|
||||
26
app/main.c
26
app/main.c
@@ -28,6 +28,7 @@
|
||||
#include "jj_param.h"
|
||||
#include "jj_motion.h"
|
||||
#include "jj_blueteeth.h"
|
||||
#include "jj_voltage.h"
|
||||
|
||||
#include "by_imu.h"
|
||||
#include "by_vofa.h"
|
||||
@@ -35,29 +36,33 @@
|
||||
#include "by_frame.h"
|
||||
#include "by_rt_button.h"
|
||||
#include "by_fan_control.h"
|
||||
uint8_t last_state;
|
||||
|
||||
uint32_t send_reset = 0x0D;
|
||||
int main(void)
|
||||
{
|
||||
TYPE_UNION test_data[BY_FRAME_DATA_NUM];
|
||||
clock_init(SYSTEM_CLOCK_144M);
|
||||
system_delay_init();
|
||||
debug_init();
|
||||
|
||||
by_frame_init();
|
||||
for (int i = 0; i < 6; i++) {
|
||||
by_frame_send(&send_reset);
|
||||
}
|
||||
encoder_quad_init(TIM3_ENCOEDER, TIM3_ENCOEDER_MAP3_CH1_C6, TIM3_ENCOEDER_MAP3_CH2_C7);
|
||||
ips200_init(IPS200_TYPE_SPI);
|
||||
while (imu660ra_init())
|
||||
;
|
||||
while (imu660ra_init());
|
||||
jj_param_eeprom_init();
|
||||
jj_bt_init();
|
||||
vol_init();
|
||||
by_rb_init();
|
||||
// by_pwm_init();
|
||||
by_buzzer_init();
|
||||
by_frame_init();
|
||||
|
||||
by_pwm_init();
|
||||
|
||||
Page_Init();
|
||||
sport_pid_init();
|
||||
|
||||
pit_ms_init(TIM1_PIT, 1); // 运动解算,编码器
|
||||
pit_ms_init(TIM6_PIT, 1); // 运动解算,编码器
|
||||
|
||||
bt_printf("ok\r\n");
|
||||
|
||||
@@ -66,13 +71,10 @@ int main(void)
|
||||
Page_Run();
|
||||
by_frame_parse(&test_data[0].u32);
|
||||
jj_bt_run();
|
||||
in_pos = test_data[1].f32;
|
||||
last_angle=in_angle;
|
||||
in_pos = 1000.f * test_data[1].f32;
|
||||
in_angle = test_data[0].f32;
|
||||
in_state = test_data[2].u8[0];
|
||||
in_stop = test_data[2].u8[1];
|
||||
if (last_state != in_state) {
|
||||
bt_printf("changing to%u\r\n", in_state);
|
||||
}
|
||||
last_state = in_state;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,13 +124,14 @@ void Page_Run(void)
|
||||
void Page_Init(void)
|
||||
{
|
||||
PAGE_REG(page_menu);
|
||||
// PAGE_REG(page_rtcam);
|
||||
|
||||
PAGE_REG(page_param_pid0);
|
||||
PAGE_REG(page_param_pid1);
|
||||
// PAGE_REG(page_argv);
|
||||
// PAGE_REG(page_sys);
|
||||
// PAGE_REG(page_run);
|
||||
PAGE_REG(page_param_pid2);
|
||||
PAGE_REG(page_param_pid3);
|
||||
PAGE_REG(page_dparam);
|
||||
PAGE_REG(page_gocar);
|
||||
PAGE_REG(page_stopcar);
|
||||
Page_Shift(page_menu);
|
||||
|
||||
pagelist[now_page].SetupCallback(); // 先构建一遍
|
||||
|
||||
@@ -22,7 +22,12 @@ enum PageID {
|
||||
// page_rtcam,
|
||||
page_param_pid0,
|
||||
page_param_pid1,
|
||||
page_param_pid2,
|
||||
page_param_pid3,
|
||||
page_dparam,
|
||||
page_stopcar,
|
||||
page_gocar,
|
||||
|
||||
// page_argv,
|
||||
// page_sys,
|
||||
// page_run,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "page_ui_widget.h"
|
||||
#include "jj_motion.h"
|
||||
#include "page.h"
|
||||
|
||||
#include "jj_voltage.h"
|
||||
#include <math.h>
|
||||
|
||||
#define LINE_HEAD 0
|
||||
@@ -44,14 +44,14 @@ static void Loop()
|
||||
{
|
||||
ips200_show_string(0, 0, "sta:");
|
||||
ips200_show_float(80, 0, in_state, 4, 1);
|
||||
ips200_show_string(0, 20, "sto:");
|
||||
ips200_show_float(80, 20, in_stop, 4, 1);
|
||||
ips200_show_string(0, 20, "outsp:");
|
||||
ips200_show_float(80, 20, out_speed, 4, 1);
|
||||
ips200_show_string(0, 40, "angle");
|
||||
ips200_show_float(80, 40, in_angle, 4, 1);
|
||||
ips200_show_string(0, 60, "near");
|
||||
ips200_show_float(80, 60, in_pos, 4, 1);
|
||||
ips200_show_string(0, 80, "gyroz");
|
||||
ips200_show_float(80, 80, in_gyro, 4, 2);
|
||||
ips200_show_string(0, 60, "cal");
|
||||
ips200_show_float(80, 60, in_pos, 3, 5);
|
||||
ips200_show_string(0, 80, "accy");
|
||||
ips200_show_float(80, 80, (float)imu660ra_gyro_z, 4, 2);
|
||||
ips200_show_string(0, 100, "speed");
|
||||
ips200_show_float(80, 100, in_speed, 4, 4);
|
||||
ips200_show_string(0, 120, "outang");
|
||||
@@ -60,15 +60,31 @@ static void Loop()
|
||||
ips200_show_float(80, 140, out_gyro, 4, 1);
|
||||
ips200_show_string(0, 160, "outpos");
|
||||
ips200_show_float(80, 160, out_pos, 4, 1);
|
||||
|
||||
// ips200_show_string(0, 180, "ls");
|
||||
// ips200_show_float(80, 180, pwm_duty_ls, 4, 1);
|
||||
// ips200_show_string(0, 200, "rs");
|
||||
// ips200_show_float(80, 200, pwm_duty_rs, 4, 1);
|
||||
// ips200_show_string(0, 220, "lb");
|
||||
// ips200_show_float(80, 220, pwm_duty_lb, 4, 1);
|
||||
// ips200_show_string(100, 0, "rb");
|
||||
// ips200_show_float(180, 0, pwm_duty_rb, 4, 1);
|
||||
ips200_show_string(0, 180, "vol");
|
||||
ips200_show_float(80, 180, (float)now_vol, 4, 2);
|
||||
ips200_show_string(0, 200, "setsp");
|
||||
ips200_show_float(80, 200, set_speed, 4, 2);
|
||||
ips200_show_string(0, 220, "dis");
|
||||
ips200_show_float(80, 220, start_dis, 4, 2);
|
||||
if (up_show_flag == 1) {
|
||||
ips200_show_string(180, 200, "up ");
|
||||
} else if (out_show_flag == 1) {
|
||||
ips200_show_string(180, 200, "out ");
|
||||
} else if (bug_show_flag == 1) {
|
||||
ips200_show_string(180, 200, "bug ");
|
||||
} else if (finish_show_flag == 1) {
|
||||
ips200_show_string(180, 200, "finish");
|
||||
} else {
|
||||
ips200_show_string(180, 200, " ");
|
||||
}
|
||||
ips200_show_string(180, 0, "ls");
|
||||
ips200_show_float(220, 0, pwm_duty_ls, 4, 1);
|
||||
ips200_show_string(180, 20, "rs");
|
||||
ips200_show_float(220, 20, pwm_duty_rs, 4, 1);
|
||||
ips200_show_string(180, 40, "lb");
|
||||
ips200_show_float(220, 40, pwm_duty_lb, 4, 1);
|
||||
ips200_show_string(180, 60, "rb");
|
||||
ips200_show_float(220, 60, pwm_duty_rb, 4, 1);
|
||||
}
|
||||
/**
|
||||
* @brief 页面事件
|
||||
|
||||
131
app/page/page_gocar.c
Normal file
131
app/page/page_gocar.c
Normal file
@@ -0,0 +1,131 @@
|
||||
#include "zf_common_headfile.h"
|
||||
#include "page_ui_widget.h"
|
||||
#include "page.h"
|
||||
#include "by_frame.h"
|
||||
#include "jj_blueteeth.h"
|
||||
#include "jj_motion.h"
|
||||
|
||||
#define LINE_HEAD 1
|
||||
#define LINE_END 6
|
||||
|
||||
static char Text[] = "gocar";
|
||||
|
||||
static int8_t Curser = LINE_HEAD; // 定义光标位置
|
||||
static int8_t Curser_Last = LINE_HEAD; // 定义光标位置
|
||||
static int8_t last_go = 0;
|
||||
static int8_t last_cnt = 0;
|
||||
static int8_t last_fly = 0;
|
||||
/***************************************************************************************
|
||||
*
|
||||
* 以下为页面模板函数
|
||||
*
|
||||
***************************************************************************************/
|
||||
|
||||
/**
|
||||
* @brief 页面初始化事件
|
||||
* @param 无
|
||||
* @retval 无
|
||||
*/
|
||||
static void Setup()
|
||||
{
|
||||
|
||||
ips200_clear();
|
||||
ips200_show_string(0, 2, "gocar");
|
||||
Print_Curser(Curser, Curser_Last, RGB565_PURPLE);
|
||||
ips200_show_string(10, 200, "go_flag:");
|
||||
ips200_show_int(80, 200, go_cnt, 1);
|
||||
ips200_show_string(10, 180, "ru_flag:");
|
||||
ips200_show_int(80, 180, bt_run_flag, 1);
|
||||
ips200_show_string(10, 160, "fl_flag:");
|
||||
ips200_show_int(80, 160, bt_fly_flag, 1);
|
||||
|
||||
ips200_show_string(10, 18, "fan_test");
|
||||
ips200_show_string(10, 2 * 18, "run");
|
||||
ips200_show_string(10, 3 * 18, "fly_close");
|
||||
ips200_show_string(10, 4 * 18, "run_close");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 页面退出事件
|
||||
* @param 无
|
||||
* @retval 无
|
||||
*/
|
||||
static void Exit()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 页面循环执行的内容
|
||||
* @param 无
|
||||
* @retval 无
|
||||
*/
|
||||
static void Loop()
|
||||
{
|
||||
if (last_cnt != go_cnt) {
|
||||
ips200_show_int(80, 200, go_cnt, 1);
|
||||
}
|
||||
last_cnt = go_cnt;
|
||||
if (last_go != bt_run_flag) {
|
||||
ips200_show_int(80, 180, bt_run_flag, 1);
|
||||
}
|
||||
last_go = bt_run_flag;
|
||||
if (last_fly != bt_fly_flag) {
|
||||
ips200_show_int(80, 160, bt_fly_flag, 1);
|
||||
}
|
||||
last_fly = bt_fly_flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 页面事件
|
||||
* @param btn:发出事件的按键
|
||||
* @param event:事件编号
|
||||
* @retval 无
|
||||
*/
|
||||
static void Event(page_event event)
|
||||
{
|
||||
Curser_Last = Curser;
|
||||
|
||||
if (page_event_forward == event) {
|
||||
Curser--; // 光标上移
|
||||
} else if (page_event_backward == event) {
|
||||
Curser++; // 光标下移
|
||||
} else if (page_event_press_short == event) {
|
||||
if (go_cnt == 1 && Curser == 1) {
|
||||
go_cnt = 0; // 起步拖动失败。重新开始
|
||||
} else if (go_cnt == 0 && Curser == 1) {
|
||||
go_cnt = 1;
|
||||
bt_fly_flag = 1;
|
||||
}
|
||||
if (go_cnt == 1 && Curser == 2) {
|
||||
go_cnt = 2;
|
||||
}
|
||||
if (Curser == 3 && bt_fly_flag != 0) {
|
||||
bt_fly_flag = 0;
|
||||
}
|
||||
if (Curser == 4 && bt_run_flag != 0) {
|
||||
bt_run_flag = 0;
|
||||
go_cnt = 0;
|
||||
}
|
||||
|
||||
} else if (page_event_press_long == event) {
|
||||
Page_Shift(page_menu);
|
||||
}
|
||||
|
||||
if (Curser < LINE_HEAD) {
|
||||
Curser = LINE_END;
|
||||
} else if (Curser > LINE_END) {
|
||||
Curser = LINE_HEAD;
|
||||
}
|
||||
|
||||
Print_Curser(Curser, Curser_Last, RGB565_PURPLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 页面注册函数
|
||||
*
|
||||
* @param pageID
|
||||
*/
|
||||
void PageRegister_page_gocar(unsigned char pageID)
|
||||
{
|
||||
Page_Register(pageID, Text, Setup, Loop, Exit, Event);
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
#include "zf_common_headfile.h"
|
||||
#include "page_ui_widget.h"
|
||||
#include "page.h"
|
||||
#include "by_frame.h"
|
||||
#include "jj_blueteeth.h"
|
||||
#include "jj_motion.h"
|
||||
|
||||
#define LINE_HEAD 1
|
||||
#define LINE_END 7
|
||||
@@ -9,6 +12,7 @@ static char Text[] = "Menu";
|
||||
|
||||
static int8_t Curser = LINE_HEAD; // 定义光标位置
|
||||
static int8_t Curser_Last = LINE_HEAD; // 定义光标位置
|
||||
|
||||
static void Print_Menu_p(void);
|
||||
/***************************************************************************************
|
||||
*
|
||||
@@ -23,6 +27,7 @@ static void Print_Menu_p(void);
|
||||
*/
|
||||
static void Setup()
|
||||
{
|
||||
|
||||
ips200_clear();
|
||||
Print_Menu_p();
|
||||
Print_Curser(Curser, Curser_Last, RGB565_PURPLE);
|
||||
@@ -64,6 +69,7 @@ static void Event(page_event event)
|
||||
if (page_max > Curser && page_menu < Curser) {
|
||||
Page_Shift(Curser); // 切换到光标选中的页面
|
||||
}
|
||||
} else if (page_event_press_long == event) {
|
||||
}
|
||||
|
||||
if (Curser < LINE_HEAD) {
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
#include "page.h"
|
||||
#include <math.h>
|
||||
|
||||
#define LINE_HEAD 0
|
||||
#define LINE_END Page2_head - 1
|
||||
static char Text[] = "Param_pid0";
|
||||
#define LINE_HEAD 1
|
||||
#define LINE_END Page2_head
|
||||
static char Text[] = "turn_pid";
|
||||
static int event_flag = 0;
|
||||
static int index_power = 0;
|
||||
static int8_t Curser = LINE_HEAD; // 定义光标位置
|
||||
@@ -25,13 +25,14 @@ static void jj_param_show();
|
||||
static void Setup()
|
||||
{
|
||||
ips200_clear();
|
||||
ips200_show_string(0, 2, "turn");
|
||||
Print_Curser(Curser, Curser_Last, RGB565_PURPLE);
|
||||
for (int16 i = 0; i <= LINE_END; i++) {
|
||||
ips200_show_string(0, i * 18 + 2, Param_Data[i].text);
|
||||
for (int16 i = 0; i < LINE_END; i++) {
|
||||
ips200_show_string(0, i * 18 + 20, Param_Data[i].text);
|
||||
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)
|
||||
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);
|
||||
}
|
||||
@@ -87,25 +88,25 @@ static void Event(page_event event)
|
||||
Print_Curser(Curser, Curser_Last, RGB565_PURPLE);
|
||||
} else if (1 == event_flag) {
|
||||
if (page_event_forward == event) {
|
||||
if (Param_Data[Curser].type == EFLOAT) {
|
||||
*((float *)(Param_Data[Curser].p_data)) += powf(10.0f, (float)index_power);
|
||||
} else if (Param_Data[Curser].type == EINT32) {
|
||||
*((int32 *)(Param_Data[Curser].p_data)) += 1;
|
||||
} else if (Param_Data[Curser].type == EUINT32) {
|
||||
*((uint32 *)(Param_Data[Curser].p_data)) += 1;
|
||||
if (Param_Data[Curser - 1].type == EFLOAT) {
|
||||
*((float *)(Param_Data[Curser - 1].p_data)) += powf(10.0f, (float)index_power);
|
||||
} else if (Param_Data[Curser - 1].type == EINT32) {
|
||||
*((int32 *)(Param_Data[Curser - 1].p_data)) += 1;
|
||||
} else if (Param_Data[Curser - 1].type == EUINT32) {
|
||||
*((uint32 *)(Param_Data[Curser - 1].p_data)) += 1;
|
||||
}
|
||||
} else if (page_event_backward == event) {
|
||||
if (Param_Data[Curser].type == EFLOAT) {
|
||||
*((float *)(Param_Data[Curser].p_data)) -= powf(10.0f, (float)index_power);
|
||||
} else if (Param_Data[Curser].type == EINT32) {
|
||||
*((int32 *)(Param_Data[Curser].p_data)) -= 1;
|
||||
} else if (Param_Data[Curser].type == EUINT32) {
|
||||
*((uint32 *)(Param_Data[Curser].p_data)) -= 1;
|
||||
if (Param_Data[Curser - 1].type == EFLOAT) {
|
||||
*((float *)(Param_Data[Curser - 1].p_data)) -= powf(10.0f, (float)index_power);
|
||||
} else if (Param_Data[Curser - 1].type == EINT32) {
|
||||
*((int32 *)(Param_Data[Curser - 1].p_data)) -= 1;
|
||||
} else if (Param_Data[Curser - 1].type == EUINT32) {
|
||||
*((uint32 *)(Param_Data[Curser - 1].p_data)) -= 1;
|
||||
}
|
||||
} else if (page_event_press_short == event) {
|
||||
index_power++;
|
||||
if (index_power > 2) {
|
||||
index_power = -2;
|
||||
index_power--;
|
||||
if (index_power < -2) {
|
||||
index_power = 2;
|
||||
}
|
||||
ips200_show_int(100, 2, index_power, 5);
|
||||
} else if (page_event_press_long == event) {
|
||||
@@ -117,12 +118,12 @@ static void Event(page_event event)
|
||||
}
|
||||
static void jj_param_show()
|
||||
{
|
||||
if (EINT32 == Param_Data[Curser].type)
|
||||
ips200_show_int(50, Curser * 18 + 2, *((int32 *)(Param_Data[Curser].p_data)), 5);
|
||||
else if (EUINT32 == Param_Data[Curser].type)
|
||||
ips200_show_uint(50, Curser * 18 + 2, *((int32 *)(Param_Data[Curser].p_data)), 5);
|
||||
else if (EFLOAT == Param_Data[Curser].type)
|
||||
ips200_show_float(50, Curser * 18 + 2, *((float *)(Param_Data[Curser].p_data)), 4, 5);
|
||||
if (EINT32 == Param_Data[Curser - 1].type)
|
||||
ips200_show_int(50, Curser * 18 + 2, *((int32 *)(Param_Data[Curser - 1].p_data)), 5);
|
||||
else if (EUINT32 == Param_Data[Curser - 1].type)
|
||||
ips200_show_uint(50, Curser * 18 + 2, *((int32 *)(Param_Data[Curser - 1].p_data)), 5);
|
||||
else if (EFLOAT == Param_Data[Curser - 1].type)
|
||||
ips200_show_float(50, Curser * 18 + 2, *((float *)(Param_Data[Curser - 1].p_data)), 4, 5);
|
||||
}
|
||||
/**
|
||||
* @brief 页面注册函数
|
||||
|
||||
@@ -4,9 +4,10 @@
|
||||
#include "page.h"
|
||||
#include <math.h>
|
||||
|
||||
#define LINE_HEAD 0
|
||||
#define LINE_END DATA_IN_FLASH_NUM - 1 - Page2_head
|
||||
static char Text[] = "Param_pid1";
|
||||
#define LINE_HEAD 1
|
||||
#define LINE_END Page3_head - Page2_head
|
||||
#define Strat_param Page2_head
|
||||
static char Text[] = "stra_pid";
|
||||
static int event_flag = 0;
|
||||
static int index_power = 0;
|
||||
static int8_t Curser = LINE_HEAD; // 定义光标位置
|
||||
@@ -25,13 +26,14 @@ static void jj_param_show();
|
||||
static void Setup()
|
||||
{
|
||||
ips200_clear();
|
||||
ips200_show_string(0, 2, "straight");
|
||||
Print_Curser(Curser, Curser_Last, RGB565_PURPLE);
|
||||
for (int16 i = 0; i < 10; i++) {
|
||||
ips200_show_string(0, i * 18 + 2, Param_Data[i + 13].text);
|
||||
if (Param_Data[i + 13].type == EINT32)
|
||||
ips200_show_int(50, i * 18 + 2, *((int32 *)(Param_Data[i + 13].p_data)), 5);
|
||||
else if (Param_Data[i + 13].type == EFLOAT)
|
||||
ips200_show_float(50, i * 18 + 2, *((float *)(Param_Data[i + 13].p_data)), 4, 5);
|
||||
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);
|
||||
}
|
||||
@@ -87,25 +89,25 @@ static void Event(page_event event)
|
||||
Print_Curser(Curser, Curser_Last, RGB565_PURPLE);
|
||||
} else if (1 == event_flag) {
|
||||
if (page_event_forward == event) {
|
||||
if (Param_Data[Curser + 13].type == EFLOAT) {
|
||||
*((float *)(Param_Data[Curser + 13].p_data)) += powf(10.0f, (float)index_power);
|
||||
} else if (Param_Data[Curser + 13].type == EINT32) {
|
||||
*((int32 *)(Param_Data[Curser + 13].p_data)) += 1;
|
||||
} else if (Param_Data[Curser + 13].type == EUINT32) {
|
||||
*((uint32 *)(Param_Data[Curser + Page2_head].p_data)) += 1;
|
||||
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 + Page2_head].type == EFLOAT) {
|
||||
*((float *)(Param_Data[Curser + Page2_head].p_data)) -= powf(10.0f, (float)index_power);
|
||||
} else if (Param_Data[Curser + Page2_head].type == EINT32) {
|
||||
*((int32 *)(Param_Data[Curser + Page2_head].p_data)) -= 1;
|
||||
} else if (Param_Data[Curser + Page2_head].type == EUINT32) {
|
||||
*((uint32 *)(Param_Data[Curser + Page2_head].p_data)) -= 1;
|
||||
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;
|
||||
index_power--;
|
||||
if (index_power < -2) {
|
||||
index_power = 2;
|
||||
}
|
||||
ips200_show_int(100, 2, index_power, 5);
|
||||
} else if (page_event_press_long == event) {
|
||||
@@ -117,12 +119,12 @@ static void Event(page_event event)
|
||||
}
|
||||
static void jj_param_show()
|
||||
{
|
||||
if (EINT32 == Param_Data[Curser + 13].type)
|
||||
ips200_show_int(50, Curser * 18 + 2, *((int32 *)(Param_Data[Curser + 13].p_data)), 5);
|
||||
else if (EUINT32 == Param_Data[Curser + 13].type)
|
||||
ips200_show_uint(50, Curser * 18 + 2, *((int32 *)(Param_Data[Curser + 13].p_data)), 5);
|
||||
else if (EFLOAT == Param_Data[Curser + 13].type)
|
||||
ips200_show_float(50, Curser * 18 + 2, *((float *)(Param_Data[Curser + 13].p_data)), 4, 5);
|
||||
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 页面注册函数
|
||||
|
||||
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 Page4_head - 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);
|
||||
}
|
||||
137
app/page/page_param_pid3.c
Normal file
137
app/page/page_param_pid3.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 Page5_head - Page4_head
|
||||
#define Strat_param Page4_head
|
||||
static char Text[] = "barr_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, "barrir");
|
||||
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_pid3(unsigned char pageID)
|
||||
{
|
||||
Page_Register(pageID, Text, Setup, Loop, Exit, Event);
|
||||
}
|
||||
137
app/page/page_stopcar.c
Normal file
137
app/page/page_stopcar.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 - Page5_head
|
||||
#define Strat_param Page5_head
|
||||
static char Text[] = "stop_sw";
|
||||
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,"stopsw");
|
||||
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_stopcar(unsigned char pageID)
|
||||
{
|
||||
Page_Register(pageID, Text, Setup, Loop, Exit, Event);
|
||||
}
|
||||
@@ -266,7 +266,7 @@ uint8 imu660ra_init(void)
|
||||
}
|
||||
imu660ra_write_register(IMU660RA_PWR_CTRL, 0x0E); // 开启性能模式 使能陀螺仪、加速度、温度传感器
|
||||
imu660ra_write_register(IMU660RA_ACC_CONF, 0xA7); // 加速度采集配置 性能模式 正常采集 50Hz 采样频率
|
||||
imu660ra_write_register(IMU660RA_GYR_CONF, 0xAC); // 陀螺仪采集配置 性能模式 正常采集 1600Hz 采样频率
|
||||
imu660ra_write_register(IMU660RA_GYR_CONF, 0xA9); // 陀螺仪采集配置 性能模式 正常采集 1600Hz 采样频率
|
||||
|
||||
// IMU660RA_ACC_SAMPLE 寄存器
|
||||
// 设置为 0x00 加速度计量程为 ±2 g 获取到的加速度计数据除以 16384 可以转化为带物理单位的数据 单位 g(m/s^2)
|
||||
|
||||
Reference in New Issue
Block a user