1212-  Basics: On / off / toggle
1313-  Supports blink patterns in the style of "Blink x times, pause, blink y times, repeat"
1414-  Supports infinite blinking
15- -  Supports single flashes
15+ -  Supports single flashes and pauses, resuming the previous mode
16+ -  Completely non-blocking (no ` delay() ` )
1617-  Parameters for pause- / off- / on-time duration can be adjusted on the fly
17- -  Super-nice fading effects (optional) with logarithmic brightness compensation
18+ -  Super-nice fading effects (optional) with logarithmic brightness compensation for LEDs 
1819-  Lightweight
19- -  Good-looking defaults (at least I tried)
20- -  Easily extendable
21- -  Non-blocking (no ` delay() ` ), no dynamic allocations
20+ -  Easily extendable to control components via SPI / CAN / I2C / UART ...
21+ -  Comes with good-looking defaults (at least I tried)
2222
2323## Example  
2424
25- This example blinks the built-in LED on pin 13 with a smooth fade effect and logarithmic
26- brightness compensation in the following pattern:
25+ This example blinks the built-in LED on pin 13 in the following pattern:
2726
28- ` Blink 2x → Short pause → Blink 3x → Long pause → Repeat ` 
27+ -  Blink 2x
28+ -  Short pause
29+ -  Blink 3x
30+ -  Long pause
31+ -  Repeat
2932
3033``` C 
31- #include  < FadingIndicatorPin .h> 
34+ #include  < FadeIndicator .h> 
3235
33- FadingIndicatorPin  led (13);
36+ FadeIndicator  led (13);
3437
3538void setup()
3639{
@@ -43,16 +46,22 @@ void loop()
4346}
4447``` 
4548
49+ Easy, uh? It's not only blinking, it does so with smooth fading effects and 
50+ logarithmic LED brightness compensation. Your boards never looked more professional! /s 
51+ 
52+ > Note: If you don't love the fading effects, just use the `Indicator`-class instead of 
53+ > `FadeIndicator`. 
54+ 
4655## Full API 
4756
4857```C 
4958// Without fading effect: 
50- #include <IndicatorPin .h> 
51- IndicatorPin  myPin(13);
59+ #include <Indicator .h> 
60+ Indicator  myPin(13);
5261
5362// With fading effect: 
54- #include <FadingIndicatorPin .h> 
55- FadingIndicatorPin  myPin(13);
63+ #include <FadeIndicator .h> 
64+ FadeIndicator  myPin(13);
5665
5766// now in your code you can do: 
5867myPin.permanent(LOW); 
@@ -61,45 +70,63 @@ myPin.blink();
6170``` 
6271
6372``` C 
73+ //  set permanently ON
74+ void  on ();
75+ 
76+ //  set permanently OFF
77+ void  off ();
78+ 
6479//  toggle between on / off
6580void  toggle ();
6681
6782//  set ON / OFF permanently
6883void  permanent (bool enable);
6984
70- // blink infinitely. ` speed `  can be 0 (slow) or 1 (fast) .
71- void blink(Speed  speed = Speed::FAST );
85+ // blink infinitely. Speed is fast by default .
86+ void blink(SpeedSetting  speed = SPEED_FAST );
7287
7388// blink ` num `  times, then long pause
7489// repeats, if ` repeat `  is set, OFF otherwise.
75- void pattern(int num, bool repeat = true, Speed  speed = Speed::FAST );
90+ void pattern(int num, bool repeat = true, SpeedSetting  speed = SPEED_FAST );
7691
7792// blink ` num1 `  times, short pause, blink ` num2 `  times, long pause
7893// repeats, if ` repeat `  is set, OFF otherwise.
79- void pattern(int num1, int num2, bool repeat = true, Speed  speed = Speed::FAST );
94+ void pattern(int num1, int num2, bool repeat = true, SpeedSetting  speed = SPEED_FAST );
8095
8196// turn ON for the given duration in ms. Continues in the previous mode afterwards.
8297void flash(uint16_t duration_ms);
8398
99+ // turn OFF for the given duration in ms. Continues in the previous mode afterwards.
100+ void pause(uint16_t duration_ms);
101+ 
84102// setup the timing parameters
85- void setTiming(
86-     uint16_t fast_on_ms,
87-     uint16_t fast_off_ms,
88-     uint16_t fast_pause_ms,
89-     uint16_t fast_ending_ms,
90-     uint16_t slow_on_ms,
91-     uint16_t slow_off_ms,
92-     uint16_t slow_pause_ms,
93-     uint16_t slow_ending_ms);
94- 
95- // Hint: You can also modify the values directly, e.g.:
96- myLed.fast_on_ms = 250;
97- 
98- // shorthand for setting up the timing parameters by defining the fast ON duration in ms.
99- // all other durations are derived from that with some internal factors.
100- void setTiming(uint16_t on_ms);
101- 
102- // ` true `  if the indicator is currently blinking, showing a pattern or flashing
103+ void setSpeed(SpeedSetting setting);
104+ // Available by default: SPEED_RAPID, SPEED_FAST, SPEED_SLOW
105+ 
106+ // Or use your own settings. SpeedSetting is a struct:
107+ typedef struct
108+ {
109+     uint16_t on_ms;
110+     uint16_t off_ms;
111+     uint16_t pause_ms;
112+     uint16_t ending_ms;
113+ } SpeedSetting;
114+ 
115+ // ... alternatively you can setup the speed settings directly
116+ void setSpeed(
117+     uint16_t on_ms,
118+     uint16_t off_ms,
119+     uint16_t pause_ms,
120+     uint16_t ending_ms);
121+ 
122+ // ... or by providing a single value, the other values are inferred from that
123+ void setSpeed(uint16_t on_ms);
124+ 
125+ // Hint: You can also modify the values directly - even on the fly - e.g.:
126+ myLed.settings.on_ms = 250;
127+ myLed.settings.pause_ms = 2000;
128+ 
129+ // ` true `  if the indicator is currently blinking, showing a pattern, flashing or pausing
103130bool isOn();
104131
105132// You must call this in your loop!
@@ -112,10 +139,11 @@ int update();
112139
113140No problem! You have two options. 
114141
115- - Use the generic `Indicator` class from `<Indicator.h>`. The `.update()`-method returns 
116-   a boolean whether the status is currently `HIGH` or `LOW`. You can then send this 
117-   value to your status indicator (see `examples/GenericBlink`). Use the `FadingIndictor` 
118-   class if you want fading effects. Here the `update` method returns an integer `0..255`. 
142+ - Use the generic `BaseIndicator` class from `<BaseIndicator.h>`. The `.update()`-method 
143+   returns a boolean whether the status is currently `HIGH` or `LOW`. You can then send 
144+   this value to your status indicator (see `examples/GenericBlink`). 
145+   Use the `BaseFadeIndictor` class if you want fading effects. Here the `update` method 
146+   returns an integer `0..255`. 
119147
120- - Subclass the `Indicator ` class with custom logic. This is what `IndicatorPin ` does 
121-   internally (see `src/IndicatorPin .h`). 
148+ - Subclass the `BaseIndicator ` class with custom logic. This is what `Indicator ` does 
149+   internally (see `src/Indicator .h`). Have a look at the `SerialBlink` example!  
0 commit comments