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.

Dependents:   RedButton

Revision:
0:dda7f6f55dc1
Child:
1:bcddb9898625
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Pulsator.h	Fri Apr 24 03:56:51 2015 +0000
@@ -0,0 +1,23 @@
+#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);
+};