Projet S5 Info - Advanced

Dependencies:   TextLCD XBeeLib mbed-rtos mbed

Fork of Coordinateur by Vincent Belanger

Revision:
4:714484401021
Parent:
2:a7820185e9a8
Child:
5:08245a3e93a8
--- a/main.cpp	Wed Apr 06 14:21:33 2016 +0000
+++ b/main.cpp	Wed Apr 06 15:24:00 2016 +0000
@@ -7,7 +7,12 @@
 using namespace XBeeLib;
 
 SDFileSystem sd(p5, p6, p7, p8, "sd"); // MOSI, MISO, SCLK, SSEL
-PwmOut speaker(p21);
+PwmOut speaker1(p21);
+PwmOut speaker2(p22);
+PwmOut speaker3(p23);
+PwmOut speaker4(p24);
+PwmOut speaker5(p25);
+PwmOut speaker6(p26);
 //wave_player player(&DACout);
 Serial pc(USBTX, USBRX);
 osThreadId threadIDC5;
@@ -48,8 +53,21 @@
 
     pc.printf("\r\n");
     
-    osSignalSet(threadIDC5, 0x1);
-    osSignalSet(threadIDG5, 0x2);
+    if(capt_1){
+        speaker1=0.50f;
+    } else {
+        speaker1=0.0f;
+    }
+    if(capt_2){
+        speaker2=0.50f;
+    } else {
+        speaker2=0.0f;
+    }
+    if(capt_3){
+        speaker3=0.50f;
+    } else {
+        speaker3=0.0f;
+    }
 }
 
 void playFile(const char* name)
@@ -64,38 +82,50 @@
     }
     fclose(fp);
     */
-    
-    speaker.period(1.0/500.0); // 500hz period
-    speaker =0.5; //50% duty cycle - max volume
-    wait(3);
-    speaker=0.0; // turn off audio
-    wait(2);
 }
 
 void playC5(void const* args)
 {
     threadIDC5 = osThreadGetId();
-
-    osSignalWait(0x1, osWaitForever);
-    pc.printf("Wait done C5");
-    playFile("/sd/Synth/C5.wav");
+    while(1){
+        osSignalWait(0x1, osWaitForever);
+        pc.printf("Wait done C5");
+        //playFile("/sd/Synth/C5.wav");        
+        speaker2=0.50f;  // 50% duty cycle 
+        //speaker2=1.0;
+        wait(2);
+        speaker2=0.0; // turn off audio
+        wait(2);
+    }
 }
 
 void playG5(void const* args)
 {
     threadIDG5 = osThreadGetId();
 
-    osSignalWait(0x2, osWaitForever);
-    pc.printf("Wait done G5");
-    //wait(1);
-    //playFile("/sd/Synth/A5.wav");
+    while(1){
+        osSignalWait(0x2, osWaitForever);
+        pc.printf("Wait done G5");
+        //wait(1);
+        //playFile("/sd/Synth/A5.wav");
+        speaker1=0.50f;  // 50% duty cycle 
+        //speaker1=1.0;
+        wait(3);
+        speaker1=0.0; // turn off audio
+        wait(1);
+    }
 }
 
 int main()
 {
-    Thread C5(playC5);
+    speaker3.period(1.0/2349.32); // 440hz period D3
+    speaker2.period(1.0/440.0); // 440hz period A3
+    speaker1.period(1.0/293.66); // 293.66hz period D
+    //speaker2.pulsewidth(2);  
+    //speaker1.pulsewidth(1); 
+    //Thread C5(playC5);
     //C5.set_priority(osPriorityHigh);
-    Thread G5(playG5);
+    //Thread G5(playG5);
     //G5.set_priority(osPriorityHigh);
 
     XBeeZB xbee = XBeeZB(p13, p14, p8, NC, NC, 9600);