Skip to main content

LED Chains

Introduction

The p44-ledchain kernel module created by plan44 can be used to drive external, individually addressable WS281x-type RGB and RGBW LED chains.

The LED chains must be connected to 1 of the 4 hardware PWM channels on the Omega2/Omega2S.

For full details about the p44-ledchain kernel module and its usage, see the README on GitHub. (Below are quick notes on how to get an LED Chain up and running.)

First Time Setup

Make sure your Omega2 is connected to the internet, and install the kernel module using opkg:

opkg update
opkg install kmod-p44-ledchain

This needs to be done only once.

Hardware

External LED chains can be connected to any of the 4 hardware PWM channels. The Omega2 can simultaneously run 4 strings of LED’s and external LED chains can be connected to any of the 4 hardware PWM channels.

The following LED Chain types are supported:

  • WS2811
  • WS2812(B)
  • WS2813(B)
  • WS2815
  • P9823
  • SK6812

PWM channels and their corresponding GPIO pins.

PWM ChannelGPIONotes
0GPIO18
1GPIO19
2GPIO20Omega2S only
3GPIO21Omega2S only

Software

GPIO Mux

To enable the PWM channel, first adjust the GPIO muxing. The GPIO mux command depends on the PWM Channel that's used to connect to the LED Chain. See the hardware PWM and GPIO Muxing docs articles for more information.

omega2-ctrl gpiomux set pwm0 pwm
tip

These commands do not persist after shutdown and will need to be run after every system boot

Activate the LED Chain Driver

The LED Chain driver can be activated with the following command:

insmod p44-ledchain ledchain<PWMno>=<inverted>,<numberofleds>,<ledtype>[,<maxretries>[,<maxTpassive>]]

This will create a /dev/ledchain<PWMno> device which can be used to control the physical LED chain.

tip

This command do not persist after shutdown and will need to be run after every system boot

info

The command will depend on which PWM channel the LED chain is connected to, and what type of LEDs are in the chain.

See the p44-ledchain README on GitHub for more info.

Example

For a single, non-inverted WS2812(B) LED connected to PWM channel 2, the command would be:

insmod p44-ledchain ledchain2=0,1,0x0001

Now a /dev/ledchain2 device will be created.

For more detail on using LED Chains, see the p44-ledchain README.

Update the LEDs

The LEDs can be updated by writing strings of bytes into the /dev/ledchain<PWMno> device.

To set the first two LEDs bright red in a device connected to PWM channel 0:

echo -en '\xFF\x00\x00\xFF\x00\x00' >/dev/ledchain0

To set the first LED to bright white in a device connected to PWM channel 2:

echo -en '\xFF\xFF\xFF' >/dev/ledchain2