@@ -52,6 +52,7 @@ void loop() {
5252 * [ Arduino IDE] ( #arduino-ide )
5353 * [ PlatformIO] ( #platformio )
5454* [ Usage] ( #usage )
55+ * [ Output pipeline] ( #output-pipeline )
5556 * [ Effects] ( #effects )
5657 * [ Static on and off] ( #static-on-and-off )
5758 * [ Static on example] ( #static-on-example )
@@ -157,6 +158,27 @@ the only argument. Further configuration of the LED object is done using a fluen
157158interface, e.g. ` JLed led = JLed(13).Breathe(2000).DelayAfter(1000).Repeat(5) ` .
158159See the examples section below for further details.
159160
161+ #### Output pipeline
162+
163+ First the configured effect (e.g. ` Fade ` ) is evaluated for the current time
164+ ` t ` . JLed internally uses unsigned bytes to represent brightness values,
165+ ranging from 0 to 255. Next, the value is scaled to the limits set by
166+ ` MinBrightness ` and ` MaxBrightness ` (optionally). When the effect is configured
167+ for a low-active LED using ` LowActive ` , the brightness value will be inverted,
168+ i.e., the value will be subtracted from 255. Finally the value is passed to the
169+ hardware abstraction, which might scale it to the resolution used by the actual
170+ device (e.g. 10 bits for an ESP8266). Finally the brightness value is written
171+ out to the configure GPIO.
172+
173+ ```
174+ ┌───────────┐ ┌────────────┐ ┌─────────┐ ┌────────┐ ┌─────────┐ ┌────────┐
175+ │ Evaluate │ │ Scale to │ │ Low │YES │ Invert │ │Scale for│ │Write to│
176+ │ effect(t) ├───►│ [min, max] ├───►│ active? ├───►│ signal ├───►│Hardware ├───►│ GPIO │
177+ └───────────┘ └────────────┘ └────┬────┘ └────────┘ └───▲─────┘ └────────┘
178+ │ NO │
179+ └───────────────────────────┘
180+ ```
181+
160182### Effects
161183
162184#### Static on and off
@@ -165,15 +187,15 @@ Calling `On(uint16_t period=1)` turns the LED on. To immediately turn a LED on,
165187make a call like ` JLed(LED_BUILTIN).On().Update() ` . The ` period ` is optional
166188and defaults to 1ms.
167189
168- ` Off() ` works like ` On() ` , except that it turns the LED off, i.e. it sets the
190+ ` Off() ` works like ` On() ` , except that it turns the LED off, i.e., it sets the
169191brightness to 0.
170192
171193Use the ` Set(uint8_t brightness, uint16_t period=1) ` method to set the
172- brightness to the given value, i.e. ` Set(255) ` is equivalent to calling ` On() `
194+ brightness to the given value, i.e., ` Set(255) ` is equivalent to calling ` On() `
173195and ` Set(0) ` is equivalent to calling ` Off() ` .
174196
175197Technically, ` Set ` , ` On ` and ` Off ` are effects with a default period of 1ms, that
176- set the brightness to a constant value. Specifiying a different period has an
198+ set the brightness to a constant value. Specifying a different period has an
177199effect on when the ` Update() ` method will be done updating the effect and
178200return false (like for any other effects). This is important when for example
179201in a ` JLedSequence ` the LED should stay on for a given amount of time.
@@ -303,15 +325,15 @@ void loop() {
303325
304326In FadeOff mode, the LED is smoothly faded off using PWM. The fade starts at
305327100% brightness. Internally it is implemented as a mirrored version of the
306- FadeOn function, i.e. FadeOff(t) = FadeOn(period-t). The ` FadeOff() ` method
328+ FadeOn function, i.e., FadeOff(t) = FadeOn(period-t). The ` FadeOff() ` method
307329takes the period of the effect as argument.
308330
309331#### Fade
310332
311333The Fade effect allows to fade from any start value ` from ` to any target value
312334` to ` with the given duration. Internally it sets up a ` FadeOn ` or ` FadeOff `
313335effect and ` MinBrightness ` and ` MaxBrightness ` values properly. The ` Fade `
314- method take three argumens : ` from ` , ` to ` and ` duration ` .
336+ method take three arguments : ` from ` , ` to ` and ` duration ` .
315337
316338<a href =" examples/fade_from_to " ><img alt =" fade from-to " src =" doc/fade_from-to.png " height =200 ></a >
317339
@@ -403,15 +425,29 @@ you want to start-over an effect.
403425##### Immediate Stop
404426
405427Call `Stop()` to immediately turn the LED off and stop any running effects.
406- Further calls to `Update()` will have no effect unless the Led is reset (using
407- `Reset()`) or a new effect activated.
428+ Further calls to `Update()` will have no effect, unless the Led is reset using
429+ `Reset()` or a new effect is activated. By default, `Stop()` sets the current
430+ brightness level to `MinBrightness`.
431+
432+ `Stop()` takes an optional argument `mode` of type `JLed::eStopMode`:
433+
434+ * if set to `JLed::eStopMode::KEEP_CURRENT`, the LEDs current level will be kept
435+ * if set to `JLed::eStopMode::FULL_OFF` the level of the LED is set to `0`,
436+ regardless of what `MinBrightness` is set to, effectively turning the LED off
437+ * if set to `JLed::eStopMode::TO_MIN_BRIGHTNESS` (default behavior), the LED
438+ will set to the value of `MinBrightness`
439+
440+ ```c++
441+ // stop the effect and set the brightness level to 0, regardless of min brightness
442+ led.Stop(JLed::eStopMode::FULL_OFF);
443+ ```
408444
409445#### Misc functions
410446
411447##### Low active for inverted output
412448
413449Use the ` LowActive() ` method when the connected LED is low active. All output
414- will be inverted by JLed (i.e. instead of x, the value of 255-x will be set).
450+ will be inverted by JLed (i.e., instead of x, the value of 255-x will be set).
415451
416452##### Minimum- and Maximum brightness level
417453
@@ -502,7 +538,7 @@ src_dir = examples/multiled_mbed
502538
503539The DAC of the ESP8266 operates with 10 bits, every value JLed writes out gets
504540automatically scaled to 10 bits, since JLed internally only uses 8 bits. The
505- scaling methods make sure that min/max relationships are preserved, i.e. 0 is
541+ scaling methods make sure that min/max relationships are preserved, i.e., 0 is
506542mapped to 0 and 255 is mapped to 1023. When using a user-defined brightness
507543function on the ESP8266, 8-bit values must be returned, all scaling is done by
508544JLed transparently for the application, yielding platform-independent code.
0 commit comments