Skip to content

Commit

Permalink
Move RTTTL into fri3d package and refactor a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
MathyV committed Jun 21, 2024
1 parent 3425af9 commit be21597
Show file tree
Hide file tree
Showing 10 changed files with 227 additions and 198 deletions.
53 changes: 27 additions & 26 deletions fri3d/fri3d_application/src/payload/examples/rtttl/main.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
import time

from examples.rtttl.rtttl_player import play_rtttl

macarena = 'Los del Rio - Macarena:o=5,d=8,b=180,b=180:f,f,f,4f,f,f,f,f,f,f,f,a,c,c,4f,f,f,4f,f,f,f,f,f,f,d,c,4p,4f,f,f,4f,f,f,f,f,f,f,f,a,4p,2c6.,4a,c6,a,f,4p,2p'
macarena_s = 'Los del Rio - Macarena - Short:o=5,d=8,b=180,b=180:4f,f,f,f,f,f,f,f,a,4p,2c6.,4a,c6,a,f'

dump_dump = 'To The Dump To The Dump To The Dump Dump Dump:o=5,d=8,b=270,b=270:c,c,4c,c,c,4c,c,c,f,p,g,p,4a,c,c,4c,c,c,4c,a,a,g,p,e,p,4c,c,c,4c,c,c,4c,c,c,f,p,g,p,4a,f,a,1c6,a,g,f,p,a.,p,f'
dump_dump_s = 'To The Dump To The Dump To The Dump Dump Dump - Short:o=5,d=8,b=270,b=270:c,c,4c,c,c,4c,c,c,f,p,g,p,4a'

william = 'Rossini - William Tell Overture Finale:d=4,o=5,b=140:16c,16c,16c,16p,16c,16c,16c,16p,16c,16c,16f,16p,8g,16a,16p,16c,16c,16c,16p,16c,16c,16f,16p,16a,16a,16g,16p,8e,16c,16p,16c,16c,16c,16p,16c,16c,16c,16p,16c,16c,16f,16p,8g,16a,16p,16f,16a,c6,16p,16a#,16a,16g,16f,16p,16a,16p,16f,16p'

take_on_me = 'a-ha - Take On Me:o=5,d=8,b=160,b=160:f#,f#,f#,d,p,b4,p,e,p,e,p,e,g#,g#,a,b,a,a,a,e,p,d,p,f#,p,f#,p,f#,e,e,f#,e,f#,f#,f#,d,p,b4,p,e,p,e,p,e,g#,g#,a,b,a,a,a,e,p,d,p,f#,p,f#,p,f#,e,e5'
take_on_me_s = 'a-ha - Take On Me - Short:o=5,d=8,b=160,b=160:f#,f#,f#,d,p,b4,p,e,p,e,p,e,g#,g#,a,b,a,a,a,e,p,d,p,f#,p,f#,'

good_bad_ugly = 'The Good The Bad The Ugly:d=8,o=5,b=125:16a,16d6,16a,16d6,2a,4f,4g,2d,4p,16a,16d6,16a,16d6,2a,4f,4g,2c6,4p,16a,16d6,16a,2d6,4f6,e6,d6,2c6,4p,16a,16d6,16a,16d6,4a.,4g,d,2d'
good_bad_ugly_s = 'The Good The Bad The Ugly - Short:d=8,o=5,b=125:16a,16d6,16a,16d6,2a,4f,4g,2d'

creeds_push_up = 'Creeds - Push Up:d=8,o=5,b=160:b,b,b,g,a,a,a,g,f#,f#,f#,f#,2f#,2p,b,b,b,g,a,a,a,g,f#,f#,f#,f#,2f#,2p, g,g,g,d,a,a,a,g,f#,f#,f#,f#,2f#,2p,g,g,g,d,e,e,e,g,f#,f#,f#,f#,2f#,2p, b,b,b,g,a,a,a,g,f#,f#,f#,f#,4p,b,b,b,g,a,a,a,g,f#,f#,f#,f#,4p, g,g,g,d,a,a,a,g,f#,f#,f#,f#,4p,g,g,g,d,e,e,e,g,f#,f#,f#,f#,4p'
creeds_push_up_s = 'Creeds - Push Up - Short:d=8,o=5,b=160:b,b,b,g,a,a,a,g,f#,f#,f#,f#,2f#'


short_songs = [macarena_s, dump_dump_s, take_on_me_s, good_bad_ugly_s, creeds_push_up_s]
songs = [macarena, dump_dump, william, take_on_me, good_bad_ugly, creeds_push_up]

from fri3d.rtttl import songs, RTTTL

frere_jacques = "Frère Jacques:d=4,o=6,b=112:c,d,e,c,c,d,e,c,e,f,g,p,e,f,g,p,8g,8a,8g,8f,e,c,8g,8a,8g,8f,e,c,c,g5,c,p,c,g5,c"
nokia = "Nokia:d=4,o=5,b=225:8e6,8d6,f#,g#,8c#6,8b,d,e,8b,8a,c#,e,2a"

short_songs = [
songs.macarena_s,
songs.dump_dump_s,
songs.take_on_me_s,
songs.good_bad_ugly_s,
songs.creeds_push_up_s
]

long_songs = [
songs.macarena,
songs.dump_dump,
songs.william,
songs.take_on_me,
songs.good_bad_ugly,
songs.creeds_push_up
]

RTTTL(nokia).play(volume=100)
RTTTL(frere_jacques).play(volume=10)

for song in short_songs:
play_rtttl(song)
RTTTL(song).play()
time.sleep(0.5)

for song in songs:
play_rtttl(song)
for song in long_songs:
RTTTL(song).play()
time.sleep(0.5)
164 changes: 0 additions & 164 deletions fri3d/fri3d_application/src/payload/examples/rtttl/rtttl_player.py

This file was deleted.

7 changes: 3 additions & 4 deletions fri3d/fri3d_application/src/payload/fri3d/badge/buzzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

from fri3d.badge.hardware import hardware_buzzer


buzzer = PWM(
hardware_buzzer.pinout.pin_buzzer,
freq=hardware_buzzer.freq,
duty=hardware_buzzer.duty)
hardware_buzzer.pinout.pin_buzzer,
freq=hardware_buzzer.freq,
duty=hardware_buzzer.duty)
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from .buzzer import hardware_buzzer
from .capabilities import hardware_capabilities
from .display import hardware_display
from .gameon import hardware_gameon
Expand All @@ -6,4 +7,3 @@
from .sao import hardware_sao
from .spi import hardware_spi
from .pinout import hardware_pinout
from .buzzer import hardware_buzzer
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ def __init__(self):
self.duty = 0


hardware_buzzer = HardwareBuzzer()
hardware_buzzer = HardwareBuzzer()
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from .buzzer import hardware_buzzer
from .capabilities import hardware_capabilities
from .display import hardware_display
from .joystick import hardware_joystick
Expand All @@ -6,4 +7,3 @@
from .pinout import hardware_pinout
from .sao import hardware_sao
from .spi import hardware_spi
from .buzzer import hardware_buzzer
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ def __init__(self):
self.duty = 0


hardware_buzzer = HardwareBuzzer()
hardware_buzzer = HardwareBuzzer()
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .rtttl import RTTTL
Loading

0 comments on commit be21597

Please sign in to comment.