Simulates the Finite State Machine for Simon Says with Morse Code. More...
Public Member Functions | |
def | __init__ (self, countdown_rate=0.5, countdown_start_number=5, unit_time=1, set_size=3, user_buffer=0.5, button_pin=pyb.Pin.cpu.C13, led_pin=pyb.Pin.cpu.A5) |
Initializes the class. More... | |
def | play (self) |
Finite State Machine for game. More... | |
def | onButtonPressFCN (self, IRQ_src) |
Callback function for when the blue button is pressed. More... | |
def | countdown (self, countdown_start_number, countdown_rate) |
Countdown function to make the user aware the flashing is about to happen. More... | |
def | blinkForUser (self, binary) |
Used to create the blinking shown to the user. More... | |
Public Attributes | |
pinC13 | |
Object for the Blue Button to be referenced. | |
pinA5 | |
Object for the LED to be referenced. | |
buttonPress | |
External Interrupt object for when the blue button is pressed or released. | |
set_size | |
Desired number of units per set. | |
set_number | |
Tracking variable for set inside each round. | |
unit_time | |
Amount of time in seconds for 1 unit. | |
state | |
State tracking variable. | |
button_var_press | |
Variable to track if the blue button is pressed. | |
button_var_release | |
Variable to track if the blue button is released. | |
iteration | |
General tracking variable to help with prompting each round in the game. | |
user_buffer | |
The tolerance for which the user needs to copy correctly +/- [s]. | |
BFU_var | |
Variable for assisting the blinking to the user. | |
countdown_rate | |
Speed at which the countdown clock counts down [ seconds per number ]. | |
countdown_start_number | |
Number at which the countdown will start. | |
english_statement | |
Statement inputted by user in English. | |
morse_statement | |
Statement that was inputted in English and converted to Morse Code dashes ad dots. | |
binary_statement | |
Statement that was inputted in English and converted to IMC binary units. | |
countdown_start_timer | |
Tracks when the countdown starts. | |
BFU_start_timer | |
Tracks when the blink for user function starts. | |
comparison_counter | |
Responsible for keeping track on index while comparing. | |
reverseSet | |
Captures the current binary set for information gathering. | |
endCheck | |
Reverses the current set_size * set_number. | |
reverseLastTrue | |
Checks how long from the end is the last True unit. | |
lastIndex | |
Indexes the last point in the current binary statement in which there is a True value. | |
button_press_timer | |
Timer to track when a button is pressed. | |
button_release_timer | |
Timer to track when a button is released. | |
pause_timer | |
Timer to track how long the user is waiting when the set ends with a release. | |
button_press_elapse | |
Tracks the amount of time the button was pressed down for. | |
button_release_elapse | |
Tracks the amount of time the button was released for. | |
replayQuestion | |
Response to continuation or termination question. | |
countdown_timer | |
Tracks the time the countdown has been running. | |
BFU_timer | |
Tracks the amount of time the LED has been blinking or not blinking for. | |
Simulates the Finite State Machine for Simon Says with Morse Code.
Contains the main finite state machine along with a visual countdown function, blink for user function, and a button press function. The various attributes include countdown rate, countdown start timer, unit time, set size, user buffer, and specifying which button and LED the user wants to use.
def simon_says_game_class.game.__init__ | ( | self, | |
countdown_rate = 0.5 , |
|||
countdown_start_number = 5 , |
|||
unit_time = 1 , |
|||
set_size = 3 , |
|||
user_buffer = 0.5 , |
|||
button_pin = pyb.Pin.cpu.C13 , |
|||
led_pin = pyb.Pin.cpu.A5 |
|||
) |
Initializes the class.
Based on source code generator testing, I recommend using the generic game attributes, however, the user gets a hang for the different attributes, the user can define the attributes to their liking. Countdown_rate is the rate seconds/ number which the coundown displays. Countdown_start_number is the number at which the countdown begins. Unit_time is the time for a single unit to be displayed or activated in seconds. Set_size is the desired size of the set. User_buffer is the tolerance the user has when it comes to copying the blinking pattern. Button_pin defines the desired button to be used. LED_pin defines the desired LED to be used.
def simon_says_game_class.game.blinkForUser | ( | self, | |
binary | |||
) |
Used to create the blinking shown to the user.
binary | A list of 0's and 1's to represent the units from the Morse Code from the inputted English statement. |
def simon_says_game_class.game.countdown | ( | self, | |
countdown_start_number, | |||
countdown_rate | |||
) |
Countdown function to make the user aware the flashing is about to happen.
countdown_start_number | The number when the countdown begins. If '5' then the countdown counts from 5 to 1 then tells user to watcht the LED. |
countdown_rate | The rate at which the countdown displays [seconds / #]. |
def simon_says_game_class.game.onButtonPressFCN | ( | self, | |
IRQ_src | |||
) |
Callback function for when the blue button is pressed.
IRQ_src | Interrupt request from Blue Button. |
def simon_says_game_class.game.play | ( | self | ) |
Finite State Machine for game.
This game has 9 states. It begins by prompting the user, then on a button press, the user will input a statement in English to be converted to Morse Code units. Then there will be a countdown. Once the countdown is done, the LED will blink for the user to watch. The user will then use the button to copy the LED blinking sequence. 3 states are dedicated to comparing the user input. One tracks how long the button was pressed. One tracks how long the button was released for. One tracks if the round ends on a release, then the user will need to wait a certain amount of time without pressing the button. The last state checks to see if the user wants to play again after winning.