Skip to content

Commit 2d74668

Browse files
Merge pull request #34 from id-studiolab/test
state diagram and code update
2 parents 90673cc + 95aad18 commit 2d74668

3 files changed

Lines changed: 11 additions & 13 deletions

File tree

assignments/03-game-controller-discover/code_solution.md

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,18 @@ has_children: false
1111

1212
```python
1313
while True:
14-
if button.value is True:
1514
if current_state is state_wait:
16-
keyboard.press(key) # Send our defined key as a command...
17-
print("button is pressed") #Print a confirmation in the serial monitor
18-
19-
current_state = state_button_is_pressed # Update our state
20-
21-
elif button.value is False:
15+
if button.value == True:
16+
keyboard.press(key) # Send our defined key as a command...
17+
print("button is pressed") #Print a confirmation in the serial monitor
18+
current_state = state_button_is_pressed # Update our state
19+
2220
if current_state is state_button_is_pressed:
23-
keyboard.release_all() # and release all keys again
24-
print("button is released") # Print a confirmation in the serial monitor
25-
26-
current_state = state_wait # Reset the state
27-
21+
if button.value == False:
22+
keyboard.release_all() # and release all keys again
23+
print("button is released") # Print a confirmation in the serial monitor
24+
current_state = state_wait # Reset the state
25+
2826
# Sleep briefly so keypress events occur at a human timescale.
2927
# Skilled users can manage ~7 button presses per second, so we
3028
# sample at roughly twice that rate to satisfy the Nyquist criterion.

assignments/03-game-controller-discover/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Your assignment is to use the template code and the acting machine diagram here
4747

4848
| Acting Machine Diagram |
4949
| -------------------------------------- |
50-
| ![](stateDiagram.png) |
50+
| ![](state_diagram_corrected.png) |
5151

5252
### Code template
5353

63 KB
Loading

0 commit comments

Comments
 (0)