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.
Pulsator.h
- Committer:
- huliyang
- Date:
- 2015-04-24
- Revision:
- 0:dda7f6f55dc1
- Child:
- 1:bcddb9898625
File content as of revision 0:dda7f6f55dc1:
#include <mbed.h> #include <PwmOut.h> class Pulsator { private: PwmOut out; Ticker ticker; float phase_2; // phase / 2 const float period; const bool active_high; const float gamma; const int levels; void step(void); void enable(void); void disable(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); };