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:
8:ddedf56b2eb0
Parent:
7:7abc04b4c474
Child:
9:b40252f5fee7
--- a/Pulsator.h	Sun Apr 26 01:43:31 2015 +0000
+++ b/Pulsator.h	Mon Apr 27 11:15:08 2015 +0000
@@ -23,10 +23,11 @@
 {
 private:
     PwmOut out;
-    float phase_2; //!< \a phase / 2
+    float phase;
 
     bool _active_high;
     bool _enable;
+    float (*_fun)(float phase);
     float _gamma;
     float _period;
     int _levels;
@@ -42,6 +43,7 @@
     operator bool(void);
 
     Pulsator& active_high(bool high = false);
+    Pulsator& fun(float (*fp)(float phase) = NULL);
     Pulsator& gamma(float power = 2.2f);
     Pulsator& levels(int number = 128);
     Pulsator& period(float seconds = 1.0f);