File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -85,38 +85,31 @@ def read_caps():
8585
8686def record_caps (timeout = 3 ):
8787 start_time = time .monotonic () # start 3 second timer waiting for user input
88+ val = None
8889 while time .monotonic () - start_time < timeout :
8990 caps = read_caps ()
90- val = None
9191 for i ,c in enumerate (caps ):
9292 if c :
9393 val = i
94- print ("true!" )
9594 time .sleep (0.1 )
9695 if val is not None : # if there's input from a pad exit the timer loop
97- break
98- return val
96+ return val
9997
10098def light_cap (cap , duration = 0.5 ):
10199 # turn the LED for the selected cap on
102100 leds [cap ].value = True
103- # wait the requested amount of time
104101 time .sleep (duration )
105- # turn the LED for the selected region off
106102 leds [cap ].value = False
107103 time .sleep (duration )
108104
109105def play_sequence (sequence ):
110- duration = 1 - len (sequence ) * 0.05
111- if duration < 0.1 :
112- duration = 0.1
106+ duration = max (0.1 , 1 - len (sequence ) * 0.05 )
113107 for cap in sequence :
114108 light_cap (cap , duration )
115109
116110def read_sequence (sequence ):
117111 pixels .fill (green )
118112 pixels .show ()
119- #time.sleep(1)
120113 for cap in sequence :
121114 if record_caps () != cap :
122115 # the player made a mistake!
You can’t perform that action at this time.
0 commit comments