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.
soft_pwm.h
- Committer:
- Oschofield
- Date:
- 2015-11-17
- Revision:
- 16:e9e1b134f498
File content as of revision 16:e9e1b134f498:
#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