hack gt final code

Dependencies:   4DGL-uLCD-SE BMP085 PinDetect SDFileSystem mbed wave_player

Files at this revision

API Documentation at this revision

Comitter:
otis22894
Date:
Sat Sep 20 08:12:46 2014 +0000
Parent:
3:14195e423d13
Child:
5:ff7f2a7ddf69
Commit message:
TIME: 4:12AM;

Changed in this revision

Speaker.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Speaker.h	Sat Sep 20 08:12:46 2014 +0000
@@ -0,0 +1,19 @@
+#include "mbed.h"
+// new class to play a note on Speaker based on PwmOut class
+class Speaker
+{
+public:
+    Speaker(PinName pin) : _pin(pin) {
+// _pin(pin) means pass pin to the Speaker Constructor
+    }
+// class method to play a note based on PwmOut class
+    void PlayNote(float frequency, float duration, float volume) {
+        _pin.period(1.0/frequency);
+        _pin = volume/2.0;
+        wait(duration);
+        _pin = 0.0;
+    }
+
+private:
+    PwmOut _pin;
+};
\ No newline at end of file
--- a/main.cpp	Sat Sep 20 07:13:27 2014 +0000
+++ b/main.cpp	Sat Sep 20 08:12:46 2014 +0000
@@ -85,9 +85,12 @@
 }
 
 void playMessage(string messageName){
-    messageName = "/sd/" + messageName;
+    messageName = "/sd/" + messageName + ".wav";
     char * cstrName = new char[messageName.length() + 1];
+    cstrName[messageName.length()]=0;
+    memcpy(cstrName,messageName.c_str(),messageName.size());
     FILE *wave_file;
+    uLCD.printf(cstrName);
     wave_file=fopen(cstrName,"r");
     waver.play(wave_file);
     fclose(wave_file);
@@ -116,15 +119,13 @@
             wait(0.1);
         }
         windSensorVoltage = windSensor*10;
-        wait(0.5);
+        wait(0.6);
     }
     uLCD.printf("BREATH DETECTED");
-    breathTimer.start();
-    
-    breathTimer.stop();
-    breatTimer.detect();
-    while(windSensorVoltage>6.15){};
-    
+    playMessage("breathTone");
+    while(windSensorVoltage>6.15){
+        windSensorVoltage = windSensor*10;
+    }
     //PRESSURE SENSOR DATA
     return false;   
 }