@@ -56,12 +56,12 @@ logarithmic LED brightness compensation. Your boards never looked more professio
56
56
57
57
```C
58
58
// Without fading effect:
59
- #include <IndicatorPin .h>
60
- IndicatorPin myPin(13);
59
+ #include <Indicator .h>
60
+ Indicator myPin(13);
61
61
62
62
// With fading effect:
63
- #include <FadingIndicatorPin .h>
64
- FadingIndicatorPin myPin(13);
63
+ #include <FadeIndicator .h>
64
+ FadeIndicator myPin(13);
65
65
66
66
// now in your code you can do:
67
67
myPin.permanent(LOW);
@@ -70,45 +70,63 @@ myPin.blink();
70
70
```
71
71
72
72
``` C
73
+ // set permanently ON
74
+ void on ();
75
+
76
+ // set permanently OFF
77
+ void off ();
78
+
73
79
// toggle between on / off
74
80
void toggle ();
75
81
76
82
// set ON / OFF permanently
77
83
void permanent (bool enable);
78
84
79
- // blink infinitely. ` speed ` can be 0 (slow) or 1 (fast) .
80
- void blink(Speed speed = Speed::FAST );
85
+ // blink infinitely. Speed is fast by default .
86
+ void blink(SpeedSetting speed = SPEED_FAST );
81
87
82
88
// blink ` num ` times, then long pause
83
89
// repeats, if ` repeat ` is set, OFF otherwise.
84
- void pattern(int num, bool repeat = true, Speed speed = Speed::FAST );
90
+ void pattern(int num, bool repeat = true, SpeedSetting speed = SPEED_FAST );
85
91
86
92
// blink ` num1 ` times, short pause, blink ` num2 ` times, long pause
87
93
// repeats, if ` repeat ` is set, OFF otherwise.
88
- 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 );
89
95
90
96
// turn ON for the given duration in ms. Continues in the previous mode afterwards.
91
97
void flash(uint16_t duration_ms);
92
98
99
+ // turn OFF for the given duration in ms. Continues in the previous mode afterwards.
100
+ void pause(uint16_t duration_ms);
101
+
93
102
// setup the timing parameters
94
- void setTiming(
95
- uint16_t fast_on_ms,
96
- uint16_t fast_off_ms,
97
- uint16_t fast_pause_ms,
98
- uint16_t fast_ending_ms,
99
- uint16_t slow_on_ms,
100
- uint16_t slow_off_ms,
101
- uint16_t slow_pause_ms,
102
- uint16_t slow_ending_ms);
103
-
104
- // Hint: You can also modify the values directly, e.g.:
105
- myLed.fast_on_ms = 250;
106
-
107
- // shorthand for setting up the timing parameters by defining the fast ON duration in ms.
108
- // all other durations are derived from that with some internal factors.
109
- void setTiming(uint16_t on_ms);
110
-
111
- // ` 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
112
130
bool isOn();
113
131
114
132
// You must call this in your loop!
@@ -121,10 +139,11 @@ int update();
121
139
122
140
No problem! You have two options.
123
141
124
- - Use the generic `Indicator` class from `<Indicator.h>`. The `.update()`-method returns
125
- a boolean whether the status is currently `HIGH` or `LOW`. You can then send this
126
- value to your status indicator (see `examples/GenericBlink`). Use the `FadingIndictor`
127
- 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`.
128
147
129
- - Subclass the `Indicator ` class with custom logic. This is what `IndicatorPin ` does
130
- 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