Use the hardware PwmOut to pulsate an LED (or something else), with selectable active high/low, customisable intensity function, gamma correction, and number of brightness levels.
Diff: Pulsator.h
- Revision:
- 5:26cc18306d95
- Parent:
- 1:bcddb9898625
- Child:
- 6:5eeb1acc1c50
--- a/Pulsator.h Fri Apr 24 07:58:22 2015 +0000 +++ b/Pulsator.h Fri Apr 24 21:26:05 2015 +0000 @@ -25,17 +25,19 @@ PwmOut out; Ticker ticker; float phase_2; //!< \a phase / 2 + bool _enable; const float period; const bool active_high; const float gamma; const int levels; - void step(void); + void disable(void); void enable(void); - void disable(void); + void step(void); public: Pulsator(PinName pin = LED1, float period = 1.0, bool active_high = true, float gamma = 2.2, int levels = 32); Pulsator& operator=(bool state); + operator bool(void); };