Oscar Schofield / Mbed 2 deprecated Elec350_OBS

Dependencies:   mbed

Committer:
Oschofield
Date:
Tue Nov 17 12:51:28 2015 +0000
Revision:
16:e9e1b134f498
added the soft_pwm header and .cpp file;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Oschofield 16:e9e1b134f498 1 #ifndef _SOFT_PWM_
Oschofield 16:e9e1b134f498 2 #define _SOFT_PWM_
Oschofield 16:e9e1b134f498 3
Oschofield 16:e9e1b134f498 4 #include "mbed.h"
Oschofield 16:e9e1b134f498 5
Oschofield 16:e9e1b134f498 6 class SoftPwm
Oschofield 16:e9e1b134f498 7 {
Oschofield 16:e9e1b134f498 8 private:
Oschofield 16:e9e1b134f498 9 float period; //PWM period
Oschofield 16:e9e1b134f498 10 float dutyCycle; //Duty cycle of the PWM
Oschofield 16:e9e1b134f498 11 Timer timer; //used for location within the cycle
Oschofield 16:e9e1b134f498 12
Oschofield 16:e9e1b134f498 13 public:
Oschofield 16:e9e1b134f498 14 //constructor - requires initial period and duty cycle values
Oschofield 16:e9e1b134f498 15 SoftPwm(float initalPeriod, float initialDutyCycle);
Oschofield 16:e9e1b134f498 16
Oschofield 16:e9e1b134f498 17 float getPeriod(); //return current period value
Oschofield 16:e9e1b134f498 18 float getDutyCycle(); //returns current Duty Cycle value
Oschofield 16:e9e1b134f498 19
Oschofield 16:e9e1b134f498 20 void setPeriod(float newPeriod); //updates the period to a specified value
Oschofield 16:e9e1b134f498 21 void setDutyCycle(float newDutyCycle); //updates the Duty cycle to the specified value
Oschofield 16:e9e1b134f498 22
Oschofield 16:e9e1b134f498 23 bool isOn(); //checks if value is on (true) or off (false) phase.
Oschofield 16:e9e1b134f498 24 };
Oschofield 16:e9e1b134f498 25
Oschofield 16:e9e1b134f498 26 #endif