Used to read incoming PWM signals from RC channels
Diff: PulseIn.h
- Revision:
- 1:eaf70ff4df07
- Parent:
- 0:1a57c7f88422
- Child:
- 2:4abac72addb7
--- a/PulseIn.h Wed Dec 19 08:06:23 2012 +0000 +++ b/PulseIn.h Sun Dec 23 23:49:18 2012 +0000 @@ -1,21 +1,22 @@ -#ifndef RC_CHANNEL_H -#define PULSEIN_H - -#include "mbed.h" - -class PulseIn -{ - public: - PulseIn(PinName p); - int read(); // read the last measured data - - private: - InterruptIn _k; // interrupt on the pin to react when signal falls or rises - void rise(); // start the time measurement when signal rises - void fall(); // stop the time mesurement and save the value when signal falls - Timer t; // timer to measure the up time of the signal and if the signal timed out - int _duration; // last measurement data -}; - -#endif - +#ifndef PULSEIN_H +#define PULSEIN_H + +#include "mbed.h" + +class PulseIn +{ + public: + PulseIn(PinName p); + int read(void); + int getAngle(void); + + private: + InterruptIn _k; + void rise(void); + void fall(void); + Timer t; + uint16_t _duration,_prev; +}; + +#endif +