diff --git a/blinky.c b/blinky.c index 60afff02cbd8d19c40f430b75dead8c2cf9bc385..c3494f33ab8b000551a52868425f65f983337995 100644 --- a/blinky.c +++ b/blinky.c @@ -22,18 +22,16 @@ static THD_FUNCTION(Blinky, arg) { while(1){ // Blink the back LED when the robot moves backward - if( ((get_acc_case() == 2) | (get_acc_case() == 4)) & - (get_wall_detection() != 2) ){ + if(get_wall_detection() != 2){ + if( ((get_acc_case() == 2) | (get_acc_case() == 4)) ){ - set_led(LED5, 1); - chThdSleepMilliseconds(300); - set_led(LED5, 0); - chThdSleepMilliseconds(200); - }else if( ((get_acc_case() == 0) | (get_acc_case() == 1) | (get_acc_case() == 3)) & - (get_wall_detection() != 2) & (get_check_back_wall() == 1) ){ - - set_led(LED5, 0); - clear_check_back_wall(); + set_led(LED5, 1); + chThdSleepMilliseconds(300); + set_led(LED5, 0); + chThdSleepMilliseconds(200); + }else{ + set_led(LED5, 0); + } } // 10Hz chThdSleepMilliseconds(100); diff --git a/check_collision.c b/check_collision.c index fa90501cf4358ed54a9e01649463ae1cdf9e5277..b936d5de4f419e91ff8e2857ecd3e7e7b3e1ea71 100644 --- a/check_collision.c +++ b/check_collision.c @@ -24,7 +24,6 @@ * wall_detection = 2 -> wall detected in the back or (front and back) */ static uint8_t wall_detection = 0; -static uint8_t check_back_wall = 0; // Declaration of functions void clear_led_but_back(void); @@ -93,7 +92,6 @@ static THD_FUNCTION(CheckCollision, arg) { // Front and back detected }else{ wall_detection = 2; - check_back_wall = 1; // Set acc_case to 0 reset_acc_case(); @@ -121,7 +119,6 @@ static THD_FUNCTION(CheckCollision, arg) { // Set back LEDs and clear front LEDs wall_detection = 2; - check_back_wall = 1; set_led(LED1, 0); set_rgb_led(LED2, 0, 0, 0); @@ -165,14 +162,6 @@ uint8_t get_wall_detection(void){ return wall_detection; } -uint8_t get_check_back_wall(void){ - return check_back_wall; -} - -void clear_check_back_wall(void){ - check_back_wall = 0; -} - // Clear all LEDs except the back LED void clear_led_but_back(void){ set_led(LED1, 0); diff --git a/check_collision.h b/check_collision.h index 1ed659744c8d7c1efc00ead75669312079e8669f..a42498d61137739edee9091df752fcfe8d6f198a 100644 --- a/check_collision.h +++ b/check_collision.h @@ -13,7 +13,5 @@ void check_collision_start(void); // Getter of wall_detection uint8_t get_wall_detection(void); -uint8_t get_check_back_wall(void); -void clear_check_back_wall(void); #endif /* CHECK_COLLISION_H_ */