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:
- 10:953afcbcebfc
- Parent:
- 7:9d4313510646
- Child:
- 12:67a06c9b69d5
--- a/RC/RC_Channel.cpp Tue Oct 16 10:21:32 2012 +0000 +++ b/RC/RC_Channel.cpp Wed Oct 17 08:37:08 2012 +0000 @@ -3,8 +3,10 @@ RC_Channel::RC_Channel(PinName mypin) : myinterrupt(mypin) { + time = -1; // start value to see if there was any value yet myinterrupt.rise(this, &RC_Channel::rise); myinterrupt.fall(this, &RC_Channel::fall); + timeoutchecker.attach(this, &RC_Channel::timeoutcheck, 1); } int RC_Channel::read() @@ -22,4 +24,11 @@ timer.stop(); time = timer.read_us(); timer.reset(); + timer.start(); +} + +void RC_Channel::timeoutcheck() +{ + if (timer.read() > 0.3) + time = 0; } \ No newline at end of file