fix:修復幾個bug

This commit is contained in:
2024-07-05 21:29:03 +08:00
parent be37b5d206
commit 336d1bc100
4 changed files with 43 additions and 40 deletions

View File

@@ -23,7 +23,7 @@ void CheckBarrier()
void RunBarrier() void RunBarrier()
{ {
if (barrier_type == BARRIER_LEFT_BEGIN) { if (barrier_type == BARRIER_LEFT_BEGIN||barrier_type == BARRIER_LEFT_RUNNING) {
track_type = TRACK_RIGHT; track_type = TRACK_RIGHT;
// if (barrier_begin_flag == 0) { // if (barrier_begin_flag == 0) {
// timer_clear(TIM_3); // timer_clear(TIM_3);
@@ -54,20 +54,20 @@ void RunBarrier()
Lpt0_found_count = 0; Lpt0_found_count = 0;
barrier_type = BARRIER_LEFT_RUNNING; barrier_type = BARRIER_LEFT_RUNNING;
track_type = TRACK_RIGHT; track_type = TRACK_RIGHT;
timer_clear(TIM_1); timer_clear(TIM_2);
timer_start(TIM_1); timer_start(TIM_2);
} else if (barrier_type == BARRIER_LEFT_RUNNING) { } else if (barrier_type == BARRIER_LEFT_RUNNING) {
track_type = TRACK_RIGHT; track_type = TRACK_RIGHT;
if (timer_get(TIM_1) >= 220) { if (timer_get(TIM_2) >= 500) {
barrier_type = BARRIER_NONE; barrier_type = BARRIER_NONE;
track_type = TRACK_RIGHT; track_type = TRACK_RIGHT;
timer_stop(TIM_1); timer_stop(TIM_2);
timer_clear(TIM_1); timer_clear(TIM_2);
} }
} }
} }
if (barrier_type == BARRIER_RIGHT_BEGIN) { if (barrier_type == BARRIER_RIGHT_BEGIN||barrier_type == BARRIER_RIGHT_RUNNING) {
track_type = TRACK_LEFT; track_type = TRACK_LEFT;
// if (barrier_begin_flag == 0) { // if (barrier_begin_flag == 0) {
// timer_clear(TIM_3); // timer_clear(TIM_3);
@@ -98,13 +98,13 @@ void RunBarrier()
Lpt1_found_count = 0; Lpt1_found_count = 0;
barrier_type = BARRIER_RIGHT_RUNNING; barrier_type = BARRIER_RIGHT_RUNNING;
track_type = TRACK_LEFT; track_type = TRACK_LEFT;
timer_clear(TIM_1); timer_clear(TIM_2);
timer_start(TIM_1); timer_start(TIM_2);
} else if (barrier_type == BARRIER_RIGHT_RUNNING) { } else if (barrier_type == BARRIER_RIGHT_RUNNING) {
track_type = TRACK_LEFT; track_type = TRACK_LEFT;
if (timer_get(TIM_1) >= 220) { if (timer_get(TIM_2) >= 500) {
timer_stop(TIM_1); timer_stop(TIM_2);
timer_clear(TIM_1); timer_clear(TIM_2);
barrier_type = BARRIER_NONE; barrier_type = BARRIER_NONE;
track_type = TRACK_LEFT; track_type = TRACK_LEFT;
} }
@@ -150,21 +150,21 @@ void RunS()
} }
void Check_shield(){ // void Check_shield(){
if (begin_flag == 1) // if (begin_flag == 1)
{ // {
shield_type = SHIELD_BEGIN; // shield_type = SHIELD_BEGIN;
timer_clear(TIM_3); // timer_clear(TIM_3);
timer_start(TIM_3); // timer_start(TIM_3);
begin_flag = 0; // begin_flag = 0;
} // }
if (timer_get(TIM_3) > 1000 && shield_type == SHIELD_BEGIN) // if (timer_get(TIM_3) > 1000 && shield_type == SHIELD_BEGIN)
{ // {
shield_type = SHIELD_NONE; // shield_type = SHIELD_NONE;
timer_stop(TIM_3); // timer_stop(TIM_3);
timer_clear(TIM_3); // timer_clear(TIM_3);
} // }
} // }

View File

@@ -113,11 +113,11 @@ void aim_distance_select(void)
void ElementJudge() void ElementJudge()
{ {
if(begin_flag == 1){ // if(begin_flag == 1){
shield_type = SHIELD_BEGIN; // shield_type = SHIELD_BEGIN;
begin_flag = 0; // begin_flag = 0;
return; // return;
} // }
if (shield_type == SHIELD_NONE) { if (shield_type == SHIELD_NONE) {
CheckGarage(); CheckGarage();
@@ -168,11 +168,12 @@ void ElementRun()
void MidLineTrack() void MidLineTrack()
{ {
if (shield_type == SHIELD_BEGIN) { // if (shield_type == SHIELD_BEGIN) {
shield_type = SHIELD_NONE; // shield_type = SHIELD_NONE;
system_delay_ms(1000); // 斑马线发车延时 // pure_angle = 0.f;
} // system_delay_ms(3500); // 斑马线发车延时
else if (cross_type == CROSS_IN) { // }
if (cross_type == CROSS_IN) {
if (track_type == TRACK_LEFT) { if (track_type == TRACK_LEFT) {
mid_track = mid_left; // 这是为了预先分配内存 mid_track = mid_left; // 这是为了预先分配内存
GetMidLine_Left(pts_far_resample_left + far_Lpt0_rpts0s_id, pts_far_resample_left_count - far_Lpt0_rpts0s_id, mid_left, (int)round(ANGLEDIST / RESAMPLEDIST), PIXPERMETER * ROADWIDTH / 2); GetMidLine_Left(pts_far_resample_left + far_Lpt0_rpts0s_id, pts_far_resample_left_count - far_Lpt0_rpts0s_id, mid_left, (int)round(ANGLEDIST / RESAMPLEDIST), PIXPERMETER * ROADWIDTH / 2);

View File

@@ -34,6 +34,7 @@
********************************************************************************************************************/ ********************************************************************************************************************/
#include "zf_common_headfile.h" #include "zf_common_headfile.h"
#include "gl_headfile.h"
#include "by_button.h" #include "by_button.h"
#include "by_buzzer.h" #include "by_buzzer.h"
#include "by_frame.h" #include "by_frame.h"
@@ -285,8 +286,8 @@ void EXTI15_10_IRQHandler(void)
void TIM1_UP_IRQHandler(void) void TIM1_UP_IRQHandler(void)
{ {
if (TIM_GetITStatus(TIM1, TIM_IT_Update) != RESET) { if (TIM_GetITStatus(TIM1, TIM_IT_Update) != RESET) {
by_frame_send(&tiny_frame_param[0].u32);
TIM_ClearITPendingBit(TIM1, TIM_IT_Update); TIM_ClearITPendingBit(TIM1, TIM_IT_Update);
by_frame_send(&tiny_frame_param[0].u32);
by_led_warn_blink(); by_led_warn_blink();
} }
} }

View File

@@ -50,15 +50,16 @@ int main(void)
pit_ms_init(TIM1_PIT, 10); pit_ms_init(TIM1_PIT, 10);
timer_init(TIM_3, TIMER_MS); timer_init(TIM_3, TIMER_MS);
timer_init(TIM_2, TIMER_MS);
by_frame_init(); by_frame_init();
printf("start running\r\n"); printf("start running\r\n");
while (1) { while (1) {
memset(recv_data, 0, sizeof(recv_data)); memset(recv_data, 0, sizeof(recv_data));
by_frame_parse(&recv_data[0].u32); by_frame_parse(&recv_data[0].u32);
if(0xEB == recv_data[0].u32) { if (0x0D == recv_data[0].u32) {
NVIC_SystemReset(); NVIC_SystemReset();
}else if (0x5C == recv_data[0].u32) { } else if (0x5C == recv_data[0].u32) {
begin_flag = 1; begin_flag = 1;
} }