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:
5:94cdc85bf1ae
Parent:
2:19f995979c6a
Child:
6:6af888a91e23
--- a/Servo.cpp	Thu Aug 02 02:29:10 2012 +0000
+++ b/Servo.cpp	Fri Aug 03 05:21:59 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;
 
 
 
@@ -23,7 +23,7 @@
     if (numServos == 0)
     {
         // Start the timeout that refreshes all servos
-        refreshTimeout.attach_us(&Servo::refresh, period);
+        refreshTicker.attach_us(&Servo::refresh, period);
     }
     
     servos[numServos++] = this;
@@ -63,7 +63,7 @@
 void Servo::refresh()
 {
     // Restart the refresh timeout
-    refreshTimeout.attach_us(&Servo::refresh, period);
+    refreshTicker.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++)