diff --git a/app/by_buzzer.c b/app/by_buzzer.c index 162fc77..d674999 100644 --- a/app/by_buzzer.c +++ b/app/by_buzzer.c @@ -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--; } diff --git a/app/jj_motion.c b/app/jj_motion.c index 2aa33e7..a3fb2fd 100644 --- a/app/jj_motion.c +++ b/app/jj_motion.c @@ -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; } diff --git a/app/jj_param.c b/app/jj_param.c index 26b4315..4d96041 100644 --- a/app/jj_param.c +++ b/app/jj_param.c @@ -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 参数初始化注册 diff --git a/app/jj_param.h b/app/jj_param.h index b2c637c..de9e13a 100644 --- a/app/jj_param.h +++ b/app/jj_param.h @@ -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); diff --git a/app/main.c b/app/main.c index 3036a72..d3c5a95 100644 --- a/app/main.c +++ b/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(); } diff --git a/app/page/page_param.c b/app/page/page_param.c index ef8d0f4..35597d9 100644 --- a/app/page/page_param.c +++ b/app/page/page_param.c @@ -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); diff --git a/app/tiny_frame/by_tiny_frame_slave_read_write.c b/app/tiny_frame/by_tiny_frame_slave_read_write.c index 9344cb4..13d3ffa 100644 --- a/app/tiny_frame/by_tiny_frame_slave_read_write.c +++ b/app/tiny_frame/by_tiny_frame_slave_read_write.c @@ -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: diff --git a/libraries/zf_device/zf_device_ips200.h b/libraries/zf_device/zf_device_ips200.h index a37ea56..b31c04c 100644 --- a/libraries/zf_device/zf_device_ips200.h +++ b/libraries/zf_device/zf_device_ips200.h @@ -110,7 +110,7 @@ // 例:C5-C12 IPS200_DATAPORT 设置为 GPIOC DATA_START_NUM 设置为 5 // --------------------双排 SPI 接口两寸屏幕引脚定义--------------------// -#define IPS200_DEFAULT_DISPLAY_DIR (IPS200_PORTAIT) // 默认的显示方向 +#define IPS200_DEFAULT_DISPLAY_DIR (IPS200_CROSSWISE) // 默认的显示方向 #define IPS200_DEFAULT_PENCOLOR (RGB565_YELLOW) // 默认的画笔颜色 #define IPS200_DEFAULT_BGCOLOR (RGB565_BLACK) // 默认的背景颜色 #define IPS200_DEFAULT_DISPLAY_FONT (IPS200_8X16_FONT) // 默认的字体模式