~

Dependencies:   mbed SimpleRGB mbed-rtos 4DGL-uLCD-SE SDFileSystem wave_player

Revision:
9:d6343146d23e
Parent:
8:38419fb4e242
diff -r 38419fb4e242 -r d6343146d23e main.cpp
--- 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
 }