This Library allows you to use any pin on the mbed micro as PWM out. It also allows the user to update the Period and Pulse width in realtime.

Revision:
0:9eb94736e774
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PwmOutAny.cpp	Sun Dec 08 19:04:44 2013 +0000
@@ -0,0 +1,49 @@
+#include "PwmOutAny.h"
+
+float _period;
+float _PercentHigh;
+
+PwmOutAny::PwmOutAny(PinName pin1, float Period, float PercentHigh):_PwmOut(pin1) 
+{
+	_period=Period;
+	_PercentHigh=PercentHigh ;
+	_PwmTicker.attach(this,&PwmOutAny::TickerFlipper,_period/2);
+}
+
+void PwmOutAny::TickerFlipper()
+{
+	static float CurrentPeriod;
+	if(!_PwmOut)
+	{
+			_PwmTicker.detach();
+			_PwmTicker.attach(this,&PwmOutAny::TickerFlipper,CurrentPeriod*(_PercentHigh));
+			_PwmOut = true;
+	}
+	else
+	{
+		   CurrentPeriod = _period;
+			_PwmTicker.detach();
+			_PwmTicker.attach(this,&PwmOutAny::TickerFlipper,CurrentPeriod*(1.0-_PercentHigh));
+			_PwmOut = false;
+	}
+}
+
+
+ float PwmOutAny::Get_PulseWidth()
+{
+	return (_PercentHigh);
+	
+}
+ void  PwmOutAny::Set_PulseWidth(float PW)
+{
+		_PercentHigh = PW;
+}
+ float PwmOutAny::Get_Period()
+{
+	return _period;
+}
+ void  PwmOutAny::Set_Period(float ChangePeriod)
+{
+	_period = ChangePeriod;
+}
+