Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions assignments/03-game-controller-discover/code_solution.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,18 @@ has_children: false

```python
while True:
if button.value is True:
if current_state is state_wait:
keyboard.press(key) # Send our defined key as a command...
print("button is pressed") #Print a confirmation in the serial monitor

current_state = state_button_is_pressed # Update our state

elif button.value is False:
if button.value == True:
keyboard.press(key) # Send our defined key as a command...
print("button is pressed") #Print a confirmation in the serial monitor
current_state = state_button_is_pressed # Update our state

if current_state is state_button_is_pressed:
keyboard.release_all() # and release all keys again
print("button is released") # Print a confirmation in the serial monitor

current_state = state_wait # Reset the state
if button.value == False:
keyboard.release_all() # and release all keys again
print("button is released") # Print a confirmation in the serial monitor
current_state = state_wait # Reset the state

# Sleep briefly so keypress events occur at a human timescale.
# Skilled users can manage ~7 button presses per second, so we
# sample at roughly twice that rate to satisfy the Nyquist criterion.
Expand Down
2 changes: 1 addition & 1 deletion assignments/03-game-controller-discover/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Your assignment is to use the template code and the acting machine diagram here

| Acting Machine Diagram |
| -------------------------------------- |
| ![](stateDiagram.png) |
| ![](state_diagram_corrected.png) |

### Code template

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.