ECE 4180 Final
Dependencies: mbed wave_player mbed-rtos C12832_lcd 4DGL-uLCD-SE LCD_fonts SDFileSystem
Revision 18:c760ba93b881, committed 2019-12-05
- Comitter:
- jcrane32
- Date:
- Thu Dec 05 04:43:25 2019 +0000
- Parent:
- 7:15fdc55dbf66
- Commit message:
- Added support to play songs from .h files and added necessary variables.
Changed in this revision
--- a/bubbles.h Thu Dec 05 03:21:55 2019 +0000 +++ b/bubbles.h Thu Dec 05 04:43:25 2019 +0000 @@ -1,3 +1,63 @@ +const unsigned short fireflies_bubbles[58][5] = { +1, 0, 1, 0, 0, +2, 0, 0, 1, 0, +3, 0, 1, 0, 0, +4, 0, 0, 1, 0, +5, 0, 1, 0, 0, +6, 0, 0, 1, 0, +7, 0, 1, 0, 0, +8, 0, 0, 1, 0, +9, 0, 1, 0, 0, +10, 0, 0, 1, 0, +11, 0, 0, 0, 1, +12, 0, 0, 1, 0, +13, 0, 1, 0, 0, +14, 0, 0, 1, 0, +15, 0, 0, 0, 1, +16, 0, 1, 1, 0, +17, 0, 1, 1, 0, +18, 0, 0, 1, 1, +19, 0, 0, 1, 1, +21, 0, 0, 1, 0, +22, 0, 0, 1, 0, +23, 0, 0, 1, 0, +24, 0, 0, 1, 0, +25, 0, 1, 0, 0, +26, 0, 1, 0, 0, +27, 0, 0, 1, 0, +28, 0, 0, 1, 0, +29, 0, 0, 0, 1, +30, 0, 0, 0, 1, +32, 0, 1, 0, 0, +33, 0, 1, 0, 0, +34, 0, 0, 1, 0, +35, 0, 0, 1, 0, +36, 0, 0, 0, 1, +37, 0, 0, 0, 1, +38, 0, 0, 1, 0, +39, 0, 0, 1, 0, +40, 0, 1, 0, 0, +41, 0, 1, 0, 0, +43, 0, 1, 1, 1, +44, 0, 1, 1, 1, +45, 0, 1, 1, 1, +46, 0, 1, 1, 1, +47, 0, 1, 1, 0, +48, 0, 1, 1, 0, +49, 0, 0, 1, 1, +50, 0, 0, 1, 1, +51, 0, 0, 1, 1, +53, 0, 1, 1, 0, +54, 0, 1, 1, 0, +55, 0, 0, 1, 1, +56, 0, 1, 1, 0, +57, 0, 0, 1, 1, +59, 0, 1, 0, 0, +60, 0, 0, 1, 0, +61, 0, 0, 0, 1, +62, 0, 0, 1, 0, +63, 0, 1, 0, 0}; + const unsigned short the_middle_bubbles[62][5] = {2, 0, 1, 0, 0, 3, 0, 1, 0, 0, 4, 0, 1, 0, 0, @@ -193,63 +253,3 @@ 64, 0, 1, 1, 0, 65, 0, 1, 1, 0, 66, 0, 1, 1, 0}; - -const unsigned short fireflies_bubbles[58][5] = { -1, 0, 1, 0, 0, -2, 0, 0, 1, 0, -3, 0, 1, 0, 0, -4, 0, 0, 1, 0, -5, 0, 1, 0, 0, -6, 0, 0, 1, 0, -7, 0, 1, 0, 0, -8, 0, 0, 1, 0, -9, 0, 1, 0, 0, -10, 0, 0, 1, 0, -11, 0, 0, 0, 1, -12, 0, 0, 1, 0, -13, 0, 1, 0, 0, -14, 0, 0, 1, 0, -15, 0, 0, 0, 1, -16, 0, 1, 1, 0, -17, 0, 1, 1, 0, -18, 0, 0, 1, 1, -19, 0, 0, 1, 1, -21, 0, 0, 1, 0, -22, 0, 0, 1, 0, -23, 0, 0, 1, 0, -24, 0, 0, 1, 0, -25, 0, 1, 0, 0, -26, 0, 1, 0, 0, -27, 0, 0, 1, 0, -28, 0, 0, 1, 0, -29, 0, 0, 0, 1, -30, 0, 0, 0, 1, -32, 0, 1, 0, 0, -33, 0, 1, 0, 0, -34, 0, 0, 1, 0, -35, 0, 0, 1, 0, -36, 0, 0, 0, 1, -37, 0, 0, 0, 1, -38, 0, 0, 1, 0, -39, 0, 0, 1, 0, -40, 0, 1, 0, 0, -41, 0, 1, 0, 0, -43, 0, 1, 1, 1, -44, 0, 1, 1, 1, -45, 0, 1, 1, 1, -46, 0, 1, 1, 1, -47, 0, 1, 1, 0, -48, 0, 1, 1, 0, -49, 0, 0, 1, 1, -50, 0, 0, 1, 1, -51, 0, 0, 1, 1, -53, 0, 1, 1, 0, -54, 0, 1, 1, 0, -55, 0, 0, 1, 1, -56, 0, 1, 1, 0, -57, 0, 0, 1, 1, -59, 0, 1, 0, 0, -60, 0, 0, 1, 0, -61, 0, 0, 0, 1, -62, 0, 0, 1, 0, -63, 0, 1, 0, 0}; \ No newline at end of file
--- a/main.cpp Thu Dec 05 03:21:55 2019 +0000 +++ b/main.cpp Thu Dec 05 04:43:25 2019 +0000 @@ -38,10 +38,12 @@ Thread thread1, thread2, thread3; Ticker nextsample; int songNdx = 0; +int songnum = 1; +const unsigned short *playingSong = NULL; // mutex to make the lcd lib thread safe Mutex lcd_mutex; -int songnum = 1; + AnalogIn joy_pot(p16); // Thread 1 @@ -128,8 +130,8 @@ // this thread plays music using the ticker class void playsound() { if (playing) { - //DACout = song[songNdx++]; - //if (i>**songlength**) i + DACout = playingSong[songNdx++]; +// if (i>**songlength**) i } else { DACout = 0; songNdx = 0; @@ -145,19 +147,21 @@ // nextsample.attach(&playsound, 1.0/8000.0); //startup sound myRGBled = blue; //tested to make sure led works, we can use whatever color(s) here - FILE *wave_file; - wave_file=fopen("/sd/cheer.wav","r"); - waver.play(wave_file); - fclose(wave_file); +// FILE *wave_file; +// wave_file=fopen("/sd/cheer.wav","r"); +// waver.play(wave_file); +// fclose(wave_file); while(1) { if (songselect){ + myRGBled = yellow; myled = 0; + playing = true; homescreen = false; lcd_mutex.lock(); uLCD.cls(); - uLCD.printf("You selected song %2d",songnum); + uLCD.printf("You selected song %2d", songnum); lcd_mutex.unlock(); //add case statement based on songnum or something //code for playing song from sd @@ -165,38 +169,42 @@ { case 1: { - FILE *wave_file; - wave_file =fopen("/sd/4180 final project/Fireflies.wav", "r"); - waver.play(wave_file); - fclose(wave_file); - break; + playingSong = fireflies; + // FILE *wave_file; + // wave_file =fopen("/sd/4180 final project/Fireflies.wav", "r"); + // waver.play(wave_file); + // fclose(wave_file); + break; } case 2: { - FILE *wave_file; - wave_file =fopen("/sd/4180 final project/The_Middle.wav", "r"); - waver.play(wave_file); - fclose(wave_file); - break; + playingSong = the_middle; + // FILE *wave_file; + // wave_file =fopen("/sd/4180 final project/The_Middle.wav", "r"); + // waver.play(wave_file); + // fclose(wave_file); + break; } case 3: { - FILE *wave_file; - wave_file =fopen("/sd/4180 final project/Stacy's_Mom.wav", "r"); - waver.play(wave_file); - fclose(wave_file); - break; + playingSong = stacys_mom; + // FILE *wave_file; + // wave_file =fopen("/sd/4180 final project/Stacy's_Mom.wav", "r"); + // waver.play(wave_file); + // fclose(wave_file); + break; } case 4: { - FILE *wave_file; - wave_file =fopen("/sd/4180 final project/Sins_!_Tragedies.wav", "r"); - waver.play(wave_file); - fclose(wave_file); - break; + playingSong = sins; + // FILE *wave_file; + // wave_file =fopen("/sd/4180 final project/Sins_!_Tragedies.wav", "r"); + // waver.play(wave_file); + // fclose(wave_file); + break; } default: - break; + break; } }
--- a/songs.h Thu Dec 05 03:21:55 2019 +0000 +++ b/songs.h Thu Dec 05 04:43:25 2019 +0000 @@ -1,4 +1,4 @@ -//const unsigned short the_middle[]; -//const unsigned short stacys_mom[]; -//const unsigned short sins[]; -//const unsigned short fireflies[]; +const unsigned short fireflies[1] = {1}; +const unsigned short the_middle[1] = {1}; +const unsigned short stacys_mom[1] = {1}; +const unsigned short sins[1] = {1}; \ No newline at end of file