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.
RC/RC_Channel.cpp
- Committer:
- maetugr
- Date:
- 2012-11-05
- Revision:
- 20:e116e596e540
- Parent:
- 15:753c5d6a63b3
- Child:
- 21:c2a2e7cbabdd
File content as of revision 20:e116e596e540:
#include "RC_Channel.h" #include "mbed.h" 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() { return time; } void RC_Channel::rise() { timer.start(); } void RC_Channel::fall() { timer.stop(); int tester = timer.read_us(); if(tester >= 1000 && tester <=2000) time = (tester-70); // TODO: skalierung mit calibrierung (speichern....) timer.reset(); timer.start(); } void RC_Channel::timeoutcheck() { if (timer.read() > 0.3) time = 0; }