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 7afb589..dc40c84 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; @@ -44,16 +44,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 b28f0b5..1d0ab48 100644 --- a/app/main.c +++ b/app/main.c @@ -37,13 +37,12 @@ int main(void) { - TYPE_UNION test_data; - TYPE_UNION test_data_last; + TYPE_UNION test_data[2]; clock_init(SYSTEM_CLOCK_120M); 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()) ; @@ -63,17 +62,10 @@ int main(void) printf("ok\r\n"); while (1) { - // Page_Run(); - by_frame_parse(1, &test_data.u32); - - if (test_data.u32 != test_data_last.u32) { - ips200_show_float(0, 50, test_data.f32, 4, 2); - // printf("- %ld\r\n", (uint32_t)(test_data.f32 * 100)); - } + Page_Run(); + by_frame_parse(2, &test_data[1].u32); - test_data_last.u32 = test_data.u32; - - // by_buzzer_run(); - // jj_bt_run(); + by_buzzer_run(); + jj_bt_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);