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.
Revision 10:1ade8e824939, committed 2015-05-18
- Comitter:
- huliyang
- Date:
- Mon May 18 13:28:03 2015 +0000
- Parent:
- 9:b40252f5fee7
- Commit message:
- Debouncer: uint16_t _levels is enough for anyone; private Ticker.
Changed in this revision
Pulsator.cpp | Show annotated file Show diff for this revision Revisions of this file |
Pulsator.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/Pulsator.cpp Tue Apr 28 15:42:25 2015 +0000 +++ b/Pulsator.cpp Mon May 18 13:28:03 2015 +0000 @@ -132,7 +132,7 @@ } //! Set the number (>= 2) of distinct brightness levels. -Pulsator& Pulsator::levels(int number) +Pulsator& Pulsator::levels(uint16_t number) { _levels = number; reload();
--- a/Pulsator.h Tue Apr 28 15:42:25 2015 +0000 +++ b/Pulsator.h Mon May 18 13:28:03 2015 +0000 @@ -23,7 +23,7 @@ #include <mbed.h> #include <PwmOut.h> -class Pulsator : Ticker +class Pulsator : private Ticker { private: PwmOut out; @@ -34,7 +34,7 @@ float (*_fun)(float phase); float _gamma; float _period; - int _levels; + uint16_t _levels; void disable(void); void enable(void); @@ -49,6 +49,6 @@ 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& levels(uint16_t number = 128); Pulsator& period(float seconds = 1.0f); };