Class Library for reading hobby servos and detecting invalid or disconnected channels

Dependents:   MadPulseCntrl Emaxx_Navigation Emaxx_Navigation_Dynamic_HIL Madpulse_Speed_Control_temp ... more

ServoIn Class Library

This class library uses external interrupts with timer functions to read servos pulses on mbed input pins.

ServoIn Library usage example

#include "mbed.h"
#include "ServoIn.h"

DigitalOut led1(LED1);
ServoIn servoIn1(p15);
ServoIn servoIn2(p14);
Serial pc(USBTX, USBRX); // tx, rx

int main() {    
    pc.baud(921600);            //Fast baud rate
        
    while(1) {
        led1 = 1;
        wait(0.05);
        led1 = 0;
        wait(0.05);
        
        pc.printf("servo pulse: CH1=%5dus  CH2=%5dus\r\n", servoIn1.read(), servoIn2.read());        
    }
}
Revision:
1:b7cc6da72d09
Parent:
0:98a3b6fbd242
Child:
2:07273d6016e9
--- a/ServoIn.h	Tue Apr 14 20:05:13 2015 +0000
+++ b/ServoIn.h	Wed Apr 15 19:36:40 2015 +0000
@@ -37,20 +37,22 @@
     * @param pin - servo pulse input pin, assigned as interrupt in
     */         
     
-    //ServoIn(PinName pin);
     ServoIn(PinName pin);
             
     int servoPulse;
     int read(void);
     void PulseRead(void);
+    void timeoutTest(void);
     
     ServoIn& operator= (ServoIn& rhs);
-    operator int();
+     operator int();
     
 private:
     InterruptIn _interrupt;
+    Timeout _validPulseTimeout;
     bool _pulseFlag;
     Timer   pulseMeasure;
+    bool _t_state;
 };
 
 #endif
\ No newline at end of file