Skip to content

Commit

Permalink
Merge pull request #277 from pioneers/student_code_update
Browse files Browse the repository at this point in the history
Updated 4 student code test files
  • Loading branch information
BrandonWong14 authored Jun 12, 2024
2 parents 545ae14 + 0c01724 commit 9a558ab
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 54 deletions.
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)

0 comments on commit 9a558ab

Please sign in to comment.