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.

Dependencies:   mbed MODI2C

Committer:
maetugr
Date:
Wed Oct 17 08:37:08 2012 +0000
Revision:
10:953afcbcebfc
Parent:
7:9d4313510646
Child:
12:67a06c9b69d5
neue Acc_Winkelberechnung, vor Kompassklassenrevision

Who changed what in which revision?

UserRevisionLine numberNew contents of line
maetugr 7:9d4313510646 1 #include "RC_Channel.h"
maetugr 7:9d4313510646 2 #include "mbed.h"
maetugr 7:9d4313510646 3
maetugr 7:9d4313510646 4 RC_Channel::RC_Channel(PinName mypin) : myinterrupt(mypin)
maetugr 7:9d4313510646 5 {
maetugr 10:953afcbcebfc 6 time = -1; // start value to see if there was any value yet
maetugr 7:9d4313510646 7 myinterrupt.rise(this, &RC_Channel::rise);
maetugr 7:9d4313510646 8 myinterrupt.fall(this, &RC_Channel::fall);
maetugr 10:953afcbcebfc 9 timeoutchecker.attach(this, &RC_Channel::timeoutcheck, 1);
maetugr 7:9d4313510646 10 }
maetugr 7:9d4313510646 11
maetugr 7:9d4313510646 12 int RC_Channel::read()
maetugr 7:9d4313510646 13 {
maetugr 7:9d4313510646 14 return time;
maetugr 7:9d4313510646 15 }
maetugr 7:9d4313510646 16
maetugr 7:9d4313510646 17 void RC_Channel::rise()
maetugr 7:9d4313510646 18 {
maetugr 7:9d4313510646 19 timer.start();
maetugr 7:9d4313510646 20 }
maetugr 7:9d4313510646 21
maetugr 7:9d4313510646 22 void RC_Channel::fall()
maetugr 7:9d4313510646 23 {
maetugr 7:9d4313510646 24 timer.stop();
maetugr 7:9d4313510646 25 time = timer.read_us();
maetugr 7:9d4313510646 26 timer.reset();
maetugr 10:953afcbcebfc 27 timer.start();
maetugr 10:953afcbcebfc 28 }
maetugr 10:953afcbcebfc 29
maetugr 10:953afcbcebfc 30 void RC_Channel::timeoutcheck()
maetugr 10:953afcbcebfc 31 {
maetugr 10:953afcbcebfc 32 if (timer.read() > 0.3)
maetugr 10:953afcbcebfc 33 time = 0;
maetugr 7:9d4313510646 34 }