-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstarwars.py
112 lines (103 loc) · 2.63 KB
/
starwars.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# Taken from
# https://gist.github.com/thenoviceoof/5465084
# but modified to work on my Roomba 770
import time
import create
#ROOMBA_PORT = "/dev/tty.usbserial-DA017V6X"
ROOMBA_PORT = "/dev/rfcomm0"
# define silence
r = 30
# map note names in the lilypad notation to irobot commands
c4 = 60
cis4 = des4 = 61
d4 = 62
dis4 = ees4 = 63
e4 = 64
f4 = 65
fis4 = ges4 = 66
g4 = 67
gis4 = aes4 = 68
a4 = 69
ais4 = bes4 = 70
b4 = 71
c5 = 72
cis5 = des5 = 73
d5 = 74
dis5 = ees5 = 75
e5 = 76
f5 = 77
fis5 = ges5 = 78
g5 = 79
gis5 = aes5 = 80
a5 = 81
ais5 = bes5 = 82
b5 = 83
c6 = 84
cis6 = des6 = 85
d6 = 86
dis6 = ees6 = 87
e6 = 88
f6 = 89
fis6 = ges6 = 90
# define some note lengths
# change the top MEASURE (4/4 time) to get faster/slower speeds
MEASURE = 160
HALF = MEASURE/2
Q = MEASURE/4
E = MEASURE/8
Ed = MEASURE*3/16
S = MEASURE/16
MEASURE_TIME = MEASURE/64.
def play_starwars(robot):
starwars1 = [(a4,Q), (a4,Q), (a4,Q), (f4,Ed), (c5,S), (a4,Q), (f4,Ed), (c5,S), (a4,HALF)]
starwars2 = [(e5,Q), (e5,Q), (e5,Q), (f5,Ed), (c5,S),(aes4,Q), (f4,Ed), (c5,S), (a4,HALF)]
starwars3 = [(a5,Q), (a4,Ed), (a4,S), (a5,Q), (aes5,E), (g5,E),(ges5,S), (f5,S), (ges5,S)]
starwars4 = [(r,E), (bes4,E), (ees5,Q), (d5,E), (des5,E),(c5,S), (b4,S), (c5,E), (c5,E)]
starwars5 = [(r,E), (f4,E), (aes4,Q), (f4,Ed), (aes4,S),(c5,Q), (a4,Ed), (c5,S), (e5,HALF)]
starwars6 = [(r,E), (f4,E), (aes4,Q), (f4,Ed), (c5,S),(a4,Q), (f4,Ed), (c5,S), (a4,HALF)]
telekom = [(c4,S), (c4,S), (c4,S), (e4,S), (c4,Q)]
print("uploading songs")
robot.setSong( 1, starwars1 )
robot.setSong( 2, starwars2 )
robot.setSong( 3, starwars3 )
time.sleep(2.0)
print("playing part 1")
robot.playSongNumber(1)
time.sleep(MEASURE_TIME*2.01)
print("playing part 2")
robot.playSongNumber(2)
time.sleep(MEASURE_TIME*2.01)
print("playing part 3")
robot.playSongNumber(3)
robot.setSong( 1, starwars4 )
time.sleep(MEASURE_TIME*1.26)
print("playing part 4")
robot.playSongNumber(1)
robot.setSong( 2, starwars5 )
time.sleep(MEASURE_TIME*1.15)
print("playing part 5")
robot.playSongNumber(2)
robot.setSong( 3, starwars3 )
time.sleep(MEASURE_TIME*1.76)
print("playing part 3 again")
robot.playSongNumber(3)
robot.setSong( 2, starwars6 )
time.sleep(MEASURE_TIME*1.26)
print("playing part 4 again")
robot.playSongNumber(1)
time.sleep(MEASURE_TIME*1.15)
print("playing part 6")
robot.playSongNumber(2)
robot.setSong( 1, telekom )
time.sleep(MEASURE_TIME*1.76)
robot.playSongNumber(1)
print("done")
robot.setSong( 2, telekom )
time.sleep(5)
robot.playSongNumber(2)
"""
robot = create.Create(ROOMBA_PORT)
robot.toSafeMode()
play_starwars(robot)
robot.close()
"""