The PWM output by software. Can be output to any pin. It can be used to replace the Pwmout.

Dependents:   RC_Servo

Fork of SoftPWM by syouichi imamori

Revision:
1:9aba3dc9cd97
Parent:
0:7918ce37626c
--- a/SoftPWM.h	Wed Oct 23 19:31:14 2013 +0000
+++ b/SoftPWM.h	Tue Jun 05 12:21:14 2018 +0000
@@ -14,29 +14,29 @@
     DigitalOut pulse;
     bool positive;
     void TickerInterrapt();
-    float width;
-    float interval;
+    double width;
+    double interval;
 public:
     SoftPWM(PinName,bool mode=true); 
 //    void attach_us(int);
     void start();
-    void write(float);
-    float read();
-    void pulsewidth(float);
+    void write(double);
+    double read();
+    void pulsewidth(double);
     void pulsewidth_ms(int);
     void pulsewidth_us(int);
-    void period(float);
+    void period(double);
     void period_ms(int);
     void period_us(int);
     void stop();
-    operator float()  { 
+    operator double()  { 
         if ( width <= 0.0 ) return 0.0;
         if ( width > 1.0 )  return 1.0;
         return width / interval;
     }
-    SoftPWM& operator=(float duty)  {
+    SoftPWM& operator=(double duty)  {
         width = interval * duty;
-        if ( duty <= 0.0 ) width =  0.0;
+        if ( duty <= 0.0 ) width =  0.0f;
         if ( duty > 1.0 )  width =  interval;
         return *this;
     }