My Project
simonTask.simonTask Class Reference

Public Member Functions

def __init__ (self, DBG_flag=True)
 
def run (self)
 runs the finite state machine of the Simon Says Game
 
def transitionTo (self, newState)
 transitions from current state to next More...
 
def button_pressed (self, IRQ_source)
 interrupt callback called when blue user button is pushed down More...
 
def randChoices (self, List, k)
 returns multiple randomized values from list More...
 

Public Attributes

 state
 The current state of the finite state machine.
 
 round
 Counts the number of runs of our task.
 
 wins
 Number of Wins.
 
 losses
 Number of Losses.
 
 press
 Global State of button not being pressed.
 
 button_press
 Global Button initialized as not being pushed.
 
 buttonStart
 record start time (ms) each time button is pushed
 
 buttonEnd
 Record end time (ms) when button is released.
 
 DBG_flag
 Flag to specify if debug messages print.
 
 ledOn
 the time choices (sec) when the led will be on
 
 ledOff
 the time choices(sec) when the led will be off
 
 modeOn
 number of items in sequence when LED is on
 
 modeOff
 number of pauses in sequence when LED if off
 
 i
 indexing value for the list of LED times
 
 game
 Game set to start when it enters State 1.
 
 pinA5
 Connect to pinA5 to control LD2 LED.
 
 tim2
 create object using timer 2, trigger at 20000 hz (cycle/sec)
 
 t2ch1
 
 pinC13
 Define pin object for PC13 - for blue user button.
 
 ButtonInt
 Associate the callback function with the pin by setting up an external interrupt.
 
 start
 start time recording More...
 
 onList
 randomize list when LED is on
 
 offList
 randomize list when LED is off
 
 now
 time passing after button is released
 
 duration
 time difference between start of code and current state
 
 onTime
 set the on time for this round
 
 offTime
 set the off time for this round
 
 curr_time
 current time is updating constantly for LED on
 
 notPress
 time difference of button not being pressed
 
 releaseTime
 record time when button is pushed
 
 pressDuration
 time difference between release time and button push
 
 offCurr
 time recording starts when led is off
 
 offDuration
 time duration when LED is off
 
 Choice
 User input to continue or quit game.
 
 randList
 empty list to append new items into
 
 List
 inputted list of time items for LED to turn on and off
 
 k
 length of list
 
 randNum
 randomly select item location
 

Static Public Attributes

int S0_GENERATE_PATTERN = 0
 Initiliaze Program with State 0.
 
int S1_START_PATTERN = 1
 State 1 initialized the pattern shown to the user on the LED.
 
int S2_USER_PATTERN = 2
 State 2 will recieve the pattern inputted by user.
 
int S3_END_ROUND = 3
 State 3 will provide results whether the user won the game or not.
 
float tolerance = 0.35
 tolerance of user pushing button in seconds
 

Member Function Documentation

◆ button_pressed()

def simonTask.simonTask.button_pressed (   self,
  IRQ_source 
)

interrupt callback called when blue user button is pushed down

Parameters
IRQ_srcthe interrupt request state
Returns
if button is pressed or not pressed

◆ randChoices()

def simonTask.simonTask.randChoices (   self,
  List,
  k 
)

returns multiple randomized values from list

Imitates random.choices() that is not available in micropython.

Parameters
Listlist of numbers or strings to be randomly selected
knumber of items to outputted
Returns
return list of randomized items

◆ transitionTo()

def simonTask.simonTask.transitionTo (   self,
  newState 
)

transitions from current state to next

Parameters
newStateThe next desire state
Returns
the new state to transition to

Member Data Documentation

◆ start

simonTask.simonTask.start

start time recording

record time when pin is on


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