Joseph Boettcher / Mbed 2 deprecated ECE4180_Lab3_Threads_Updated

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

Fork of ECE4180_Lab3_Threads_Updated by Sean Buckingham

Revision:
7:bf1bb278bdec
Parent:
3:c92e21f305d8
Child:
8:17ac4f255e4b
--- a/main.cpp	Tue Jun 04 16:01:32 2013 +0100
+++ b/main.cpp	Mon Oct 03 18:35:19 2016 +0000
@@ -1,21 +1,85 @@
 #include "mbed.h"
 #include "rtos.h"
- 
+#include "uLCD_4DGL.h"
+#include "LSM9DS1.h"
+#include "SDFileSystem.h"
+#include "wave_player.h"
+
+/* shiftbright instantiation*/
+DigitalOut red(p23);
+DigitalOut blue(p21);
+DigitalOut green(p22);
+
+/*uLCD instantiation*/
+uLCD_4DGL uLCD(p28,p27,p29); // serial tx, serial rx, reset pin;
+Mutex mutex;
+
+/* wave player instantiation*/
+SDFileSystem sd(p5, p6, p7, p8, "sd"); //SD card
+AnalogOut DACout(p18);
+wave_player waver(&DACout);
+
 DigitalOut led1(LED1);
 DigitalOut led2(LED2);
- 
-void led2_thread(void const *args) {
+
+/* makes different colored squares the same color as the shiftbright*/
+void lcd_thread1(void const *args) {
+    int color = 0xFFC0CB; //initially pink
+    while (true) {
+        if (blue == 1) { color = 0x0000FF; }
+        else if (red === 1) { color = 0xFF0000; }
+        else if (green == 1) { color = 0x008000; }
+        mutex.lock();
+        uLCD.filled_rectangle(5, 64, 84, 25, color);
+        mutex.unlock();
+    }
+}
+
+/*makes different colored circle every time the bell sound sounds*/
+void lcd_thread2(void const *args) {
+    int color2 = 0xFFC0CB;
+}
+
+/*play wav file on sd and when playing led1 turns on*/
+void wav_thread3(void const *args) {
     while (true) {
-        led2 = !led2;
-        Thread::wait(1000);
+        FILE *wave_file;
+        wave_file=fopen("/sd/wavfiles/Store_Door_Chime-Mike_Koenig-570742973.wav","r");
+        waver.play(wave_file);
+        led1 = 1;
+        fclose(wave_file);
+        led1 = 0;
+        Thread::wait(500);  
+    }
+}
+
+void light_thread4(void const *args) {
+    while (true) {
+        red = 0;
+        blue = 1;
+        green = 0;
+    
+        wait(1);
+    
+        red = 0;
+        blue = 0;
+        green = 1;
+
+        wait(1); 
+    
+        red = 1;
+        blue = 0;
+        green = 0;
+    
+        wait(1);   
     }
 }
  
 int main() {
-    Thread thread(led2_thread);
+    //Thread thread(thread1);
     
-    while (true) {
+    /*while (true) {
         led1 = !led1;
         Thread::wait(500);
-    }
+    }*/
 }