Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated last 4 student code test files #277

Merged
merged 2 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 20 additions & 24 deletions tests/student_code/sound_device.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Student code that plays pitches from keyboard inputs
# Commented out print_buttons and play_notes functions as they are not run
import time

SOUND = '59_1'
Expand All @@ -23,8 +24,8 @@

################################## AUTONOMOUS ##################################

def autonomous_setup():
print("Now executing AUTONOMOUS SETUP")
def autonomous():
print("Now executing AUTONOMOUS")
# Write pitches
for note in NOTES:
if (note == ' '):
Expand All @@ -35,35 +36,30 @@ def autonomous_setup():
Robot.set_value(SOUND, "PITCH", MAP[note])
time.sleep(NOTE_DURATION)

def autonomous_main():
pass

#################################### TELEOP ####################################

def teleop_setup():
print("Now executing TELEOP SETUP")
def teleop():
print("Now executing TELEOP")
# Robot.run(print_button)
# Robot.run(play_notes)
pass

def teleop_main():
if Gamepad.get_value('button_a'):
Robot.set_value(SOUND, "PITCH", MAP['C'])
print("Wrote Button A: Pitch C")
time.sleep(NOTE_DURATION);
if Gamepad.get_value('button_b'):
Robot.set_value(SOUND, "PITCH", MAP['B'])
print("Wrote Button B: Pitch B")
time.sleep(NOTE_DURATION);
while True:
if Gamepad.get_value('button_a'):
Robot.set_value(SOUND, "PITCH", MAP['C'])
print("Wrote Button A: Pitch C")
time.sleep(NOTE_DURATION);
if Gamepad.get_value('button_b'):
Robot.set_value(SOUND, "PITCH", MAP['B'])
print("Wrote Button B: Pitch B")
time.sleep(NOTE_DURATION);

################################### THREADS ####################################

def print_button():
while (1):
if Gamepad.get_value('button_a'):
print("BUTTON A IS PRESSED")
if Gamepad.get_value('button_b'):
print("BUTTON B IS PRESSED")
# def print_button():
# while (1):
# if Gamepad.get_value('button_a'):
# print("BUTTON A IS PRESSED")
# if Gamepad.get_value('button_b'):
# print("BUTTON B IS PRESSED")

# def play_notes():
# while (1):
Expand Down
13 changes: 4 additions & 9 deletions tests/student_code/tc_212_a.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,10 @@
DEVICE = "62_1"
PARAM = "MY_INT"

def autonomous_setup():
def autonomous():
pass

def autonomous_main():
pass

def teleop_setup():
pass

def teleop_main():
Robot.set_value(DEVICE, PARAM, 999)
def teleop():
while True:
Robot.set_value(DEVICE, PARAM, 999)

14 changes: 5 additions & 9 deletions tests/student_code/tc_212_b.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,12 @@
DEVICE = "62_1"
PARAM = "MY_INT"

def autonomous_setup():
def autonomous():
pass

def autonomous_main():
pass

def teleop_setup():
def teleop():
Robot.set_value(DEVICE, PARAM, 999)

def teleop_main():
if Keyboard.get_value('w'):
Robot.set_value(DEVICE, PARAM, 1000)
while True:
if Keyboard.get_value('w'):
Robot.set_value(DEVICE, PARAM, 1000)

19 changes: 7 additions & 12 deletions tests/student_code/tc_212_c.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,12 @@
DEVICE = "62_1"
PARAM = "MY_INT"

def autonomous_setup():
def autonomous():
pass

def autonomous_main():
pass

def teleop_setup():
pass

def teleop_main():
if Keyboard.get_value('w'):
Robot.set_value(DEVICE, PARAM, 999)
else:
Robot.set_value(DEVICE, PARAM, 111)
def teleop():
while True:
if Keyboard.get_value('w'):
Robot.set_value(DEVICE, PARAM, 999)
else:
Robot.set_value(DEVICE, PARAM, 111)
Loading