error correction

This commit is contained in:
Thomas Klaehn 2016-09-21 09:57:13 +02:00
parent 92448cf9a5
commit dc2e04e314

View File

@ -137,7 +137,7 @@ static enum system_state handle_state_collision_drive_back(void)
system_state_object.collision_timer.running = true; system_state_object.collision_timer.running = true;
} }
if(system_state_object.collision_timer.running && if(system_state_object.collision_timer.running &&
(system_state_object.collision_timer.tick > sys_tick_get_ms())) { (system_state_object.collision_timer.tick < sys_tick_get_ms())) {
drive_ctrl_halt(); drive_ctrl_halt();
next_state = SYS_COLLISION_TURN; next_state = SYS_COLLISION_TURN;
system_state_object.collision_timer.running = false; system_state_object.collision_timer.running = false;
@ -159,7 +159,7 @@ static enum system_state handle_state_collision_turn(void)
shell_write(print_buffer, strlen(print_buffer)); shell_write(print_buffer, strlen(print_buffer));
drv_open(&rng); drv_open(&rng);
// random number between 500 and 4000 // random number between 500 and 4000
int sleep = drv_read(&rng, NULL, 0) % 3500 + 500; unsigned int sleep = (unsigned int)drv_read(&rng, NULL, 0) % 3500 + 500;
system_state_object.collision_timer.tick = sys_tick_get_ms() + sleep; system_state_object.collision_timer.tick = sys_tick_get_ms() + sleep;
system_state_object.collision_timer.running = true; system_state_object.collision_timer.running = true;
// randomize turn direction // randomize turn direction
@ -169,7 +169,7 @@ static enum system_state handle_state_collision_turn(void)
drive_ctrl_turn_right(); drive_ctrl_turn_right();
} }
if(system_state_object.collision_timer.running && if(system_state_object.collision_timer.running &&
(system_state_object.collision_timer.tick > sys_tick_get_ms())) { (system_state_object.collision_timer.tick < sys_tick_get_ms())) {
drive_ctrl_halt(); drive_ctrl_halt();
next_state = system_state_object.saved_state; next_state = system_state_object.saved_state;
system_state_object.collision_timer.running = false; system_state_object.collision_timer.running = false;