Skip to content

jandelgado/jled

Repository files navigation

Preferring Python? I just released jled-circuitpython, a JLed implementation for CircuitPython and MicroPython.

JLed - Advanced LED Library

run tests Coverage Status

An embedded C++ library to control LEDs. It uses a non-blocking approach and can control LEDs in simple (on/off) and complex (blinking, breathing and more) ways in a time-driven manner.

JLed got some coverage on Hackaday and someone did a video tutorial for JLed - Thanks!

JLed in action Interactive JLed playground
JLed in action jled running in the browser

Example

// breathe LED (on gpio 9) 6 times for 1500ms, waiting for 500ms after each run
#include <jled.h>

auto led_breathe = JLed(9).Breathe(1500).DelayAfter(500).Repeat(6);

void setup() { }

void loop() {
  led_breathe.Update();
}

Contents

Features

  • non-blocking
  • effects: simple on/off, breathe, blink, candle, fade-on, fade-off, user-defined (e.g. morse)
  • high resolution (up to 16-bit) effects, if the hardware supports it with JLedHD (since JLed 5.0)
  • supports inverted polarity of LED
  • easy configuration using fluent interface
  • can control groups of LEDs sequentially or in parallel
  • Portable: Arduino, ESP8266, ESP32, Mbed, Raspberry Pi Pico and more platforms compatible, runs even in the browser
  • supports Arduino, mbed, Raspberry Pi Pico and ESP32 ESP-IDF SDK's
  • well tested

Cheat Sheet

JLed Cheat Sheet

Installation

Arduino IDE

In the main menu of the Arduino IDE, select Sketch > Include Library > Manage Libraries... and search for jled, then press install.

PlatformIO

Add jled to your library dependencies in your platformio.ini project file, e.g.

...
[env:nanoatmega328]
platform = atmelavr
board = nanoatmega328
framework = arduino
lib_deps=jled
...

Usage

First, the LED object is constructed and configured, then the state is updated with subsequent calls to the Update() method, typically from the loop() function. While the effect is active, Update returns true, otherwise false.

The constructor takes the pin, to which the LED is connected to as the only argument. Further configuration of the LED object is done using a fluent interface, e.g. auto led = JLed(13).Breathe(2000).DelayAfter(1000).Repeat(5). See the examples section below for further details.

JLed vs JLedHD

JLed uses 8-bit brightness internally (uint8_t, 0–255), while JLedHD ("high-definition") uses 16-bit (uint16_t, 0–65535). Both share the same API and effects — the extra resolution is a zero-cost abstraction: the brightness type is a template parameter, so no virtual dispatch or runtime branching is involved.

When to use JLedHD: On long fade or breathe effects the 256 discrete steps of JLed can produce visible "staircase" banding, especially at low brightness. JLedHD eliminates this by giving the HAL up to 65536 values to work with; the HAL then maps them to the native PWM resolution of the platform (e.g. 13-bit on ESP32, 16-bit on Pico/Teensy).

When to stick with JLed: For simple on/off or blink effects the extra resolution buys nothing, and 8-bit uses half the memory per brightness value. Also note that on some platforms (see the table below) JLed and JLedHD resolve to the same HAL width (e.g. standard 8-bit Arduino boards), so JLedHD has no practical benefit there.

Note: You cannot mix JLed and JLedHD objects in the same sketch when both map to ArduinoHal with different bit widths, because analogWriteResolution() is a global setting. See the ArduinoHal note below.

Output pipeline

First the configured effect (e.g. Fade) is evaluated for the current time t. JLed internally uses either 8-bit (JLed, uint8_t, 0–255) or 16-bit (JLedHD, uint16_t, 0–65535) values to represent brightness. Next, the value is scaled to the limits set by MinBrightness and MaxBrightness (optionally). When the effect is configured for a low-active LED using LowActive, the brightness value will be inverted. Finally the value is passed to the hardware abstraction, which scales it to the native PWM resolution of the platform (e.g. 13 bits for ESP32 JLedHD, 16 bits for Pico JLedHD). The brightness value is then written out to the configured GPIO.

┌───────────┐    ┌────────────┐    ┌─────────┐    ┌────────┐    ┌─────────┐    ┌────────┐
│ Evaluate  │    │  Scale to  │    │  Low    │YES │ Invert │    │Scale for│    │Write to│
│ effect(t) ├───►│ [min, max] ├───►│ active? ├───►│ signal ├───►│Hardware ├───►│  GPIO  │
└───────────┘    └────────────┘    └────┬────┘    └────────┘    └───▲─────┘    └────────┘
                                        │ NO                        │
                                        └───────────────────────────┘

Effects

Static on and off

Calling On(uint16_t period=1) turns the LED on. To immediately turn a LED on, make a call like JLed(LED_BUILTIN).On().Update(). The period is optional and defaults to 1ms.

Off() works like On(), except that it turns the LED off, i.e., it sets the brightness to 0.

Use the Set(Brightness brightness, uint16_t period=1) method to set the brightness to a specific value. The type of brightness depends on the instantiation: uint8_t (0–255) for JLed, and uint16_t (0–65535) for JLedHD. For example, Set(255) is equivalent to calling On() and Set(0) is equivalent to calling Off() when using JLed; with JLedHD the full range is Set(65535) for full brightness.

To write brightness values that work with both JLed and JLedHD without change, use jled::Percentage or the _pct user-defined literal (requires using jled::operator""_pct). Percentage converts implicitly to the correct range for whichever brightness type is active:

using jled::operator""_pct;

JLed   led   = JLed(13)  .Set(75_pct);  // 75 % of 255  → 191
JLedHD ledHD = JLedHD(13).Set(75_pct);  // 75 % of 65535 → 49151
// Equivalent explicit form:
JLed   led2  = JLed(13)  .Set(jled::Percentage(75));

Technically, Set, On and Off are effects with a default period of 1ms, that set the brightness to a constant value. Specifying a different period has an effect on when the Update() method will be done updating the effect and return false (like for any other effects). This is important when for example in a JLedSequence the LED should stay on for a given amount of time.

Static on example
#include <jled.h>

// turn builtin LED on after 1 second.
auto led = JLed(LED_BUILTIN).On().DelayBefore(1000);

void setup() { }

void loop() {
  led.Update();
}

Blinking

In blinking mode, the LED cycles through a given number of on-off cycles, on- and off-cycle durations are specified independently. The Blink() method takes the duration for the on- and off cycle as arguments.

Blinking example
#include <jled.h>

// blink internal LED every second; 1 second on, 0.5 second off.
auto led = JLed(LED_BUILTIN).Blink(1000, 500).Forever();

void setup() { }

void loop() {
  led.Update();
}

Breathing

In breathing mode, the LED smoothly changes the brightness using PWM. The Breathe() method takes the period of the effect as an argument.

Breathing example
#include <jled.h>

// connect LED to pin 13 (PWM capable). LED will breathe with period of
// 2000ms and a delay of 1000ms after each period.
auto led = JLed(13).Breathe(2000).DelayAfter(1000).Forever();

void setup() { }

void loop() {
  led.Update();
}

It is also possible to specify fade-on, on- and fade-off durations for the breathing mode to customize the effect.

// LED will fade-on in 500ms, stay on for 1000ms, and fade-off in 500ms.
// It will delay for 1000ms afterwards and continue the pattern.
auto led = JLed(13).Breathe(500, 1000, 500).DelayAfter(1000).Forever();

Candle

In candle mode, the random flickering of a candle or fire is simulated. The builder method has the following signature: Candle(uint8_t speed, uint8_t jitter, uint16_t period)

  • speed - controls the speed of the effect. 0 for fastest, increasing speed divides into halve per increment. The default value is 6.
  • jitter - the amount of jittering. 0 none (constant on), 255 maximum. Default value is 15.
  • period - Period of effect in ms. The default value is 65535 ms.

The default settings simulate a candle. For a fire effect for example use call the method with Candle(5 /*speed*/, 100 /* jitter*/).

Candle example
#include <jled.h>

// Candle on LED pin 13 (PWM capable).
auto led = JLed(13).Candle();

void setup() { }

void loop() {
  led.Update();
}

FadeOn

In FadeOn mode, the LED is smoothly faded on to 100% brightness using PWM. The FadeOn() method takes the period of the effect as an argument.

The brightness function uses an approximation of this function (example with period 1000):

fadeon function

FadeOn example
#include <jled.h>

// LED is connected to pin 9 (PWM capable) gpio
auto led = JLed(9).FadeOn(1000).DelayBefore(2000);

void setup() { }

void loop() {
  led.Update();
}

FadeOff

In FadeOff mode, the LED is smoothly faded off using PWM. The fade starts at 100% brightness. Internally it is implemented as a mirrored version of the FadeOn function, i.e., FadeOff(t) = FadeOn(period-t). The FadeOff() method takes the period of the effect as argument.

Fade

The Fade effect allows to fade from any start value from to any target value to with the given duration. Internally it sets up a FadeOn or FadeOff effect and MinBrightness and MaxBrightness values properly. The Fade method take three arguments: from, to and duration.

fade from-to

Fade example
#include <jled.h>

// fade from 100 to 200 with period 1000
auto led = JLed(9).Fade(100, 200, 1000);

void setup() { }

void loop() {
  led.Update();
}

User provided brightness function

It is also possible to provide a user defined brightness evaluator. The class must be derived from the jled::BrightnessEvaluator<Brightness> template class and implement two methods:

  • Brightness Eval(uint32_t t) const - the brightness evaluation function that calculates a brightness for the given time t. The brightness must be returned as an unsigned byte, where 0 means LED off and 255 means full brightness if Brightness is uint8_t and as an unsigned int between 0 and 65535 if Brightness is uint16_t.
  • uint16_t Period() const - period of the effect.

All time values are specified in milliseconds.

The user_func example demonstrates a simple user provided brightness function, while the morse example shows how a more complex application, allowing you to send morse codes (not necessarily with an LED), can be realized.

User provided brightness function example

The example shows how to implement a user defined effect that works both with JLed and JLedHD

template<typename Brightness>
class UserEffect : public jled::BrightnessEvaluator<Brightness> {
  public:
    Brightness Eval(uint32_t t) const override {
        // this function changes between OFF and ON  every 250 ms.
        return jled::BrightnessTraits<Brightness>::kFullBrightness*((t/250)%2);
    }
    // duration of effect: 5 seconds.
    uint16_t Period() const override { return 5000; }
};

Delays and repetitions

Initial delay before effect starts

Use the DelayBefore() method to specify a delay before the first effect starts. The default value is 0 ms.

Delay after effect finished

Use the DelayAfter() method to specify a delay after each repetition of an effect. The default value is 0 ms.

Repetitions

Use the Repeat() method to specify the number of repetitions. The default value is 1 repetition. The Forever() method sets to repeat the effect forever. Each repetition includes a full period of the effect and the time specified by DelayAfter() method. Use IsForever() to query whether the effect is set to repeat forever.

State functions

Update

Call Update(int16_t *pLast=nullptr) or Update(uint32_t t, int16_t *pLast=nullptr) to periodically update the state of the LED.

Update returns true, if the effect is active, or false when it finished. Update() is a shortcut to call Update(uint32_t t) with the current time in milliseconds.

To obtain the value of the last written brightness value (after applying min- and max-brightness transformations), pass an additional optional pointer *pLast , where this value will be stored, when it was written. Example:

int16_t lastVal = -1;
led.Update(&lastVal);
if (lastVal != -1) {
    // the LED was updated with the brightness value now stored in lastVal
    ...
}

Most of the time just calling Update() without any parameters is what you want.

See last_brightness example for a working example.

IsRunning

IsRunning() returns true if the current effect is running, else false.

Reset

A call to Reset() brings the JLed object to its initial state. Use it when you want to start-over an effect.

Immediate Stop

Call Stop() to immediately turn the LED off and stop any running effects. Further calls to Update() will have no effect, unless the Led is reset using Reset() or a new effect is activated. By default, Stop() sets the current brightness level to MinBrightness.

Stop() takes an optional argument mode of type JLed::eStopMode:

  • if set to JLed::eStopMode::KEEP_CURRENT, the LEDs current level will be kept
  • if set to JLed::eStopMode::FULL_OFF the level of the LED is set to 0, regardless of what MinBrightness is set to, effectively turning the LED off
  • if set to JLed::eStopMode::TO_MIN_BRIGHTNESS (default behavior), the LED will set to the value of MinBrightness
// stop the effect and set the brightness level to 0, regardless of min brightness
led.Stop(JLed::eStopMode::FULL_OFF);

Misc functions

Low active for inverted output

Use the LowActive() method when the connected LED is low active. All output will be inverted by JLed (i.e., instead of x, the value of FullBrightness - x will be set, where FullBrightness is 255 for JLed and 65535 for JLedHD). Use IsLowActive() to query whether the LED is configured as low active.

Minimum- and Maximum brightness level

The MaxBrightness(Brightness level) method is used to set the maximum brightness level of the LED, where Brightness is uint8_t for JLed and uint16_t for JLedHD. A level of full brightness (255 / 65535, the default) is maximum output, while 0 effectively turns the LED off. In the same way, the MinBrightness(Brightness level) method sets the minimum brightness level. The default minimum level is 0. If minimum or maximum brightness levels are set, the output value is scaled to be within the interval defined by [minimum brightness, maximum brightness]: a value of 0 will be mapped to the minimum brightness level, and a value of full brightness will be mapped to the maximum brightness level.

To specify levels independently of the brightness type, use jled::Percentage or the _pct literal (see Percentage below).

The Brightness MaxBrightness() const method returns the current maximum brightness level. Brightness MinBrightness() const returns the current minimum brightness level.

Controlling a group of LEDs

The JLedSequence class allows controlling a group of JLed objects simultaneously, either in parallel or sequentially, starting the next JLed effect when the previous finished. The companion JLedSequenceHD class works identically but controls JLedHD objects. Note that JLed and JLedHD objects cannot be mixed in the same sequence. The constructor takes the mode (PARALLEL, SEQUENCE), an array of JLed objects and the size of the array, e.g.

JLed leds[] = {
    JLed(4).Blink(750, 250).Repeat(10),
    JLed(3).Breathe(2000).Repeat(5);
};

auto sequence = JLedSequence(JLedSequence::eMode::PARALLEL, leds).Repeat(2);

void setup() {
}

void loop() {
    sequence.Update();
}

Because the size of the array is known at compile time in this example, it is not necessary to pass the array size to the constructor. A second constructor is available in case the JLed array is created dynamically at runtime: JLed(eMode mode, JLed* leds, size_t n).

The JLedSequence provides the following methods:

  • Update() - updates the active JLed objects controlled by the sequence. Like the JLed::Update() method, it returns true if an effect is running, else false.
  • Use the Repeat(n) method to specify the number of repetitions. The default value is 1 repetition. The Forever() methods sets to repeat the sequence forever.
  • Stop() - turns off all JLed objects controlled by the sequence and stops the sequence. Further calls to Update() will have no effect.
  • Reset() - Resets all JLed objects controlled by the sequence and the sequence, resulting in a start-over.

Framework notes

JLed supports the Arduino and mbed frameworks. When using platformio, the framework to be used is configured in the platform.ini file, as shown in the following example, which for example selects the mbed framework:

[env:nucleo_f401re_mbed]
platform=ststm32
board = nucleo_f401re
framework = mbed
build_flags = -Isrc
src_filter = +<../../src/>  +<./>
upload_protocol=stlink

An mbed example is provided here. To compile it for the F401RE, make your plaform.ini look like:

...
[platformio]
default_envs = nucleo_f401re_mbed
src_dir = examples/multiled_mbed
...

Platform notes

Resolution and the Brightness type

JLed calculates all effects in either 8-bit precision (uint8_t, used by JLed) or 16-bit precision (uint16_t, used by JLedHD). Before writing to hardware, the value is scaled from the internal precision to the native PWM resolution of the HAL. This scaling is performed by a single bit-shift and is zero-cost when source and target resolutions are identical (e.g. 8-bit internal → 8-bit HAL, or 16-bit internal → 16-bit HAL).

To specify brightness values that work transparently with both JLed and JLedHD without any code changes, use Percentage or the _pct user-defined literal:

using jled::operator""_pct;

JLed   led   = JLed(13)  .MaxBrightness(75_pct).Breathe(500);  // 75 % of 255
// or ...
JLedHD led16 = JLedHD(13).MaxBrightness(75_pct).Breathe(500);  // 75 % of 65535
// Both of the above are equivalent to: .MaxBrightness(jled::Percentage(75))

The following table shows the HAL and native PWM resolution used by JLed and JLedHD on each supported platform:

Platform JLed JLedHD
ESP32 (native SDK / ESP-IDF) Esp32Hal<8> (8-bit) Esp32Hal<13> (13-bit)
Raspberry Pi Pico (native Pico SDK) PicoHal<8> (8-bit) PicoHal<16> (16-bit)
mbed MbedHal<8> (8-bit) MbedHal<16> (16-bit)
Teensy 4.x / 3.x / LC ArduinoHal<8> (8-bit) ArduinoHal<16> (16-bit)
SAMD21 (Arduino Zero, MKR series) / Arduino Due ArduinoHal<8> (8-bit) ArduinoHal<12> (12-bit)
STM32 (STM32duino) ArduinoHal<8> (8-bit) ArduinoHal<12> (12-bit)
nRF5 (Nordic) ArduinoHal<8> (8-bit) ArduinoHal<12> (12-bit)
RP2040 arduino-pico SDK (with JLED_FORCE_ARDUINO_HAL) ArduinoHal<8> (8-bit) ArduinoHal<16> (16-bit)
ESP8266 Arduino core v1/v2 ArduinoHal<10> (10-bit) ArduinoHal<10> (10-bit)
All other Arduino-compatible platforms ArduinoHal<8> (8-bit) ArduinoHal<8> (8-bit)

Internally, JLed performs all effect calculations in 8-bit arithmetic (uint8_t). The result is passed directly to the HAL, which writes it via analogWrite using 8-bit resolution.

JLedHD performs the same calculations in 16-bit arithmetic (uint16_t), giving 256× finer intermediate values. If the platform's native PWM resolution is lower than 16 bits (e.g. 13-bit on ESP32), the HAL right-shifts the value to fit: a 16-bit brightness of 65535 becomes 8191 in 13-bit space. No precision is fabricated — the extra bits simply allow the effect evaluator to express smoother transitions before the final hardware mapping is applied.

ArduinoHal and the global analogWriteResolution limit

ArduinoHal uses Arduino's analogWriteResolution() to configure PWM resolution, which is a global, sketch-wide setting that applies to every PWM pin at once. As a consequence, you cannot mix JLed (8-bit) and JLedHD objects in the same sketch when both resolve to ArduinoHal with different bit widths. The last analogWriteResolution() call wins and silently misconfigures the other instances. This affects all platforms where JLedHD maps to a higher resolution than 8-bit: Teensy (16-bit), SAMD21 / Arduino Due / STM32 / nRF5 (12-bit), ESP8266 core v1/v2 (10-bit), and RP2040 via arduino-pico (16-bit). On all remaining Arduino-compatible platforms both types share the same 8-bit resolution, so mixing is safe.

JLED_FORCE_ARDUINO_HAL

Define JLED_FORCE_ARDUINO_HAL (e.g. via build_flags in platformio.ini) to bypass the native Pico-SDK and ESP32 HALs and fall back to the generic ArduinoHal. This is useful when targeting those platforms through the Arduino framework rather than the native SDK, or for debugging purposes.

[env:my_board]
platform = ...
build_flags = -DJLED_FORCE_ARDUINO_HAL

When JLED_FORCE_ARDUINO_HAL is set on an RP2040 board, JLedHD maps to ArduinoHal<16> (Earle Philhower arduino-pico SDK) instead of PicoHal<16>, subject to the global analogWriteResolution constraint described above.

ESP8266

The ESP8266 PWM peripheral supports up to 10-bit resolution. Both JLed and JLedHD on Arduino core v1/v2 operate at native 10-bit resolution (ArduinoHal<10>), with brightness values scaled from 8-bit or 16-bit internal precision accordingly. Note that ESP8266 Arduino core v3+ reverted PWM to 8 bits for compatibility, so JLedHD maps to ArduinoHal<8> there and offers no additional resolution over JLed.

ESP32

When compiling for the ESP32, JLed uses ledc functions provided by the ESP32 ESP-IDF SDK. (See espressif documentation for details).

The ledc API connects so-called channels to GPIO pins, enabling them to use PWM. There are LEDC_CHANNEL_MAX (8) channels available per speed mode. Unless otherwise specified, JLed automatically picks the next free channel, starting with channel 0 and wrapping over after the last channel. To manually specify a channel, the JLed object must be constructed this way:

auto esp32Led = JLed(jled::Esp32Hal<8>(2, 7)).Blink(1000, 1000).Forever();

JLed uses Esp32Hal<8> (8-bit PWM, LEDC_TIMER_0) and JLedHD uses Esp32Hal<13> (13-bit PWM, LEDC_TIMER_1). Both types can be used simultaneously because they are assigned to separate timers and LEDC channels. Higher resolutions produce smoother brightness gradients at the cost of a lower maximum PWM frequency. At 13-bit resolution and the default 5 kHz base frequency the ESP32 is still well within its hardware limits.

The jled::Esp32Hal(pin, chan) constructor takes the pin number as the first argument and the ESP32 ledc channel number on the second position. Note that using the above-mentioned constructor results in non-platform independent code, so it should be avoided and is normally not necessary.

For completeness, the full signature of the Esp32Hal constructor is

Esp32Hal(PinType pin, int chan = kAutoSelectChan, uint16_t freq = 5000)

The PWM resolution and timer are template parameters, not runtime arguments:

// default: 8-bit resolution, LEDC_TIMER_0
template<uint8_t kResBits = 8, ledc_timer_t kTimer = LEDC_TIMER_0>
class Esp32Hal;

This allows to override the default frequency, resolution, and timer when needed.

Important: Do not call Arduino SDK functions pinMode or digitalWrite on GPIO pins that are controlled by JLed, because that would interfere with JLed using the Espressif ledc API directly, resulting in malfunctioning JLed LEDs.

Important: Each GPIO pin must be controlled by at most one JLed (or JLedHD) object at a time. Constructing a second JLed on the same pin will silently reconfigure the shared LEDC channel, disrupting the first object.

Using ESP-IDF

Since JLed uses the ESP-IDF SDK, JLed can also be directly used in ESP-IDF projects, without the need of using the Arduino Framework (which is also possible). See these repositories for example projects:

STM32

Arduino framework

I had success running JLed on a STM32 Nucleo64 F401RE board using this STM32 Arduino core and compiling examples from the Arduino IDE. Note that the stlink is necessary to upload sketches to the microcontroller.

Raspberry Pi Pico

When using JLed on a Raspberry Pi Pico with the native Pico SDK, JLed uses PicoHal<8> (8-bit PWM) and JLedHD uses PicoHal<16> (16-bit PWM). Each PWM slice is configured independently, so JLed and JLedHD instances can be mixed freely, except when two pins share the same PWM slice (e.g. GPIO 10 and GPIO 11 both use slice 5): pins on the same slice must use the same resolution, otherwise their wrap register will be silently overwritten.

With a fixed clock divider of 1 the PWM frequency depends on resolution:

Bits RP2040 frequency RP2350 frequency
8 ~488 kHz ~586 kHz
10 ~122 kHz ~146 kHz
12 ~30.5 kHz ~36.6 kHz
16 ~1.9 kHz ~2.3 kHz

Even at 16-bit resolution the PWM frequency stays above 1 kHz, producing smooth visible output on LEDs. The Pico supports up to 16 PWM channels in parallel. See the pico-demo for an example and build instructions.

When using the Arduino framework on the RP2040 (Earle Philhower arduino-pico SDK), JLedHD maps to ArduinoHal<16> (16-bit) instead. The analogWriteResolution global constraint described above applies in this case. See platformio.ini for details (look for env:raspberrypi_pico_w, which targets the Raspberry Pi Pico W).

Example sketches

Example sketches are provided in the examples directory.

Building examples with PlatformIO

To build an example using the PlatformIO ide, uncomment the example to be built in the platformio.ini project file, e.g.:

[platformio]
; uncomment example to build
src_dir = examples/hello
;src_dir = examples/breathe

Building examples with the Arduino IDE

To build an example sketch in the Arduino IDE, select an example from the File > Examples > JLed menu.

Extending

Support new hardware

JLed uses a very thin hardware abstraction layer (HAL) to abstract access to the actual MCU/framework used (e.g. ESP32, ESP8266). The HAL encapsulates access to the GPIO and clock functionality of the MCU under the framework being used. During the unit tests, mocked HAL instances are used, enabling tests to check the generated output. The Custom HAL example provides an example for a user defined HAL.

Unit tests

JLed comes with an exhaustive host-based unit test suite. Info on how to run the host-based provided unit tests is provided here.

Contributing

  • fork this repository
  • create your feature branch
  • add code
  • add unit test(s)
  • add documentation
  • make sure the cpp linter does not report any problems (run make lint). Hint: use clang-format with the provided settings
  • commit changes
  • submit a PR

FAQ

How do I check if a JLed object is still being updated?

  • Check the return value of the JLed::Update method: the method returns true if the effect is still running, otherwise false.
  • The JLed::IsRunning method returns true if an effect is running, else false.

How do I restart an effect?

Call Reset() on a JLed object to start over.

How do I change a running effect?

Just 'reconfigure' the JLed with any of the effect methods (e.g. FadeOn, Breathe, Blink etc). Time-wise, the effect will start over.

Author and Copyright

Copyright © 2017-2026 by Jan Delgado.

License

MIT