
elec350
Fork of elec350 by
soft_pwm.h@16:721e41936a07, 2015-11-19 (annotated)
- Committer:
- rmerrisonhort
- Date:
- Thu Nov 19 10:06:45 2015 +0000
- Revision:
- 16:721e41936a07
- Parent:
- 12:ae626e46b996
Added InternalTemperature class.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
rmerrisonhort | 10:021f19a9861f | 1 | #ifndef _SOFT_PWM_ |
rmerrisonhort | 10:021f19a9861f | 2 | #define _SOFT_PWM_ |
rmerrisonhort | 10:021f19a9861f | 3 | |
rmerrisonhort | 10:021f19a9861f | 4 | #include "mbed.h" |
rmerrisonhort | 10:021f19a9861f | 5 | |
rmerrisonhort | 10:021f19a9861f | 6 | class SoftPwm |
rmerrisonhort | 10:021f19a9861f | 7 | { |
rmerrisonhort | 10:021f19a9861f | 8 | private: |
rmerrisonhort | 12:ae626e46b996 | 9 | float period; // The period of the PWM cycle. |
rmerrisonhort | 12:ae626e46b996 | 10 | float dutyCycle; // Duty cycle. |
rmerrisonhort | 12:ae626e46b996 | 11 | Timer timer; // A timer for keeping track of where in the cycle we are. |
rmerrisonhort | 10:021f19a9861f | 12 | public: |
rmerrisonhort | 12:ae626e46b996 | 13 | // Constructor. The initial period and duty cycle should be given. |
rmerrisonhort | 10:021f19a9861f | 14 | SoftPwm(float initialPeriod, float initialDutycycle); |
rmerrisonhort | 10:021f19a9861f | 15 | |
rmerrisonhort | 12:ae626e46b996 | 16 | // getPeriod: Return the current cycle period. |
rmerrisonhort | 12:ae626e46b996 | 17 | float getPeriod(); |
rmerrisonhort | 12:ae626e46b996 | 18 | // getDutyCycle: Return the current duty cycle. |
rmerrisonhort | 12:ae626e46b996 | 19 | float getDutyCycle(); |
rmerrisonhort | 12:ae626e46b996 | 20 | |
rmerrisonhort | 12:ae626e46b996 | 21 | // setPeriod: Change the current cycle period. |
rmerrisonhort | 10:021f19a9861f | 22 | void setPeriod(float newPeriod); |
rmerrisonhort | 12:ae626e46b996 | 23 | // setDutyCycle: Change the current duty cycle. |
rmerrisonhort | 10:021f19a9861f | 24 | void setDutyCycle(float newDutyCycle); |
rmerrisonhort | 11:4685f33a2468 | 25 | |
rmerrisonhort | 12:ae626e46b996 | 26 | // isOn: Looks at the current value of the timer and returns true if currently |
rmerrisonhort | 12:ae626e46b996 | 27 | // in the on-phase and false if currently in the off-phase. |
rmerrisonhort | 10:021f19a9861f | 28 | bool isOn(); |
rmerrisonhort | 10:021f19a9861f | 29 | }; |
rmerrisonhort | 10:021f19a9861f | 30 | |
rmerrisonhort | 12:ae626e46b996 | 31 | #endif |
rmerrisonhort | 12:ae626e46b996 | 32 |