NOT FINISHED YET!!! My first try to get a self built fully working Quadrocopter based on an mbed, a self built frame and some other more or less cheap parts.
Diff: RC/RC_Channel.cpp
- Revision:
- 7:9d4313510646
- Child:
- 10:953afcbcebfc
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/RC/RC_Channel.cpp Mon Oct 15 17:23:06 2012 +0000 @@ -0,0 +1,25 @@ +#include "RC_Channel.h" +#include "mbed.h" + +RC_Channel::RC_Channel(PinName mypin) : myinterrupt(mypin) +{ + myinterrupt.rise(this, &RC_Channel::rise); + myinterrupt.fall(this, &RC_Channel::fall); +} + +int RC_Channel::read() +{ + return time; +} + +void RC_Channel::rise() +{ + timer.start(); +} + +void RC_Channel::fall() +{ + timer.stop(); + time = timer.read_us(); + timer.reset(); +} \ No newline at end of file