Skip to content

Commit 9a558ab

Browse files
Merge pull request #277 from pioneers/student_code_update
Updated 4 student code test files
2 parents 545ae14 + 0c01724 commit 9a558ab

File tree

4 files changed

+36
-54
lines changed

4 files changed

+36
-54
lines changed

tests/student_code/sound_device.py

+20-24
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Student code that plays pitches from keyboard inputs
2+
# Commented out print_buttons and play_notes functions as they are not run
23
import time
34

45
SOUND = '59_1'
@@ -23,8 +24,8 @@
2324

2425
################################## AUTONOMOUS ##################################
2526

26-
def autonomous_setup():
27-
print("Now executing AUTONOMOUS SETUP")
27+
def autonomous():
28+
print("Now executing AUTONOMOUS")
2829
# Write pitches
2930
for note in NOTES:
3031
if (note == ' '):
@@ -35,35 +36,30 @@ def autonomous_setup():
3536
Robot.set_value(SOUND, "PITCH", MAP[note])
3637
time.sleep(NOTE_DURATION)
3738

38-
def autonomous_main():
39-
pass
40-
4139
#################################### TELEOP ####################################
4240

43-
def teleop_setup():
44-
print("Now executing TELEOP SETUP")
41+
def teleop():
42+
print("Now executing TELEOP")
4543
# Robot.run(print_button)
4644
# 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);
5854

5955
################################### THREADS ####################################
6056

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")
6763

6864
# def play_notes():
6965
# while (1):

tests/student_code/tc_212_a.py

+4-9
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,10 @@
66
DEVICE = "62_1"
77
PARAM = "MY_INT"
88

9-
def autonomous_setup():
9+
def autonomous():
1010
pass
1111

12-
def autonomous_main():
13-
pass
14-
15-
def teleop_setup():
16-
pass
17-
18-
def teleop_main():
19-
Robot.set_value(DEVICE, PARAM, 999)
12+
def teleop():
13+
while True:
14+
Robot.set_value(DEVICE, PARAM, 999)
2015

tests/student_code/tc_212_b.py

+5-9
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,12 @@
77
DEVICE = "62_1"
88
PARAM = "MY_INT"
99

10-
def autonomous_setup():
10+
def autonomous():
1111
pass
1212

13-
def autonomous_main():
14-
pass
15-
16-
def teleop_setup():
13+
def teleop():
1714
Robot.set_value(DEVICE, PARAM, 999)
18-
19-
def teleop_main():
20-
if Keyboard.get_value('w'):
21-
Robot.set_value(DEVICE, PARAM, 1000)
15+
while True:
16+
if Keyboard.get_value('w'):
17+
Robot.set_value(DEVICE, PARAM, 1000)
2218

tests/student_code/tc_212_c.py

+7-12
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,12 @@
66
DEVICE = "62_1"
77
PARAM = "MY_INT"
88

9-
def autonomous_setup():
9+
def autonomous():
1010
pass
1111

12-
def autonomous_main():
13-
pass
14-
15-
def teleop_setup():
16-
pass
17-
18-
def teleop_main():
19-
if Keyboard.get_value('w'):
20-
Robot.set_value(DEVICE, PARAM, 999)
21-
else:
22-
Robot.set_value(DEVICE, PARAM, 111)
12+
def teleop():
13+
while True:
14+
if Keyboard.get_value('w'):
15+
Robot.set_value(DEVICE, PARAM, 999)
16+
else:
17+
Robot.set_value(DEVICE, PARAM, 111)

0 commit comments

Comments
 (0)