1
1
# Student code that plays pitches from keyboard inputs
2
+ # Commented out print_buttons and play_notes functions as they are not run
2
3
import time
3
4
4
5
SOUND = '59_1'
23
24
24
25
################################## AUTONOMOUS ##################################
25
26
26
- def autonomous_setup ():
27
- print ("Now executing AUTONOMOUS SETUP " )
27
+ def autonomous ():
28
+ print ("Now executing AUTONOMOUS" )
28
29
# Write pitches
29
30
for note in NOTES :
30
31
if (note == ' ' ):
@@ -35,35 +36,30 @@ def autonomous_setup():
35
36
Robot .set_value (SOUND , "PITCH" , MAP [note ])
36
37
time .sleep (NOTE_DURATION )
37
38
38
- def autonomous_main ():
39
- pass
40
-
41
39
#################################### TELEOP ####################################
42
40
43
- def teleop_setup ():
44
- print ("Now executing TELEOP SETUP " )
41
+ def teleop ():
42
+ print ("Now executing TELEOP" )
45
43
# Robot.run(print_button)
46
44
# Robot.run(play_notes)
47
- pass
48
-
49
- def teleop_main ():
50
- if Gamepad .get_value ('button_a' ):
51
- Robot .set_value (SOUND , "PITCH" , MAP ['C' ])
52
- print ("Wrote Button A: Pitch C" )
53
- time .sleep (NOTE_DURATION );
54
- if Gamepad .get_value ('button_b' ):
55
- Robot .set_value (SOUND , "PITCH" , MAP ['B' ])
56
- print ("Wrote Button B: Pitch B" )
57
- time .sleep (NOTE_DURATION );
45
+ while True :
46
+ if Gamepad .get_value ('button_a' ):
47
+ Robot .set_value (SOUND , "PITCH" , MAP ['C' ])
48
+ print ("Wrote Button A: Pitch C" )
49
+ time .sleep (NOTE_DURATION );
50
+ if Gamepad .get_value ('button_b' ):
51
+ Robot .set_value (SOUND , "PITCH" , MAP ['B' ])
52
+ print ("Wrote Button B: Pitch B" )
53
+ time .sleep (NOTE_DURATION );
58
54
59
55
################################### THREADS ####################################
60
56
61
- def print_button ():
62
- while (1 ):
63
- if Gamepad .get_value ('button_a' ):
64
- print ("BUTTON A IS PRESSED" )
65
- if Gamepad .get_value ('button_b' ):
66
- print ("BUTTON B IS PRESSED" )
57
+ # def print_button():
58
+ # while (1):
59
+ # if Gamepad.get_value('button_a'):
60
+ # print("BUTTON A IS PRESSED")
61
+ # if Gamepad.get_value('button_b'):
62
+ # print("BUTTON B IS PRESSED")
67
63
68
64
# def play_notes():
69
65
# while (1):
0 commit comments