|
37 | 37 | BTW_REPEAT_THRESHOLD = 25
|
38 | 38 | intermission_played_songs = deque([])
|
39 | 39 | INTERMISSION_REPEAT_THRESHOLD = 3
|
| 40 | +goal_played_songs = deque([]) |
| 41 | +GOAL_REPEAT_THRESHOLD = 4 |
| 42 | +penalty_played_songs = deque([]) |
| 43 | +PENALTY_REPEAT_THRESHOLD = 4 |
| 44 | +powerplay_played_songs = deque([]) |
| 45 | +POWERPLAY_REPEAT_THRESHOLD = 4 |
40 | 46 |
|
41 | 47 | #
|
42 | 48 | # GPIO Setup
|
@@ -148,7 +154,20 @@ def play_song(p_song):
|
148 | 154 | def play_goal(channel):
|
149 | 155 | print "GOAL"
|
150 | 156 | change_lights_after_input(OUTPUT_GOAL)
|
151 |
| - play_song(pick_random_song(GOAL_MP3_DIR)) |
| 157 | + new_song = "" |
| 158 | + while True: |
| 159 | + new_song = pick_random_song(GOAL_MP3_DIR) |
| 160 | + if new_song in goal_played_songs: |
| 161 | + print "Song %s has already been played, skipping." % new_song |
| 162 | + else: |
| 163 | + goal_played_songs.append(new_song) |
| 164 | + break; |
| 165 | + |
| 166 | + # Keep list at GOAL_REPEAT_THRESHOLD |
| 167 | + if len(goal_played_songs) > GOAL_REPEAT_THRESHOLD: |
| 168 | + print "Removing %s from goal_played_songs list" % goal_played_songs[0] |
| 169 | + goal_played_songs.popleft() |
| 170 | + play_song(new_song) |
152 | 171 |
|
153 | 172 | #
|
154 | 173 | # WARM-UP
|
@@ -180,15 +199,41 @@ def play_cdnanthem(channel):
|
180 | 199 | def play_penalty(channel):
|
181 | 200 | print "PENALTY"
|
182 | 201 | change_lights_after_input(OUTPUT_PENALTY)
|
183 |
| - play_song(pick_random_song(PENALTY_MP3_DIR)) |
| 202 | + new_song = "" |
| 203 | + while True: |
| 204 | + new_song = pick_random_song(PENALTY_MP3_DIR) |
| 205 | + if new_song in penalty_played_songs: |
| 206 | + print "Song %s has already been played, skipping." % new_song |
| 207 | + else: |
| 208 | + penalty_played_songs.append(new_song) |
| 209 | + break; |
| 210 | + |
| 211 | + # Keep list at PENALTY_REPEAT_THRESHOLD |
| 212 | + if len(penalty_played_songs) > PENALTY_REPEAT_THRESHOLD: |
| 213 | + print "Removing %s from penalty_played_songs list" % penalty_played_songs[0] |
| 214 | + penalty_played_songs.popleft() |
| 215 | + play_song(new_song) |
184 | 216 |
|
185 | 217 | #
|
186 | 218 | # POWERPLAY
|
187 | 219 | #
|
188 | 220 | def play_powerplay(channel):
|
189 | 221 | print "POWERPLAY"
|
190 | 222 | change_lights_after_input(OUTPUT_POWERPLAY)
|
191 |
| - play_song(pick_random_song(POWERPLAY_MP3_DIR)) |
| 223 | + new_song = "" |
| 224 | + while True: |
| 225 | + new_song = pick_random_song(POWERPLAY_MP3_DIR) |
| 226 | + if new_song in powerplay_played_songs: |
| 227 | + print "Song %s has already been played, skipping." % new_song |
| 228 | + else: |
| 229 | + powerplay_played_songs.append(new_song) |
| 230 | + break; |
| 231 | + |
| 232 | + # Keep list at POWERPLAY_REPEAT_THRESHOLD |
| 233 | + if len(powerplay_played_songs) > POWERPLAY_REPEAT_THRESHOLD: |
| 234 | + print "Removing %s from powerplay_played_songs list" % powerplay_played_songs[0] |
| 235 | + powerplay_played_songs.popleft() |
| 236 | + play_song(new_song) |
192 | 237 |
|
193 | 238 | #
|
194 | 239 | # INTERMISSION
|
|
0 commit comments