Andy A / SlowPWM
Revision:
0:76861123625b
Child:
1:386d04fe1e37
diff -r 000000000000 -r 76861123625b SlowPWM.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SlowPWM.h	Tue Jun 18 10:52:51 2019 +0000
@@ -0,0 +1,43 @@
+#ifndef __slowPWM.h__
+#define __slowPWM.h__ 
+ 
+#include "mbed.h"
+class slowPWM : public DigitalOut
+{
+public:
+ 
+// constructor without setting anything going.
+    slowPWM( const PinName pin);
+ 
+// constructor that also starts things running
+    slowPWM( float period, float highTime, const PinName pin );
+ 
+// set the period
+    void setPeriod(float period);
+ 
+// set the on time per cycle
+    void setHighTime(float highTime);
+
+// set the on time per cycle as a fraction
+    void setDutyCycle(float cycle);
+
+ 
+// stop things. If output is high it will still turn low at the correct time
+    void stop();
+ 
+// start things
+    void start();
+ 
+private:
+// internal functions and variables not visible to the outside world
+ 
+    void onTurnOff(void);
+    void onCycleStart(void);
+ 
+    Ticker cycleTimer;
+    Timeout offTimer;
+ 
+    float _timeOn;
+    float _repeatTime;
+};
+#endif