fix: 修复蜂鸣器bug及日常更新

This commit is contained in:
2024-03-03 19:23:21 +08:00
parent f1c0b63d21
commit ecfd586ca4
8 changed files with 28 additions and 18 deletions

View File

@@ -10,6 +10,7 @@ uint32_t a[40] = {0};
void queue_init(void) void queue_init(void)
{ {
queue_long = 0;
memset(a, 0, sizeof(a)); memset(a, 0, sizeof(a));
} }
@@ -22,7 +23,7 @@ void queue_add_element(int element)
} }
void queue_pop_element(void) 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) { if (queue_long > 0) {
queue_long--; queue_long--;
} }

View File

@@ -22,7 +22,7 @@ float gy_Ki = 0.0f;
float gy_Kd = 0.0f; float gy_Kd = 0.0f;
float in_gyro; float in_gyro;
float out_gyro; float out_gyro;
//float set_gyro = 0.0f; // float set_gyro = 0.0f;
float po_Kp = 1.0f; float po_Kp = 1.0f;
float po_Ki = 0.0f; float po_Ki = 0.0f;
@@ -48,15 +48,17 @@ void sport_motion(void)
cnt1++; cnt1++;
in_gyro = imu660ra_gyro_z; // 陀螺仪输入 in_gyro = imu660ra_gyro_z; // 陀螺仪输入
in_angle = 0; // 图像远端输入 // in_angle = 0; // 图像远端输入
in_pos = 0; // 图像近端输入 // in_pos = 0; // 图像近端输入
in_speed = encoder_get_count(TIM5_ENCOEDER) / 1024 / 0.01 * 0.25; // 速度输入,m/s // 清除计数
encoder_clear_count(TIM5_ENCOEDER); // 清除计数
PID_Compute(&far_gyro_pid); PID_Compute(&far_gyro_pid);
if (cnt1 >= 10) { if (cnt1 >= 10) {
PID_Compute(&far_angle_pid); PID_Compute(&far_angle_pid);
PID_Compute(&speed_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; cnt1 = 0;
} }

View File

@@ -7,6 +7,7 @@
PARAM_INFO Param_Data[DATA_NUM]; PARAM_INFO Param_Data[DATA_NUM];
soft_iic_info_struct eeprom_param; soft_iic_info_struct eeprom_param;
TYPE_UNION iic_buffer[DATA_IN_FLASH_NUM]; TYPE_UNION iic_buffer[DATA_IN_FLASH_NUM];
TYPE_UNION temp_frame_param[20];
/** /**
* @brief 参数初始化注册 * @brief 参数初始化注册

View File

@@ -63,6 +63,7 @@ typedef struct {
extern soft_iic_info_struct eeprom_param; extern soft_iic_info_struct eeprom_param;
extern PARAM_INFO Param_Data[DATA_NUM]; extern PARAM_INFO Param_Data[DATA_NUM];
extern TYPE_UNION iic_buffer[DATA_IN_FLASH_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_eeprom_init(void);
void jj_param_write(void); void jj_param_write(void);
void jj_param_read(void); void jj_param_read(void);

View File

@@ -41,7 +41,7 @@ int main(void)
system_delay_init(); system_delay_init();
debug_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); ips200_init(IPS200_TYPE_SPI);
while (imu660ra_init()) while (imu660ra_init())
; ;
@@ -49,7 +49,7 @@ int main(void)
jj_bt_init(); jj_bt_init();
by_rb_init(); by_rb_init();
by_pwm_init(); by_pwm_init();
// by_buzzer_init(); by_buzzer_init();
by_tiny_frame_init(); by_tiny_frame_init();
Page_Init(); Page_Init();
@@ -62,7 +62,9 @@ int main(void)
while (1) { while (1) {
Page_Run(); 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(); jj_bt_run();
by_tiny_frame_run(); by_tiny_frame_run();
} }

View File

@@ -33,7 +33,7 @@ static void Setup()
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 + 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) { if (index_power > 2) {
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) { } else if (page_event_press_long == event) {
event_flag = 0; event_flag = 0;
Print_Curser(Curser, Curser_Last, RGB565_PURPLE); Print_Curser(Curser, Curser_Last, RGB565_PURPLE);

View File

@@ -7,6 +7,7 @@
#include "by_tiny_frame_pack.h" #include "by_tiny_frame_pack.h"
#include "jj_motion.h" #include "jj_motion.h"
#include "jj_param.h"
void by_tiny_frame_read_write_run(void) 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: case 0x06:
// 添加写入接口,操作完成后应答 // 添加写入接口,操作完成后应答
switch (frame_pack_s.reg_addr) { switch (frame_pack_s.reg_addr) {
case 0x00: case 0x0000:
in_angle = (float)frame_s.data; temp_frame_param[0].u32 = frame_s.data;
in_angle=temp_frame_param[0].f32;
break; break;
case 0x01: case 0x0001:
in_pos = (float)frame_s.data; in_pos = (float)frame_s.data;
break; break;
default: default:
break; break;
} }
frame_pack_s.data=frame_s.data;
by_tiny_frame_pack_send(&frame_pack_s); by_tiny_frame_pack_send(&frame_pack_s);
break; break;
default: default:

View File

@@ -110,7 +110,7 @@
// 例C5-C12 IPS200_DATAPORT 设置为 GPIOC DATA_START_NUM 设置为 5 // 例C5-C12 IPS200_DATAPORT 设置为 GPIOC DATA_START_NUM 设置为 5
// --------------------双排 SPI 接口两寸屏幕引脚定义--------------------// // --------------------双排 SPI 接口两寸屏幕引脚定义--------------------//
#define IPS200_DEFAULT_DISPLAY_DIR (IPS200_PORTAIT) // 默认的显示方向 #define IPS200_DEFAULT_DISPLAY_DIR (IPS200_CROSSWISE) // 默认的显示方向
#define IPS200_DEFAULT_PENCOLOR (RGB565_YELLOW) // 默认的画笔颜色 #define IPS200_DEFAULT_PENCOLOR (RGB565_YELLOW) // 默认的画笔颜色
#define IPS200_DEFAULT_BGCOLOR (RGB565_BLACK) // 默认的背景颜色 #define IPS200_DEFAULT_BGCOLOR (RGB565_BLACK) // 默认的背景颜色
#define IPS200_DEFAULT_DISPLAY_FONT (IPS200_8X16_FONT) // 默认的字体模式 #define IPS200_DEFAULT_DISPLAY_FONT (IPS200_8X16_FONT) // 默认的字体模式