Skip to content

Commit

Permalink
Add debounce
Browse files Browse the repository at this point in the history
  • Loading branch information
cuklev committed Dec 17, 2016
1 parent 3900ccb commit fb81b29
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/Slim/logic/fight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,28 @@ enum {
CHASE,
} STATE = SEARCH;

static uint16_t debounce_start_timer = 0;

void initFight()
{
debounce_start_timer = 50;

enqueueTurn(STANDARD_SPEED, 0, -20);
enqueueLinearMovement(STANDARD_SPEED, 250);
enqueueTurn(STANDARD_SPEED, 75, -360);
enqueueTurn(STANDARD_SPEED, 75, -360);
enqueueTurn(STANDARD_SPEED, 75, -360);
enqueueTurn(STANDARD_SPEED, 75, -360);
enqueueTurn(STANDARD_SPEED, 100, -360);
enqueueTurn(STANDARD_SPEED, 100, -360);
enqueueTurn(STANDARD_SPEED, 100, -360);
enqueueTurn(STANDARD_SPEED, 100, -360);
}

void handleFight()
{
if(debounce_start_timer > 0)
{
debounce_start_timer--;
return;
}

uint8_t left = readLeftSensor();
uint8_t right = readRightSensor();

Expand Down

0 comments on commit fb81b29

Please sign in to comment.