Update twist_scrimmage.py
This commit is contained in:
@@ -167,10 +167,10 @@ class CelebrationSound:
|
|||||||
async def play_victory_fanfare():
|
async def play_victory_fanfare():
|
||||||
"""Classic victory fanfare"""
|
"""Classic victory fanfare"""
|
||||||
notes = [
|
notes = [
|
||||||
(330, 200), # E4
|
(cn["B3"], 200),
|
||||||
(330, 100), # E4
|
(cn["B3"], 100),
|
||||||
(330, 100), # E4
|
(cn["B3"], 100),
|
||||||
(440, 600), # A4
|
(cn["E4"], 600)
|
||||||
]
|
]
|
||||||
|
|
||||||
for freq, duration in notes:
|
for freq, duration in notes:
|
||||||
@@ -216,13 +216,24 @@ async def play_success_chime():
|
|||||||
async def play_ta_da():
|
async def play_ta_da():
|
||||||
"""Classic "ta-da!" sound"""
|
"""Classic "ta-da!" sound"""
|
||||||
notes = [
|
notes = [
|
||||||
(cn["B3"], 200), # B4
|
(cn["Cs4"], 200),
|
||||||
(cn["E4"], 400), # E5
|
(cn["Ds4"], 200),
|
||||||
|
(cn["E4"], 200),
|
||||||
|
(cn["Ds4"], 200),
|
||||||
|
(cn["E4"], 200),
|
||||||
|
(cn["Fs4"], 400),
|
||||||
|
(cn["Gs4"], 600),
|
||||||
|
(cn["Fs4"], 400),
|
||||||
|
(cn["Gs4"], 200),
|
||||||
|
(cn["A4"], 200),
|
||||||
|
(cn["B4"], 200),
|
||||||
|
(cn["C5"], 200),
|
||||||
|
(cn["Cs5"], 200)
|
||||||
]
|
]
|
||||||
|
|
||||||
for freq, duration in notes:
|
for freq, duration in notes:
|
||||||
await hub.speaker.beep(freq, duration)
|
await hub.speaker.beep(freq, duration)
|
||||||
await wait(100)
|
#await wait(100)
|
||||||
async def play_power_up():
|
async def play_power_up():
|
||||||
"""Rising power-up sound"""
|
"""Rising power-up sound"""
|
||||||
frequencies = [
|
frequencies = [
|
||||||
@@ -239,19 +250,19 @@ async def play_rickroll_inspired():
|
|||||||
"""Fun 80s-style dance beat inspired sound"""
|
"""Fun 80s-style dance beat inspired sound"""
|
||||||
# Upbeat bouncy rhythm
|
# Upbeat bouncy rhythm
|
||||||
pattern = [
|
pattern = [
|
||||||
(cn["B3"], 200), (cn["Cs4"], 200), (cn["Ds4"], 200), (cn["E4"], 200),
|
(cn["Gs3"], 200), (cn["A3"], 200), (cn["B3"], 200), (cn["Cs4"], 200),
|
||||||
(cn["Cs4"], 200), (cn["B3"], 200), (cn["A3"], 200), (cn["B3"], 300),
|
(cn["A3"], 200), (cn["Gs3"], 200), (cn["Fs3"], 200), (cn["Gs3"], 400),
|
||||||
(cn["Cs4"], 200), (cn["B3"], 200), (cn["A3"], 200), (cn["Gs3"], 400),
|
(cn["A3"], 200), (cn["Gs3"], 200), (cn["Fs3"], 200), (cn["E3"], 400),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for freq, duration in pattern:
|
for freq, duration in pattern:
|
||||||
await hub.speaker.beep(freq, duration)
|
await hub.speaker.beep(freq, duration)
|
||||||
await wait(50)
|
#await wait(50)
|
||||||
|
|
||||||
# Basically a big if else statement that calls the functions above
|
# Basically a big if else statement that calls the functions above
|
||||||
async def celebrate_mission_complete(sound_type=CelebrationSound.RICKROLL_INSPIRED):
|
async def celebrate_mission_complete(sound_type=CelebrationSound.WAITING_SOUND):
|
||||||
"""
|
"""
|
||||||
Main celebration function to call after completing a mission.
|
Main celebration function to call after completing a mission.
|
||||||
Plays a sound and shows light animation.
|
Plays a sound and shows light animation.
|
||||||
@@ -323,7 +334,7 @@ async def main():
|
|||||||
elif color_detected == Color.RED:
|
elif color_detected == Color.RED:
|
||||||
print('Running Mission 6')
|
print('Running Mission 6')
|
||||||
await Run6()
|
await Run6()
|
||||||
await celebrate_mission_complete(CelebrationSound.POWER_UP)
|
await celebrate_mission_complete(CelebrationSound.TA_DA)
|
||||||
else:
|
else:
|
||||||
hub.light.off()
|
hub.light.off()
|
||||||
left_motor.stop()
|
left_motor.stop()
|
||||||
@@ -331,6 +342,4 @@ async def main():
|
|||||||
else:
|
else:
|
||||||
print("No color was detected.")
|
print("No color was detected.")
|
||||||
await wait(100) # prevent loop from iterating fast
|
await wait(100) # prevent loop from iterating fast
|
||||||
|
|
||||||
# Main execution loop
|
|
||||||
run_task(main())
|
run_task(main())
|
||||||
Reference in New Issue
Block a user