Code Listing for Controllers A and B
State Machines for Controller A:
Game: This code is used to control the main game play of Controller A and to move through the different stages in the game. Controller A is the master, and communicates most timing and stage end events to Controller B.
Balance: This state machine controls the state of the balance system for the whole game and posts events depending on the change of state. Events from both Controller A and B affect the state of the balance state machine.
Target: This state machine controls the state of the target system for the whole game and posts events depending on the change of state. Events from both Controller A and B affect the state of the target state machine.
Comm: This state machine controls communication between Controller A and Controller B.
Game: This code is used to control the main game play of Controller A and to move through the different stages in the game. Controller A is the master, and communicates most timing and stage end events to Controller B.
Balance: This state machine controls the state of the balance system for the whole game and posts events depending on the change of state. Events from both Controller A and B affect the state of the balance state machine.
Target: This state machine controls the state of the target system for the whole game and posts events depending on the change of state. Events from both Controller A and B affect the state of the target state machine.
Comm: This state machine controls communication between Controller A and Controller B.
State Machines For Controller B:
Game: This code is used to control the main game play of Controller B and to move through the different stages in the game. Controller A is the master, and communicates most timing and stage end events to Controller B.
Balance: This state machine controls the state of the balance system for the whole game and posts events depending on the change of state. Only events from Controller B affect the state of the balance state machine.
Target: This state machine controls the state of the target system for the whole game and posts events depending on the change of state. Only events from Controller B affect the state.
Comm: This state machine controls communication between Controller A and Controller B.
Game: This code is used to control the main game play of Controller B and to move through the different stages in the game. Controller A is the master, and communicates most timing and stage end events to Controller B.
Balance: This state machine controls the state of the balance system for the whole game and posts events depending on the change of state. Only events from Controller B affect the state of the balance state machine.
Target: This state machine controls the state of the target system for the whole game and posts events depending on the change of state. Only events from Controller B affect the state.
Comm: This state machine controls communication between Controller A and Controller B.
Functionality Code:
TargetControl : The Target Control service checks for target events and contains helper functions to turn targets on and off
VibrationControl : The Vibration Control service interprets the analog input from the potentiometer and contains helper functions to turn vibration on and off
Debounce : The Debounce Service checks for Ready Button, Balance Switch, and Access Card events.
ClockControl: The Clock Control Service controls the game clock LED display. It initializes the clock and turns LEDs off as time passes.
*Functionality code is the same for both controllers with the exception that Controller B does not check the access card reader or control a game clock.
TargetControl : The Target Control service checks for target events and contains helper functions to turn targets on and off
VibrationControl : The Vibration Control service interprets the analog input from the potentiometer and contains helper functions to turn vibration on and off
Debounce : The Debounce Service checks for Ready Button, Balance Switch, and Access Card events.
ClockControl: The Clock Control Service controls the game clock LED display. It initializes the clock and turns LEDs off as time passes.
*Functionality code is the same for both controllers with the exception that Controller B does not check the access card reader or control a game clock.