hack gt final code
Dependencies: 4DGL-uLCD-SE BMP085 PinDetect SDFileSystem mbed wave_player
Diff: main.cpp
- Revision:
- 3:14195e423d13
- Parent:
- 2:a111a0137d95
- Child:
- 4:d29e7e826c42
diff -r a111a0137d95 -r 14195e423d13 main.cpp --- a/main.cpp Sat Sep 20 06:00:39 2014 +0000 +++ b/main.cpp Sat Sep 20 07:13:27 2014 +0000 @@ -13,11 +13,14 @@ wave_player waver(&DACout); uLCD_4DGL uLCD(p28, p27, p29); I2C i2c(p9, p10); +AnalogIn windSensor(p17); +float windSensorVoltage; const int address = 0x77 << 1; bool breathing; bool pulse; bool breath_success = true; ostringstream stream; +Timer breathTimer; int getSensorData(); void playMessage(string messageName); @@ -33,6 +36,10 @@ void unconsciousChocking(); int main(){ + while(1){ + checkBreath(); + wait(0.1); + } playMessage("Place mask on face"); playMessage("Clip sensor to ear"); playMessage("Tilt Head"); @@ -102,7 +109,23 @@ } bool checkBreath(){ - //SENSOR DATA + windSensorVoltage = windSensor*10; + while(windSensorVoltage<6.15){ + while(windSensorVoltage<6.16){ + windSensorVoltage = windSensor*10; + wait(0.1); + } + windSensorVoltage = windSensor*10; + wait(0.5); + } + uLCD.printf("BREATH DETECTED"); + breathTimer.start(); + + breathTimer.stop(); + breatTimer.detect(); + while(windSensorVoltage>6.15){}; + + //PRESSURE SENSOR DATA return false; }