~
Dependencies: mbed SimpleRGB mbed-rtos 4DGL-uLCD-SE SDFileSystem wave_player
Revision 9:d6343146d23e, committed 2016-10-11
- Comitter:
- kswanson31
- Date:
- Tue Oct 11 03:42:42 2016 +0000
- Parent:
- 8:38419fb4e242
- Commit message:
- Completed sound thread (haven't tested), formatted other threads
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDFileSystem.lib Tue Oct 11 03:42:42 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/SDFileSystem/#c8f66dc765d4
--- a/main.cpp Tue Oct 11 03:30:07 2016 +0000 +++ b/main.cpp Tue Oct 11 03:42:42 2016 +0000 @@ -3,6 +3,8 @@ #include <string> #include "uLCD_4DGL.h" #include "SimpleRGB.h" +#include "SDFileSystem.h" +#include "wave_player.h" #define SECOND 1000 // used with threads DigitalOut led(LED1); // test led @@ -84,7 +86,7 @@ strftime(buffer, 32, "%I:%M %p\n", localtime(&seconds)); // lock, update time at top right with smiley at top left stdio_mutex.lock(); - lcd.text_string(buffer, 5, 1, FONT_7X8, RED); + lcd.text_string(buffer, 8, 1, FONT_7X8, BLUE); lcd.text_string(":-)", 1, 1, FONT_7X8, WHITE); // unlock, wait for 20 sec stdio_mutex.unlock(); @@ -148,6 +150,10 @@ Thread::wait(9 * SECOND); } } + +SDFileSystem sd(p5, p6, p7, p8, "sd"); // SD card with .wav files +AnalogOut DACout(p18); // DAC for producing sound +wave_player waver(&DACout); // wavplayer object // - 2 @@ -165,33 +171,37 @@ /* 2 calls */ Thread thread2(uLCD_reboot_thread); Thread thread3(uLCD_status_thread); - //Thread thread4(rainbow_led_thread); + Thread thread4(rainbow_led_thread); //Thread thread5(uLCD_video_thread); + + FILE *wave_file; + // - 2 led = 1; while(true) { - /* 2 speaker 'thread' calls + + /* 2 speaker 'thread' calls */ // speaker plays mac reboot sound, error sound occasionally // play reboot sound - // wait 20 - // error - // wait 20 - // error + wave_file = fopen("/sd/reboot.wav","r"); + waver.play(wave_file); + fclose(wave_file); // wait 20 - */// - 2 - - - // thread testing - led = !led; - Thread::wait(2000); - led = !led; - Thread::wait(1000); - led = !led; - Thread::wait(500); - // - test - + Thread::wait(20 * SECOND); + // error + wave_file = fopen("/sd/error.wav","r"); + waver.play(wave_file); + fclose(wave_file); + // wait 20 + Thread::wait(20 * SECOND); + // error + waver.play(wave_file); + fclose(wave_file); + // wait 20 + Thread::wait(20 * SECOND); + // - 2 } // interupts will occur automatically }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wave_player.lib Tue Oct 11 03:42:42 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/sravet/code/wave_player/#acc3e18e77ad