Skip to content

Commit 2760efc

Browse files
authored
Update code.py
delete semicolon, use intermediate variable to get around exceeding the return limit (7 vs. limit of 6)
1 parent bf4b6bf commit 2760efc

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

CPX_Simon_Game/code.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def light_region(region, duration=1):
4141
cpx.pixels[led] = REGION_COLOR[region]
4242

4343
# play a tone for the selected region
44-
cpx.start_tone(REGION_TONE[region]);
44+
cpx.start_tone(REGION_TONE[region])
4545

4646
# wait the requested amount of time
4747
time.sleep(duration)
@@ -54,22 +54,24 @@ def light_region(region, duration=1):
5454
cpx.pixels[led] = (0, 0, 0)
5555

5656
def read_region(timeout=30):
57+
val = 0
5758
start_time = time.time()
5859
while time.time() - start_time < timeout:
5960
if cpx.touch_A1:
60-
return PAD_REGION['A1']
61+
val = PAD_REGION['A1']
6162
elif cpx.touch_A2:
62-
return PAD_REGION['A2']
63+
val = PAD_REGION['A2']
6364
elif cpx.touch_A3:
64-
return PAD_REGION['A3']
65+
val = PAD_REGION['A3']
6566
elif cpx.touch_A4:
66-
return PAD_REGION['A4']
67+
val = PAD_REGION['A4']
6768
elif cpx.touch_A5:
68-
return PAD_REGION['A5']
69+
val = PAD_REGION['A5']
6970
elif cpx.touch_A6:
70-
return PAD_REGION['A6']
71+
val = PAD_REGION['A6']
7172
elif cpx.touch_A7:
72-
return PAD_REGION['A7']
73+
val = PAD_REGION['A7']
74+
return val
7375

7476
def play_sequence(sequence):
7577
duration = 1 - len(sequence) * 0.05

0 commit comments

Comments
 (0)