events Module
Files:
Interface
Function: CheckEvents
Arguments: None.
Returns:The Event_t indicating the detected event.
Checks and returns events.
Pseudo-Code
CheckEvents(Returns an Event_t indicating the detected event.)
Initialize static variable FlagSensed to FALSE
Initialize static variable Capturing to FALSE
Initialize static variable RightSawOpposing to FALSE
Initialize static variable HitGreenTape to FALSE
Get the side information and store it in the corners variable
If a flash is detected:
return flash event
Endif
If the game timer is expired:
return game timer done event
Endif
If the state of the playing state machine is going to goal:
If the state of the goalfinding state machine is finding goal
and the duty detected by the right top beacon equals corners.opposing:
Set RightSawOpposing to TRUE
Endif
If the green tape timer is expired:
Set HitGreenTape to TRUE
Endif
If the state of the goalfinding state machine is heading to goal
and either of the front tape sensors see green tape:
Start the green tape timer with 100ms
Endif
If the state of the goalfinding state machine is finding goal
and the duty detected by the right top beacon equals corners.own
and RightSawOpposing is TRUE:
Turn off top beacon interrupts
return at goal direction event
Endif
If both front tape sensors read green or white
and the rear tape sensor reads green:
return in goal event
Else:
return misaligned event
Endif
Endif
If the flag captured timer is expired:
return capturing timer done event
Endif
If the gate sensor is blocked:
Start the flag captured timer with 500ms
return gate blocked event
Endif
If either flag sensor level is over 400:
Set FlagSensed to TRUE
return flag sensed event
Else if FlagSensed is TRUE:
Set FlagSensed to FALSE
return flag lost event
Endif
return no event