A simple library for driving RC servos without using the mbed's PWM functions. This allows the mbed to drive as many servos as there are DigitalOut pins, and additionally allows for the PWM functions to be used at a different frequency than the 50Hz used for servos.

Revision:
4:373219702af9
Parent:
2:19f995979c6a
Child:
6:6af888a91e23
--- a/Servo.cpp	Thu Aug 02 02:29:10 2012 +0000
+++ b/Servo.cpp	Thu Aug 02 02:53:08 2012 +0000
@@ -8,7 +8,7 @@
 // DigitalOut pins provided by the mbed.
 Servo *Servo::servos[26];
 unsigned int Servo::numServos = 0;
-Timeout Servo::refreshTimeout;
+Ticker Servo::refreshTicker;
 
 
 
@@ -22,8 +22,8 @@
     
     if (numServos == 0)
     {
-        // Start the timeout that refreshes all servos
-        refreshTimeout.attach_us(&Servo::refresh, period);
+        // Start the ticker that refreshes all servos
+        refreshTicker.attach_us(&Servo::refresh, period);
     }
     
     servos[numServos++] = this;
@@ -61,10 +61,7 @@
 
 
 void Servo::refresh()
-{
-    // Restart the refresh timeout
-    refreshTimeout.attach_us(&Servo::refresh, period);
-    
+{   
     // Start all of the individual servo width timeouts and write a logical 1 to their signal pins
     for (int i = 0; i < numServos; i++)
     {