ECE 4180 Final Project

Dependencies:   mbed wave_player 4DGL-uLCD-SE SDFileSystem_OldbutworkswithRTOS PinDetect

Portable Surface Transducer Jukebox

ECE 4180 Final Project

Team members

  • Bruna Correa
  • Lance Hudson
  • Javier Rodriguez

Jukebox Overview

This unique jukebox uses a surface transducer to essentially turn any hard surface (table, etc) into a resonant speaker. The user has the option to select one of out ten songs which were preselected and loaded onto the SD card. To begin, the user types their song choice into the keypad and is prompted to press “START” to begin the song. The user can end the song at any time by pressing “STOP,” which will redirect them back to the original selection menu.

Parts Required

  • 1x Mbed (LPC1768)

Mbed

  • 1x MicroSD card breakout (Sparkfun)

MicroSD Breakout

  • 1x Class D Amp (Sparkfun TPA2005)

Class D Amp

  • 1x Surface conduction transducer speaker (Generic)

Surface Transducer

  • 1x Breadboard speaker

Speaker

  • 2x standard pushbuttons

Pushbutton

  • 1x uLCD (Sparkfun 4DGL)

uLCD Screen

  • 1x Touch capacitance keypad (Sparkfun MPR121)

Touch Pad

  • 2x 6-volt breadboard battery packs

Battery Pack

  • 1x Standard 8x4x4 project box

Project Box

Design Challenges and Tradeoffs

One of the major challenges experienced when developing the Jukebox user interface was the synchronous playback function of the music. This required several instances of interrupt handling and pin detects. More specifically, regarding the “STOP” button, we realized that it was initially not possible to perform any pushbutton polling while the waveplayer function play() is active; if the “STOP” button was pressed while a song is playing, it would only be recognized when the song was finished. Therefore, we looked into editing the waveplayer library itself by passing an extern bool named “play” that was switched to true when “START” is pressed and false when “STOP” is pressed. Inside the play() function we added a logical check to ensure that this play variable is true, and if switched to false, it immediately breaks from the loop, thereby stopping the playback.

Several design tradeoffs had to be made for the benefit of portability. For example, we chose to not implement the original RGB LED strip because it added too much weight and occupied too much space inside the housing for the portable implementation desired. We believe that portability was a more valuable feature for the end user than an LED light show.

Schematic

The schematic used is shown below. For more detailed information on connection declarations and classifications in the software, refer to the code repository.

/media/uploads/jrod1096/schematic.jpeg

Demonstration Video

Committer:
jrod1096
Date:
Wed Dec 12 05:17:58 2018 +0000
Revision:
3:74066405c9fc
Parent:
2:c2afd0c426af
Surface Transducer Jukebox

Who changed what in which revision?

UserRevisionLine numberNew contents of line
4180_1 1:5b8e223e983d 1
4180_1 1:5b8e223e983d 2 #include "mbed.h"
4180_1 1:5b8e223e983d 3 #include "SDFileSystem.h"
4180_1 1:5b8e223e983d 4 #include "wave_player.h"
jrod1096 3:74066405c9fc 5 #include "uLCD_4DGL.h"
jrod1096 3:74066405c9fc 6 #include "mpr121.h"
jrod1096 3:74066405c9fc 7 #include "PinDetect.h"
jrod1096 3:74066405c9fc 8 #include <string>
jrod1096 3:74066405c9fc 9 #include <list>
4180_1 1:5b8e223e983d 10
jrod1096 3:74066405c9fc 11 DigitalOut led1(LED1);
jrod1096 3:74066405c9fc 12 InterruptIn interrupt(p26);
jrod1096 3:74066405c9fc 13 InterruptIn start(p12);
jrod1096 3:74066405c9fc 14 PinDetect stop(p13);
4180_1 1:5b8e223e983d 15
4180_1 1:5b8e223e983d 16 SDFileSystem sd(p5, p6, p7, p8, "sd"); //SD card
jrod1096 3:74066405c9fc 17 uLCD_4DGL uLCD(p9, p10, p11);
jrod1096 3:74066405c9fc 18 Serial pc(USBTX, USBRX);
jrod1096 3:74066405c9fc 19
4180_1 1:5b8e223e983d 20
jrod1096 3:74066405c9fc 21 // Speaker and Class D
jrod1096 3:74066405c9fc 22 AnalogOut speaker(p18);
jrod1096 3:74066405c9fc 23 wave_player waver(&speaker);
jrod1096 3:74066405c9fc 24
jrod1096 3:74066405c9fc 25 // Keypad
jrod1096 3:74066405c9fc 26 I2C i2c(p28, p27);
jrod1096 3:74066405c9fc 27 Mpr121 mpr121(&i2c, Mpr121::ADD_VSS);
jrod1096 3:74066405c9fc 28
jrod1096 3:74066405c9fc 29 int keypad = 0;
jrod1096 3:74066405c9fc 30 string title;
jrod1096 3:74066405c9fc 31 int title_size;
jrod1096 3:74066405c9fc 32 string artist;
jrod1096 3:74066405c9fc 33 int artist_size;
jrod1096 3:74066405c9fc 34
jrod1096 3:74066405c9fc 35
jrod1096 3:74066405c9fc 36 bool newKey = false;
jrod1096 3:74066405c9fc 37 bool play = false;
jrod1096 3:74066405c9fc 38 bool reset = false;
jrod1096 3:74066405c9fc 39
jrod1096 3:74066405c9fc 40 void key () {
jrod1096 3:74066405c9fc 41
jrod1096 3:74066405c9fc 42 newKey = true;
jrod1096 3:74066405c9fc 43
jrod1096 3:74066405c9fc 44 }
jrod1096 3:74066405c9fc 45
jrod1096 3:74066405c9fc 46 void b1 () {
jrod1096 3:74066405c9fc 47
jrod1096 3:74066405c9fc 48 if (keypad != 0) {
jrod1096 3:74066405c9fc 49 play = true;
jrod1096 3:74066405c9fc 50 }
jrod1096 3:74066405c9fc 51
jrod1096 3:74066405c9fc 52 }
jrod1096 3:74066405c9fc 53
jrod1096 3:74066405c9fc 54
jrod1096 3:74066405c9fc 55 void update_screen(int index) {
jrod1096 3:74066405c9fc 56
jrod1096 3:74066405c9fc 57 if (index == 1) { // MENU SCREEN
jrod1096 3:74066405c9fc 58
jrod1096 3:74066405c9fc 59 uLCD.cls();
jrod1096 3:74066405c9fc 60
jrod1096 3:74066405c9fc 61 // Draw border
jrod1096 3:74066405c9fc 62 uLCD.filled_circle(0,0,10,AQUA);
jrod1096 3:74066405c9fc 63 uLCD.filled_circle(0,128,10,AQUA);
jrod1096 3:74066405c9fc 64 uLCD.filled_circle(128,0,10,AQUA);
jrod1096 3:74066405c9fc 65 uLCD.filled_circle(128,128,10,AQUA);
jrod1096 3:74066405c9fc 66 uLCD.filled_rectangle(0,0,128,3,AQUA);
jrod1096 3:74066405c9fc 67 uLCD.filled_rectangle(124,0,128,128,AQUA);
jrod1096 3:74066405c9fc 68 uLCD.filled_rectangle(0,0,3,128,AQUA);
jrod1096 3:74066405c9fc 69 uLCD.filled_rectangle(0,125,128,128,AQUA);
jrod1096 3:74066405c9fc 70
jrod1096 3:74066405c9fc 71 // Print title
jrod1096 3:74066405c9fc 72 uLCD.color(AQUA);
jrod1096 3:74066405c9fc 73 uLCD.text_width(2.5);
jrod1096 3:74066405c9fc 74 uLCD.text_height(2.5);
jrod1096 3:74066405c9fc 75 uLCD.locate(1,1);
jrod1096 3:74066405c9fc 76 uLCD.printf("JUKEBOX");
jrod1096 3:74066405c9fc 77
jrod1096 3:74066405c9fc 78 // Print menu information
jrod1096 3:74066405c9fc 79 uLCD.color(TEAL);
jrod1096 3:74066405c9fc 80 uLCD.text_width(1);
jrod1096 3:74066405c9fc 81 uLCD.text_height(1);
jrod1096 3:74066405c9fc 82 uLCD.locate(3,5);
jrod1096 3:74066405c9fc 83 uLCD.printf(" Welcome!\r\n");
jrod1096 3:74066405c9fc 84 uLCD.locate(2,6);
jrod1096 3:74066405c9fc 85 uLCD.printf("Please make a \r\n");
jrod1096 3:74066405c9fc 86 uLCD.locate(2,7);
jrod1096 3:74066405c9fc 87 uLCD.printf("song selection.\r\n");
jrod1096 3:74066405c9fc 88 uLCD.locate(1,9);
jrod1096 3:74066405c9fc 89 uLCD.printf(" Then hit PLAY!\r\n");
jrod1096 3:74066405c9fc 90 uLCD.filled_rectangle(15,90,114,90, GREEN);
jrod1096 3:74066405c9fc 91 uLCD.filled_rectangle(15,110,114,110, GREEN);
jrod1096 3:74066405c9fc 92 uLCD.filled_rectangle(15,90,15,110, GREEN);
jrod1096 3:74066405c9fc 93 uLCD.filled_rectangle(114,90,114,110, GREEN);
jrod1096 3:74066405c9fc 94
jrod1096 3:74066405c9fc 95 } else if (index == 2) { // SONG CHOICE
jrod1096 3:74066405c9fc 96
jrod1096 3:74066405c9fc 97 // Print KEYPAD selection
jrod1096 3:74066405c9fc 98 uLCD.text_width(1);
jrod1096 3:74066405c9fc 99 uLCD.text_height(1);
jrod1096 3:74066405c9fc 100 uLCD.locate(6,12);
jrod1096 3:74066405c9fc 101 uLCD.color(GREEN);
jrod1096 3:74066405c9fc 102 if (keypad > 0) {
jrod1096 3:74066405c9fc 103 if (keypad < 10) {
jrod1096 3:74066405c9fc 104 uLCD.printf("Song 0%i\r\n",keypad);
jrod1096 3:74066405c9fc 105 } else {
jrod1096 3:74066405c9fc 106 uLCD.printf("Song %i\r\n",keypad);
jrod1096 3:74066405c9fc 107 }
jrod1096 3:74066405c9fc 108 }
jrod1096 3:74066405c9fc 109
jrod1096 3:74066405c9fc 110 } else if (index == 3) { // NOW PLAYING
4180_1 1:5b8e223e983d 111
jrod1096 3:74066405c9fc 112 uLCD.cls();
jrod1096 3:74066405c9fc 113
jrod1096 3:74066405c9fc 114 // Draw border
jrod1096 3:74066405c9fc 115 uLCD.filled_circle(0,0,10,AQUA);
jrod1096 3:74066405c9fc 116 uLCD.filled_circle(0,128,10,AQUA);
jrod1096 3:74066405c9fc 117 uLCD.filled_circle(128,0,10,AQUA);
jrod1096 3:74066405c9fc 118 uLCD.filled_circle(128,128,10,AQUA);
jrod1096 3:74066405c9fc 119 uLCD.filled_rectangle(0,0,128,3,AQUA);
jrod1096 3:74066405c9fc 120 uLCD.filled_rectangle(124,0,128,128,AQUA);
jrod1096 3:74066405c9fc 121 uLCD.filled_rectangle(0,0,3,128,AQUA);
jrod1096 3:74066405c9fc 122 uLCD.filled_rectangle(0,125,128,128,AQUA);
jrod1096 3:74066405c9fc 123
jrod1096 3:74066405c9fc 124 // Print NOW PLAYING
jrod1096 3:74066405c9fc 125 uLCD.color(AQUA);
jrod1096 3:74066405c9fc 126 uLCD.locate(1,2);
jrod1096 3:74066405c9fc 127 uLCD.text_width(1);
jrod1096 3:74066405c9fc 128 uLCD.text_height(1);
jrod1096 3:74066405c9fc 129 uLCD.printf(" Now playing...");
jrod1096 3:74066405c9fc 130 uLCD.color(GREEN);
jrod1096 3:74066405c9fc 131 uLCD.text_width(1);
jrod1096 3:74066405c9fc 132 uLCD.text_height(1);
jrod1096 3:74066405c9fc 133 uLCD.locate(1,5);
jrod1096 3:74066405c9fc 134 uLCD.printf("%s\r\n",title); // song title
jrod1096 3:74066405c9fc 135 uLCD.locate(1,7);
jrod1096 3:74066405c9fc 136 uLCD.printf("%s\r\n",artist);
jrod1096 3:74066405c9fc 137 uLCD.filled_rectangle(15,35,114,35, GREEN);
jrod1096 3:74066405c9fc 138 uLCD.filled_rectangle(15,67,114,67, GREEN);
jrod1096 3:74066405c9fc 139 uLCD.filled_rectangle(15,35,15,67, GREEN);
jrod1096 3:74066405c9fc 140 uLCD.filled_rectangle(114,35,114,67, GREEN);
jrod1096 3:74066405c9fc 141
4180_1 1:5b8e223e983d 142
jrod1096 3:74066405c9fc 143 // MUSIC SYMBOL #1
jrod1096 3:74066405c9fc 144 uLCD.filled_rectangle(30,76,45,78, BLUE);
jrod1096 3:74066405c9fc 145 uLCD.filled_rectangle(30,76,32,91,BLUE);
jrod1096 3:74066405c9fc 146 uLCD.filled_rectangle(43,76,45,91,BLUE);
jrod1096 3:74066405c9fc 147 uLCD.filled_circle(29,91,3,BLUE);
jrod1096 3:74066405c9fc 148 uLCD.filled_circle(42,91,3,BLUE);
jrod1096 3:74066405c9fc 149
jrod1096 3:74066405c9fc 150
jrod1096 3:74066405c9fc 151 // MUSIC SYMBOL #2
jrod1096 3:74066405c9fc 152 uLCD.filled_rectangle(58,84,73,86,PURPLE);
jrod1096 3:74066405c9fc 153 uLCD.filled_rectangle(58,84,60,99,PURPLE);
jrod1096 3:74066405c9fc 154 uLCD.filled_rectangle(71,84,73,99,PURPLE);
jrod1096 3:74066405c9fc 155 uLCD.filled_circle(56,99,3,PURPLE);
jrod1096 3:74066405c9fc 156 uLCD.filled_circle(70,99,3,PURPLE);
jrod1096 3:74066405c9fc 157
jrod1096 3:74066405c9fc 158 // MUSIC SYMBOL #3
jrod1096 3:74066405c9fc 159 uLCD.filled_rectangle(87,76,102,78, PINK);
jrod1096 3:74066405c9fc 160 uLCD.filled_rectangle(87,76,89,91,PINK);
jrod1096 3:74066405c9fc 161 uLCD.filled_rectangle(100,76,102,91,PINK);
jrod1096 3:74066405c9fc 162 uLCD.filled_circle(86,91,3,PINK);
jrod1096 3:74066405c9fc 163 uLCD.filled_circle(99,91,3,PINK);
jrod1096 3:74066405c9fc 164
jrod1096 3:74066405c9fc 165
jrod1096 3:74066405c9fc 166
jrod1096 3:74066405c9fc 167 // Print STOP message
jrod1096 3:74066405c9fc 168 uLCD.color(RED);
jrod1096 3:74066405c9fc 169 uLCD.text_width(1.0);
jrod1096 3:74066405c9fc 170 uLCD.text_height(1.0);
jrod1096 3:74066405c9fc 171 uLCD.locate(1,14);
jrod1096 3:74066405c9fc 172 uLCD.printf(" Hit STOP to end");
jrod1096 3:74066405c9fc 173
jrod1096 3:74066405c9fc 174 }
jrod1096 3:74066405c9fc 175
jrod1096 3:74066405c9fc 176 }
jrod1096 3:74066405c9fc 177
jrod1096 3:74066405c9fc 178 void get_song() {
jrod1096 3:74066405c9fc 179
jrod1096 3:74066405c9fc 180 // Read value
jrod1096 3:74066405c9fc 181 int value=mpr121.read(0x00);
jrod1096 3:74066405c9fc 182 value +=mpr121.read(0x01)<<8;
jrod1096 3:74066405c9fc 183
jrod1096 3:74066405c9fc 184 // Match keypad value to number
jrod1096 3:74066405c9fc 185 switch (value) {
jrod1096 3:74066405c9fc 186 case 2:
jrod1096 3:74066405c9fc 187 keypad = 1;
jrod1096 3:74066405c9fc 188 break;
jrod1096 3:74066405c9fc 189 case 4:
jrod1096 3:74066405c9fc 190 keypad = 2;
jrod1096 3:74066405c9fc 191 break;
jrod1096 3:74066405c9fc 192 case 8:
jrod1096 3:74066405c9fc 193 keypad = 3;
jrod1096 3:74066405c9fc 194 break;
jrod1096 3:74066405c9fc 195 case 16:
jrod1096 3:74066405c9fc 196 keypad = 4;
jrod1096 3:74066405c9fc 197 break;
jrod1096 3:74066405c9fc 198 case 32:
jrod1096 3:74066405c9fc 199 keypad = 5;
jrod1096 3:74066405c9fc 200 break;
jrod1096 3:74066405c9fc 201 case 64:
jrod1096 3:74066405c9fc 202 keypad = 6;
jrod1096 3:74066405c9fc 203 break;
jrod1096 3:74066405c9fc 204 case 128:
jrod1096 3:74066405c9fc 205 keypad = 7;
jrod1096 3:74066405c9fc 206 break;
jrod1096 3:74066405c9fc 207 case 256:
jrod1096 3:74066405c9fc 208 keypad = 8;
jrod1096 3:74066405c9fc 209 break;
jrod1096 3:74066405c9fc 210 case 512:
jrod1096 3:74066405c9fc 211 keypad = 9;
jrod1096 3:74066405c9fc 212 break;
jrod1096 3:74066405c9fc 213 case 1024:
jrod1096 3:74066405c9fc 214 keypad = 10;
jrod1096 3:74066405c9fc 215 break;
jrod1096 3:74066405c9fc 216 }
jrod1096 3:74066405c9fc 217
jrod1096 3:74066405c9fc 218 update_screen(2);
jrod1096 3:74066405c9fc 219
jrod1096 3:74066405c9fc 220 }
jrod1096 3:74066405c9fc 221
jrod1096 3:74066405c9fc 222
jrod1096 3:74066405c9fc 223 void play_song() {
jrod1096 3:74066405c9fc 224
4180_1 1:5b8e223e983d 225 FILE *wave_file;
jrod1096 3:74066405c9fc 226 switch (keypad) {
jrod1096 3:74066405c9fc 227 case 1:
jrod1096 3:74066405c9fc 228 wave_file=fopen("/sd/wavfiles/dura.wav","r");
jrod1096 3:74066405c9fc 229 title = " Dura";
jrod1096 3:74066405c9fc 230 artist = " Daddy Yankee";
jrod1096 3:74066405c9fc 231 title_size = 1;
jrod1096 3:74066405c9fc 232 artist_size = 1;
jrod1096 3:74066405c9fc 233 break;
jrod1096 3:74066405c9fc 234 case 2:
jrod1096 3:74066405c9fc 235 wave_file=fopen("/sd/wavfiles/despacito.wav","r");
jrod1096 3:74066405c9fc 236 title = " Despacito";
jrod1096 3:74066405c9fc 237 artist = " Luis Fonsi";
jrod1096 3:74066405c9fc 238 title_size = 1;
jrod1096 3:74066405c9fc 239 artist_size = 1;
jrod1096 3:74066405c9fc 240 break;
jrod1096 3:74066405c9fc 241 case 3:
jrod1096 3:74066405c9fc 242 wave_file=fopen("/sd/wavfiles/disco.wav","r");
jrod1096 3:74066405c9fc 243 title = " Disco";
jrod1096 3:74066405c9fc 244 artist = " Maxine Night";
jrod1096 3:74066405c9fc 245 title_size = 1;
jrod1096 3:74066405c9fc 246 artist_size = 1;
jrod1096 3:74066405c9fc 247 break;
jrod1096 3:74066405c9fc 248 case 4:
jrod1096 3:74066405c9fc 249 wave_file=fopen("/sd/wavfiles/california.wav","r");
jrod1096 3:74066405c9fc 250 title = " California";
jrod1096 3:74066405c9fc 251 artist = " Phantom ";
jrod1096 3:74066405c9fc 252 title_size = 1;
jrod1096 3:74066405c9fc 253 artist_size = 1;
jrod1096 3:74066405c9fc 254 break;
jrod1096 3:74066405c9fc 255 case 5:
jrod1096 3:74066405c9fc 256 wave_file=fopen("/sd/wavfiles/christmas.wav","r");
jrod1096 3:74066405c9fc 257 title = " All I Want";
jrod1096 3:74066405c9fc 258 artist = " Mariah Carey";
jrod1096 3:74066405c9fc 259 title_size = 1;
jrod1096 3:74066405c9fc 260 artist_size = 1;
jrod1096 3:74066405c9fc 261 break;
jrod1096 3:74066405c9fc 262 case 6:
jrod1096 3:74066405c9fc 263 wave_file=fopen("/sd/wavfiles/beethoven.wav","r");
jrod1096 3:74066405c9fc 264 title = " Symphony 9";
jrod1096 3:74066405c9fc 265 artist = " Beethoven";
jrod1096 3:74066405c9fc 266 title_size = 1;
jrod1096 3:74066405c9fc 267 artist_size = 1;
jrod1096 3:74066405c9fc 268 break;
jrod1096 3:74066405c9fc 269 case 7:
jrod1096 3:74066405c9fc 270 wave_file=fopen("/sd/wavfiles/queen.wav","r");
jrod1096 3:74066405c9fc 271 title = " Rock You";
jrod1096 3:74066405c9fc 272 artist = " Queen";
jrod1096 3:74066405c9fc 273 title_size = 1;
jrod1096 3:74066405c9fc 274 artist_size = 1;
jrod1096 3:74066405c9fc 275 break;
jrod1096 3:74066405c9fc 276 case 8:
jrod1096 3:74066405c9fc 277 wave_file=fopen("/sd/wavfiles/losing_it.wav","r");
jrod1096 3:74066405c9fc 278 title = " Losing It";
jrod1096 3:74066405c9fc 279 artist = " Fisher";
jrod1096 3:74066405c9fc 280 title_size = 1;
jrod1096 3:74066405c9fc 281 artist_size = 1;
jrod1096 3:74066405c9fc 282 break;
jrod1096 3:74066405c9fc 283 case 9:
jrod1096 3:74066405c9fc 284 wave_file=fopen("/sd/wavfiles/better_not.wav","r");
jrod1096 3:74066405c9fc 285 title = " Better Not";
jrod1096 3:74066405c9fc 286 artist = " Louis TC";
jrod1096 3:74066405c9fc 287 title_size = 1;
jrod1096 3:74066405c9fc 288 artist_size = 1;
jrod1096 3:74066405c9fc 289 break;
jrod1096 3:74066405c9fc 290 case 10:
jrod1096 3:74066405c9fc 291 wave_file=fopen("/sd/wavfiles/drinkee.wav","r");
jrod1096 3:74066405c9fc 292 title = " Drinkee";
jrod1096 3:74066405c9fc 293 artist = " Sofi Tukker";
jrod1096 3:74066405c9fc 294 title_size = 1;
jrod1096 3:74066405c9fc 295 artist_size = 1;
jrod1096 3:74066405c9fc 296 break;
jrod1096 3:74066405c9fc 297 }
jrod1096 3:74066405c9fc 298 update_screen(3);
jrod1096 3:74066405c9fc 299 waver.play(wave_file);
jrod1096 3:74066405c9fc 300 fclose(wave_file);
jrod1096 3:74066405c9fc 301
jrod1096 3:74066405c9fc 302
jrod1096 3:74066405c9fc 303
jrod1096 3:74066405c9fc 304 }
jrod1096 3:74066405c9fc 305
jrod1096 3:74066405c9fc 306
jrod1096 3:74066405c9fc 307 void stop_song() {
jrod1096 3:74066405c9fc 308
jrod1096 3:74066405c9fc 309 play = false;
jrod1096 3:74066405c9fc 310
jrod1096 3:74066405c9fc 311
jrod1096 3:74066405c9fc 312 }
jrod1096 3:74066405c9fc 313
jrod1096 3:74066405c9fc 314
jrod1096 3:74066405c9fc 315
jrod1096 3:74066405c9fc 316 int main(){
jrod1096 3:74066405c9fc 317
jrod1096 3:74066405c9fc 318
jrod1096 3:74066405c9fc 319 interrupt.mode(PullUp);
jrod1096 3:74066405c9fc 320 start.mode(PullUp);
jrod1096 3:74066405c9fc 321 interrupt.fall(&key);
jrod1096 3:74066405c9fc 322 start.fall(&b1);
jrod1096 3:74066405c9fc 323 stop.mode(PullUp);
jrod1096 3:74066405c9fc 324 wait_ms(10);
jrod1096 3:74066405c9fc 325 stop.attach_deasserted(&stop_song);
jrod1096 3:74066405c9fc 326 stop.setSampleFrequency();
jrod1096 3:74066405c9fc 327
jrod1096 3:74066405c9fc 328
jrod1096 3:74066405c9fc 329
jrod1096 3:74066405c9fc 330
jrod1096 3:74066405c9fc 331 while(1) { // One jukebox cycle
jrod1096 3:74066405c9fc 332
jrod1096 3:74066405c9fc 333
jrod1096 3:74066405c9fc 334 // Reset, draw menu screen
jrod1096 3:74066405c9fc 335 keypad = 0;
jrod1096 3:74066405c9fc 336 update_screen(1);
jrod1096 3:74066405c9fc 337
jrod1096 3:74066405c9fc 338 // Wait for user to select song AND press play
jrod1096 3:74066405c9fc 339 while ((keypad == 0)||(play==false)) {
jrod1096 3:74066405c9fc 340 if (newKey) {
jrod1096 3:74066405c9fc 341 newKey = false;
jrod1096 3:74066405c9fc 342 get_song();
jrod1096 3:74066405c9fc 343 }
jrod1096 3:74066405c9fc 344 }
jrod1096 3:74066405c9fc 345
jrod1096 3:74066405c9fc 346 play_song();
jrod1096 3:74066405c9fc 347
jrod1096 3:74066405c9fc 348 // Reset values before starting again
jrod1096 3:74066405c9fc 349 play = false;
jrod1096 3:74066405c9fc 350 newKey = false;
jrod1096 3:74066405c9fc 351 keypad = 0;
jrod1096 3:74066405c9fc 352
jrod1096 3:74066405c9fc 353
jrod1096 3:74066405c9fc 354
jrod1096 3:74066405c9fc 355 }
jrod1096 3:74066405c9fc 356
jrod1096 3:74066405c9fc 357
jrod1096 3:74066405c9fc 358
4180_1 1:5b8e223e983d 359 }