
elec350
Fork of elec350 by
Diff: soft_pwm.h
- Revision:
- 12:ae626e46b996
- Parent:
- 11:4685f33a2468
--- a/soft_pwm.h Wed Oct 21 20:01:11 2015 +0000 +++ b/soft_pwm.h Wed Oct 21 22:42:17 2015 +0000 @@ -6,19 +6,27 @@ class SoftPwm { private: - float period; - float dutyCycle; - Timer timer; + float period; // The period of the PWM cycle. + float dutyCycle; // Duty cycle. + Timer timer; // A timer for keeping track of where in the cycle we are. public: + // Constructor. The initial period and duty cycle should be given. SoftPwm(float initialPeriod, float initialDutycycle); + // getPeriod: Return the current cycle period. + float getPeriod(); + // getDutyCycle: Return the current duty cycle. + float getDutyCycle(); + + // setPeriod: Change the current cycle period. void setPeriod(float newPeriod); + // setDutyCycle: Change the current duty cycle. void setDutyCycle(float newDutyCycle); - float getDutyCycle(); - float getPeriod(); - + // isOn: Looks at the current value of the timer and returns true if currently + // in the on-phase and false if currently in the off-phase. bool isOn(); }; -#endif \ No newline at end of file +#endif +