Skip to content

Commit 6800200

Browse files
committed
update readme
1 parent b70ec83 commit 6800200

File tree

5 files changed

+82
-35
lines changed

5 files changed

+82
-35
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Changelog
22

3-
## WIP
3+
## v2.0.0 (2021-12-16)
44

55
- **Revamped API!**
66
- New: writes the state only on changes, not on every update

README.md

Lines changed: 51 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ logarithmic LED brightness compensation. Your boards never looked more professio
5656
5757
```C
5858
// Without fading effect:
59-
#include <IndicatorPin.h>
60-
IndicatorPin myPin(13);
59+
#include <Indicator.h>
60+
Indicator myPin(13);
6161
6262
// With fading effect:
63-
#include <FadingIndicatorPin.h>
64-
FadingIndicatorPin myPin(13);
63+
#include <FadeIndicator.h>
64+
FadeIndicator myPin(13);
6565
6666
// now in your code you can do:
6767
myPin.permanent(LOW);
@@ -70,45 +70,63 @@ myPin.blink();
7070
```
7171

7272
```C
73+
// set permanently ON
74+
void on();
75+
76+
// set permanently OFF
77+
void off();
78+
7379
// toggle between on / off
7480
void toggle();
7581

7682
// set ON / OFF permanently
7783
void permanent(bool enable);
7884

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);
8187

8288
// blink `num` times, then long pause
8389
// 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);
8591

8692
// blink `num1` times, short pause, blink `num2` times, long pause
8793
// 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);
8995

9096
// turn ON for the given duration in ms. Continues in the previous mode afterwards.
9197
void flash(uint16_t duration_ms);
9298

99+
// turn OFF for the given duration in ms. Continues in the previous mode afterwards.
100+
void pause(uint16_t duration_ms);
101+
93102
// 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
112130
bool isOn();
113131

114132
// You must call this in your loop!
@@ -121,10 +139,11 @@ int update();
121139
122140
No problem! You have two options.
123141
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`.
128147
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!

examples/SerialBlink/SerialBlink.ino

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* This example does not blink a light, but outputs its state directly to the Serial
3+
* port.
4+
*/
5+
6+
#include <BaseIndicator.h>
7+
8+
class SerialBlinker : public BaseIndicator
9+
{
10+
public:
11+
void write(int state) override
12+
{
13+
Serial.print("LED: ");
14+
Serial.println(state);
15+
}
16+
};
17+
18+
SerialBlinker myBlinker;
19+
20+
void setup()
21+
{
22+
myBlinker.pattern(2, 4);
23+
}
24+
25+
void loop()
26+
{
27+
myBlinker.update();
28+
}

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Indicator",
3-
"version": "1.2.0",
3+
"version": "2.0.0",
44
"description": "This library gives you non-blocking blinking patterns and smooth fade effects for your LEDs, buzzers or any other status indicators",
55
"keywords": "led, signal, fading, blink",
66
"repository": {

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=Indicator
2-
version=1.2.0
2+
version=2.0.0
33
author=Thomas Feldmann <mail@tfeldmann.de>
44
maintainer=Thomas Feldmann <mail@tfeldmann.de>
55
sentence=Supercharge your status LEDs / beepers

0 commit comments

Comments
 (0)