Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: soft_pwm.h
- 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