fix: 修复蜂鸣器bug及日常更新
This commit is contained in:
@@ -10,6 +10,7 @@ uint32_t a[40] = {0};
|
||||
|
||||
void queue_init(void)
|
||||
{
|
||||
queue_long = 0;
|
||||
memset(a, 0, sizeof(a));
|
||||
}
|
||||
|
||||
@@ -22,7 +23,7 @@ void queue_add_element(int element)
|
||||
}
|
||||
void queue_pop_element(void)
|
||||
{
|
||||
memmove(a, &a[1], queue_long * sizeof(a));
|
||||
memmove(a, &a[1], (queue_long - 1) * sizeof(a[0]));
|
||||
if (queue_long > 0) {
|
||||
queue_long--;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ float gy_Ki = 0.0f;
|
||||
float gy_Kd = 0.0f;
|
||||
float in_gyro;
|
||||
float out_gyro;
|
||||
//float set_gyro = 0.0f;
|
||||
// float set_gyro = 0.0f;
|
||||
|
||||
float po_Kp = 1.0f;
|
||||
float po_Ki = 0.0f;
|
||||
@@ -47,16 +47,18 @@ void sport_motion(void)
|
||||
{
|
||||
|
||||
cnt1++;
|
||||
in_gyro = imu660ra_gyro_z; // 陀螺仪输入
|
||||
in_angle = 0; // 图像远端输入
|
||||
in_pos = 0; // 图像近端输入
|
||||
in_speed = encoder_get_count(TIM5_ENCOEDER) / 1024 / 0.01 * 0.25; // 速度输入,m/s
|
||||
encoder_clear_count(TIM5_ENCOEDER); // 清除计数
|
||||
in_gyro = imu660ra_gyro_z; // 陀螺仪输入
|
||||
// in_angle = 0; // 图像远端输入
|
||||
// in_pos = 0; // 图像近端输入
|
||||
// 清除计数
|
||||
PID_Compute(&far_gyro_pid);
|
||||
|
||||
if (cnt1 >= 10) {
|
||||
PID_Compute(&far_angle_pid);
|
||||
PID_Compute(&speed_pid);
|
||||
in_speed = encoder_get_count(TIM5_ENCOEDER); // 速度输入,m/s
|
||||
// printf("rate:%d\r\n", (int16)in_speed);
|
||||
encoder_clear_count(TIM5_ENCOEDER);
|
||||
cnt1 = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
PARAM_INFO Param_Data[DATA_NUM];
|
||||
soft_iic_info_struct eeprom_param;
|
||||
TYPE_UNION iic_buffer[DATA_IN_FLASH_NUM];
|
||||
TYPE_UNION temp_frame_param[20];
|
||||
|
||||
/**
|
||||
* @brief 参数初始化注册
|
||||
|
||||
@@ -63,6 +63,7 @@ typedef struct {
|
||||
extern soft_iic_info_struct eeprom_param;
|
||||
extern PARAM_INFO Param_Data[DATA_NUM];
|
||||
extern TYPE_UNION iic_buffer[DATA_IN_FLASH_NUM];
|
||||
extern TYPE_UNION temp_frame_param[20];
|
||||
void jj_param_eeprom_init(void);
|
||||
void jj_param_write(void);
|
||||
void jj_param_read(void);
|
||||
|
||||
12
app/main.c
12
app/main.c
@@ -41,7 +41,7 @@ int main(void)
|
||||
system_delay_init();
|
||||
debug_init();
|
||||
|
||||
encoder_dir_init(TIM5_ENCOEDER, TIM5_ENCOEDER_MAP0_CH1_A0, TIM5_ENCOEDER_MAP0_CH2_A1);
|
||||
encoder_quad_init(TIM5_ENCOEDER, TIM5_ENCOEDER_MAP0_CH1_A0, TIM5_ENCOEDER_MAP0_CH2_A1);
|
||||
ips200_init(IPS200_TYPE_SPI);
|
||||
while (imu660ra_init())
|
||||
;
|
||||
@@ -49,8 +49,8 @@ int main(void)
|
||||
jj_bt_init();
|
||||
by_rb_init();
|
||||
by_pwm_init();
|
||||
// by_buzzer_init();
|
||||
|
||||
by_buzzer_init();
|
||||
|
||||
by_tiny_frame_init();
|
||||
Page_Init();
|
||||
sport_pid_init();
|
||||
@@ -59,10 +59,12 @@ int main(void)
|
||||
pit_ms_init(TIM1_PIT, 1); // 运动解算,bianmaqi
|
||||
|
||||
printf("ok\r\n");
|
||||
|
||||
|
||||
while (1) {
|
||||
Page_Run();
|
||||
//by_buzzer_run();
|
||||
ips200_show_float(40, 40, in_angle, 4, 5);
|
||||
ips200_show_float(40, 60, in_pos, 4, 5);
|
||||
by_buzzer_run();
|
||||
jj_bt_run();
|
||||
by_tiny_frame_run();
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ static void Setup()
|
||||
else if (Param_Data[i].type == EFLOAT)
|
||||
ips200_show_float(50, i * 18 + 2, *((float *)(Param_Data[i].p_data)), 4, 5);
|
||||
}
|
||||
ips200_show_int(50, (DATA_IN_FLASH_NUM-1)* 18 + 2, index_power, 5);
|
||||
ips200_show_int(100, 2, index_power, 5);
|
||||
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ static void Event(page_event event)
|
||||
if (index_power > 2) {
|
||||
index_power = -2;
|
||||
}
|
||||
ips200_show_int(50, (DATA_NUM-1)* 18 + 2, index_power, 5);
|
||||
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);
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "by_tiny_frame_pack.h"
|
||||
|
||||
#include "jj_motion.h"
|
||||
#include "jj_param.h"
|
||||
|
||||
void by_tiny_frame_read_write_run(void)
|
||||
{
|
||||
@@ -35,15 +36,17 @@ void by_tiny_frame_read_write_handle(by_tf_parse_frame_t frame_s, uint8_t status
|
||||
case 0x06:
|
||||
// 添加写入接口,操作完成后应答
|
||||
switch (frame_pack_s.reg_addr) {
|
||||
case 0x00:
|
||||
in_angle = (float)frame_s.data;
|
||||
case 0x0000:
|
||||
temp_frame_param[0].u32 = frame_s.data;
|
||||
in_angle=temp_frame_param[0].f32;
|
||||
break;
|
||||
case 0x01:
|
||||
case 0x0001:
|
||||
in_pos = (float)frame_s.data;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
frame_pack_s.data=frame_s.data;
|
||||
by_tiny_frame_pack_send(&frame_pack_s);
|
||||
break;
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user