Oscar Schofield / Mbed 2 deprecated Elec350_OBS

Dependencies:   mbed

Revision:
16:e9e1b134f498
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/soft_pwm.h	Tue Nov 17 12:51:28 2015 +0000
@@ -0,0 +1,26 @@
+#ifndef _SOFT_PWM_
+#define _SOFT_PWM_
+
+#include "mbed.h"
+
+class SoftPwm
+{
+        private:
+            float period;           //PWM period
+            float dutyCycle;        //Duty cycle of the PWM
+            Timer timer;            //used for location within the cycle
+            
+        public:
+            //constructor - requires initial period and duty cycle values 
+            SoftPwm(float initalPeriod, float initialDutyCycle); 
+            
+            float getPeriod();      //return current period value
+            float getDutyCycle();   //returns current Duty Cycle value
+            
+            void setPeriod(float newPeriod); //updates the period to a specified value 
+            void setDutyCycle(float newDutyCycle); //updates the Duty cycle to the specified value
+            
+            bool isOn();            //checks if value is on (true) or off (false) phase.
+};
+
+#endif 
\ No newline at end of file