breath sensor library
windSensor.h@1:d07f80ef7abc, 2016-12-11 (annotated)
- Committer:
- otis22894
- Date:
- Sun Dec 11 21:12:18 2016 +0000
- Revision:
- 1:d07f80ef7abc
- Parent:
- 0:397523d4133e
First commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
otis22894 | 0:397523d4133e | 1 | #include "mbed.h" |
otis22894 | 0:397523d4133e | 2 | #include "NeoStrip.h" |
otis22894 | 1:d07f80ef7abc | 3 | #include "MPL3115.h" |
otis22894 | 0:397523d4133e | 4 | #include <vector> |
otis22894 | 0:397523d4133e | 5 | |
otis22894 | 0:397523d4133e | 6 | class windSensor { |
otis22894 | 0:397523d4133e | 7 | public: |
otis22894 | 1:d07f80ef7abc | 8 | windSensor(PinName p, NeoStrip *_strip, PinName p2, PinName p3); |
otis22894 | 0:397523d4133e | 9 | /* Start victim breath */ |
otis22894 | 0:397523d4133e | 10 | void sample(); |
otis22894 | 0:397523d4133e | 11 | void startReading(); |
otis22894 | 0:397523d4133e | 12 | void stopReading(); |
otis22894 | 0:397523d4133e | 13 | void reset(); |
otis22894 | 0:397523d4133e | 14 | bool breathDetected(); |
otis22894 | 0:397523d4133e | 15 | /* End vicim breath */ |
otis22894 | 0:397523d4133e | 16 | |
otis22894 | 0:397523d4133e | 17 | /* start give breath */ |
otis22894 | 0:397523d4133e | 18 | float give_breath(void); |
otis22894 | 1:d07f80ef7abc | 19 | bool pressureSpikeDetected(); |
otis22894 | 0:397523d4133e | 20 | /* end give breath */ |
otis22894 | 0:397523d4133e | 21 | |
otis22894 | 0:397523d4133e | 22 | private: |
otis22894 | 0:397523d4133e | 23 | /* start vicim breath */ |
otis22894 | 0:397523d4133e | 24 | AnalogIn sensor; |
otis22894 | 0:397523d4133e | 25 | Ticker breathReader; |
otis22894 | 0:397523d4133e | 26 | |
otis22894 | 0:397523d4133e | 27 | volatile float thresh; |
otis22894 | 0:397523d4133e | 28 | //volatile bool Breath = false; // set on each visit to interrupt routine |
otis22894 | 0:397523d4133e | 29 | volatile bool isBreathing; |
otis22894 | 0:397523d4133e | 30 | volatile int breathCount; //increment if breath is above thresh on each visit to interrupt routine |
otis22894 | 0:397523d4133e | 31 | /* end victim breath */ |
otis22894 | 0:397523d4133e | 32 | |
otis22894 | 0:397523d4133e | 33 | /* start give breath */ |
otis22894 | 0:397523d4133e | 34 | Timer t, q; |
otis22894 | 0:397523d4133e | 35 | vector<float> b; |
otis22894 | 0:397523d4133e | 36 | /* end give breath */ |
otis22894 | 0:397523d4133e | 37 | vector<float> c; |
otis22894 | 0:397523d4133e | 38 | NeoStrip *strip; |
otis22894 | 1:d07f80ef7abc | 39 | MPL3115 barometer; |
otis22894 | 1:d07f80ef7abc | 40 | bool spike; |
otis22894 | 1:d07f80ef7abc | 41 | float pressure_threshold; |
otis22894 | 0:397523d4133e | 42 | }; |