Threads work, speaker not tested.

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

Files at this revision

API Documentation at this revision

Comitter:
mikeb
Date:
Fri Feb 26 17:17:48 2016 +0000
Parent:
1:6553131e3bcf
Commit message:
Working threads, untested speaker

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 6553131e3bcf -r b78eabd8f218 main.cpp
--- a/main.cpp	Fri Feb 26 17:04:20 2016 +0000
+++ b/main.cpp	Fri Feb 26 17:17:48 2016 +0000
@@ -50,8 +50,8 @@
         if (old_seed != seed){
             old_seed = seed;
             uLCD_mutex.lock();
-            uLCD.filled_rectangle(30, 30, 100, 10,BLACK);
-            uLCD.filled_rectangle(30, 30, 100*seed, 10, RED);
+            uLCD.filled_rectangle(30, 30, 120, 10,BLACK);
+            uLCD.filled_rectangle(30, 30, 120*seed, 10, RED);
             uLCD_mutex.unlock();
         
         }
@@ -64,7 +64,7 @@
         //seed_mutex.lock();
         seed = rand()/float(RAND_MAX);
         //seed_mutex.unlock();
-        rgb.write(seed/9 ,seed/5, seed/4); //Blue, green,red;
+        rgb.write(seed/9 ,seed/5, seed/4+.2); //Blue, green,red;
         Thread::wait(150);
     }
 }
@@ -77,36 +77,36 @@
     uLCD.text_height(2);
     uLCD.text_italic(ON);
     uLCD.background_color(BLACK);
-    //Thread thread1(uLCD2_thread);
+    Thread thread1(uLCD2_thread);
     Thread thread2(audio_thread);
     Thread thread3(RGB_thread);
     led1 = 1;
-    string s = "Spo";
-    std::string s2 = "oky!";
-    std::string o = " ";
-    std::string o2 = "o";
+    //Problems using c_str()
 
     while (true) {
         led2 = !led2;
-        for( short i = 0; i <6; i++){
+
         uLCD_mutex.lock();
-        uLCD.locate(0,4);
-        uLCD.printf("%o%s%s2\n\r", o.c_str(), s.c_str(), s2.c_str());
+        uLCD.locate(0,5);
+        uLCD.printf("SPOOKY!    ");
         uLCD_mutex.unlock();
-        o = o + " ";
-        Thread::wait(1000);
-        }
+        Thread::wait(800);
         
-        o = " ";
+        uLCD_mutex.lock();
+        uLCD.locate(0,5);
+        uLCD.printf(" SPOOKY!");
+        uLCD_mutex.unlock();
+        Thread::wait(800);
         
-        for( short i = 0; i <6; i++){
         uLCD_mutex.lock();
-        uLCD.locate(0,4);
-        uLCD.printf("%s%02%s2\n\r",  s.c_str(), o2.c_str(), s2.c_str());
+        uLCD.locate(0,5);
+        uLCD.printf("  SPOOKY!");
         uLCD_mutex.unlock();
-        o2 = o2 + "o";
-        Thread::wait(1000);
-        }
-        o2 = "o";
+        Thread::wait(800);
+        
+       
+       
+        
+        
     }
 }