For Nikhil
Dependencies: 4DGL-uLCD-SE EthernetInterface Game_Synchronizer MMA8452 SDFileSystem mbed-rtos mbed wave_player
Fork of 2035_Tanks_Shell by
Diff: misc/misc.cpp
- Revision:
- 22:3c68eea5a609
- Parent:
- 20:6a58052b0140
- Child:
- 23:77049670cae6
diff -r edfeb289b21f -r 3c68eea5a609 misc/misc.cpp --- a/misc/misc.cpp Thu Oct 29 03:56:30 2015 +0000 +++ b/misc/misc.cpp Thu Oct 29 05:14:49 2015 +0000 @@ -1,4 +1,11 @@ #include "misc.h" +#include "uLCD_4DGL.h" +#include "SDFileSystem.h" +#include "wave_player.h" + +extern uLCD_4DGL uLCD; +extern wave_player player; + int CONVERT_24_TO_16_BPP(int col_24) { int b = col_24 & 0xFF; @@ -10,4 +17,23 @@ b >>= 3; return r<<11 | g<<5 | b; +} + +// Given the filename of a .wav file in the SD card, play the file over the speaker. +void playSound(char * wav) +{ + // open wav file + FILE *wave_file; + wave_file=fopen(wav,"r"); + + if(wave_file == NULL){ + uLCD.locate(0,4); + uLCD.printf("Error in SD"); + return; + } + // play wav file + player.play(wave_file); + + // close wav file + fclose(wave_file); } \ No newline at end of file