SharpShooter
Dependencies: 4DGL-uLCD-SE SDFileSystem mbed-rtos mbed wave_player
main.cpp
- Committer:
- jboettcher
- Date:
- 2016-10-28
- Revision:
- 5:f51cdddf541e
- Parent:
- 1:8a3fa9e90572
File content as of revision 5:f51cdddf541e:
#include "mbed.h" #include "Speaker.h" #include "uLCD_4DGL.h" #include "SDFileSystem.h" #include "wave_player.h" #include "Nav_Switch.h" #include "rtos.h" DigitalOut myled(LED1); /*uLCD instantiation*/ uLCD_4DGL uLCD(p9,p10,p11); // serial tx, serial rx, reset pin; Nav_Switch myNav( p24, p25, p26, p27, p28); //up, down, left, right, fire Mutex mutex; /* wave player instantiation*/ SDFileSystem sd(p5, p6, p7, p8, "sd"); //SD card AnalogOut DACout(p18); wave_player waver(&DACout); /*play wav file on sd and when playing led1 turns on*/ void wav_thread3(void const *args) { while (1) { FILE *wave_file; wave_file=fopen("/sd/wavfiles/alarm.wav","r"); waver.play(wave_file); fclose(wave_file); } } void switch_thread5(void const *args) { while (true) { if(myNav.fire()) myled=!myled; if(myNav.up()) myled=!myled; if(myNav.down()) myled=!myled; if(myNav.right()) myled=!myled; if(myNav.left()) myled=!myled; //Thread::wait(500); } } int main() { myled=0; //Thread thread2(switch_thread5); //Thread thread3(wav_thread3); while(1) { uLCD.rectangle(0,0,128,10,0xFFFFFF); } }