405 Documentation  9.0
lab02.RxnGame Class Reference

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
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __init__()

def lab02.RxnGame.__init__ (   self,
  LED_pin,
  BTN_pin,
  timer,
  limit 
)
Parameters
LED_pinLED to light for the user
BTN_pinbutton for user input @parm timer timer to keep track of time elapsed since press
limitmax number of secconds to keep the LED on

Member Function Documentation

◆ getAveRxnTime()

def lab02.RxnGame.getAveRxnTime (   self)

Calculate average reaction time.

Calculates the average rxn time of the user over all attempts

◆ pressedBTN()

def lab02.RxnGame.pressedBTN (   self,
  home 
)

Button pressed ISR.

ISR called whenever the user button is pressed on the board

Parameters
homeis auto-handled by the IRQ

◆ printStats()

def lab02.RxnGame.printStats (   self)

Prints game stats.

Print reaction time statistics e.g. average reaction time and total tries

◆ resetStats()

def lab02.RxnGame.resetStats (   self)

Reset game stats.

Upon completion of a round, reset game statistics for a new game

◆ start()

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.


The documentation for this class was generated from the following file: