Reaction Game Class. More...
Public Member Functions | |
| def | __init__ (self, LED_pin, BTN_pin, timer, limit) |
| def | getAveRxnTime (self) |
| Calculate average reaction time. More... | |
| def | start (self) |
| Begin the game. More... | |
| def | pressedBTN (self, home) |
| Button pressed ISR. More... | |
| def | resetStats (self) |
| Reset game stats. More... | |
| def | printStats (self) |
| Prints game stats. More... | |
Public Attributes | |
| LED | |
| BTN | |
| timer | |
| time_limit | |
| start_time | |
| end_time | |
| rxn_time | |
| total_time | |
| BTN_pressed | |
| isr_count | |
Reaction Game Class.
This class stores the values and functions required to play the game. Becuase it is a class, multiple game objects can be made and the game can be ported into other projects
| def lab02.RxnGame.__init__ | ( | self, | |
| LED_pin, | |||
| BTN_pin, | |||
| timer, | |||
| limit | |||
| ) |
| LED_pin | LED to light for the user |
| BTN_pin | button for user input @parm timer timer to keep track of time elapsed since press |
| limit | max number of secconds to keep the LED on |
| def lab02.RxnGame.getAveRxnTime | ( | self | ) |
Calculate average reaction time.
Calculates the average rxn time of the user over all attempts
| def lab02.RxnGame.pressedBTN | ( | self, | |
| home | |||
| ) |
Button pressed ISR.
ISR called whenever the user button is pressed on the board
| home | is auto-handled by the IRQ |
| def lab02.RxnGame.printStats | ( | self | ) |
Prints game stats.
Print reaction time statistics e.g. average reaction time and total tries
| def lab02.RxnGame.resetStats | ( | self | ) |
Reset game stats.
Upon completion of a round, reset game statistics for a new game
| def lab02.RxnGame.start | ( | self | ) |
Begin the game.
Turns on the LED and starts a timer to count how many micro-seconds it takes the user to press the button. Note: the LED turns on and then a couple of instructions are executed.