Package: rpi-ws281x
Userspace Raspberry Pi library for controlling WS281X LEDs. This
includes WS2812 and SK6812RGB RGB LEDs Preliminary support is now
included for SK6812RGBW LEDs (yes, RGB + W) The LEDs can be controlled
by either the PWM (2 independent channels) or PCM controller (1 channel)
or the SPI interface (1 channel).Background:The BCM2835 in the Raspberry Pi has both a PWM and a PCM module that are
well suited to driving individually controllable WS281X LEDs. Using the
DMA, PWM or PCM FIFO, and serial mode in the PWM, it’s possible to
control almost any number of WS281X LEDs in a chain connected to the
appropriate output pin. For SPI the Raspbian spidev driver is used
(/dev/spidev0.0). This library and test program set the clock rate
to 3X the desired output frequency and creates a bit pattern in RAM from
an array of colors where each bit is represented by 3 bits as follows.Bit 1 - 1 1 0
Bit 0 - 1 0 0GPIO Usage:The GPIOs that can be used are limited by the hardware of the Pi and
will vary based on the method used to drive them (PWM, PCM or SPI).
Beware that the GPIO numbers are not the same as the physical pin
numbers on the header.PWM:PWM0, which can be set to use GPIOs 12, 18, 40, and 52.
Only 12 (pin 32) and 18 (pin 12) are available on the B+/2B/3B

PWM1 which can be set to use GPIOs 13, 19, 41, 45 and 53.
Only 13 is available on the B+/2B/PiZero/3B, on pin 33PCM:PCM_DOUT, which can be set to use GPIOs 21 and 31.
Only 21 is available on the B+/2B/PiZero/3B, on pin 40.SPI:SPI0-MOSI is available on GPIOs 10 and 38.
Only GPIO 10 is available on all models.
See also note for RPi 3 below.Power and voltage requirementsWS281X LEDs are generally driven at 5V. Depending on your actual LED
model and data line length you might be able to successfully drive the
data input with 3.3V. However in the general case you probably want to
use a level shifter to convert from the Raspberry Pi GPIO/PWM to 5V.It is also possible to run the LEDs from a 3.3V - 3.6V power source, and
connect the GPIO directly at a cost of brightness, but this isn’t
recommended.The test program is designed to drive a 8x8 grid of LEDs e.g.from
Adafruit (http://www.adafruit.com/products/1487) or Pimoroni
(https://shop.pimoroni.com/products/unicorn-hat). Please see the
Adafruit and Pimoroni websites for more information.Know what you’re doing with the hardware and electricity. I take no
reponsibility for damage, harm, or mistakes.Important warning about DMA channelsYou must make sure that the DMA channel you choose to use for the LEDs
is notalready in
useby the operating system.For example,using DMA channel 5 will cause filesystem corruptionon the Raspberry Pi 3 Model B.
See:https://github.com/jgarff/rpi_ws281x/issues/224The default DMA channel (10) should be safe for the Raspberry Pi 3 Model
B, but this may change in future software releases.Limitations:PWMSince this library and the onboard Raspberry Pi audio both use the PWM,
they cannot be used together. You will need to blacklist the Broadcom
audio kernel module by creating a file/etc/modprobe.d/snd-blacklist.confwithblacklist snd_bcm2835If the audio device is still loading after blacklisting, you may also
need to comment it out in the /etc/modules file.On headless systems you may also need to force audio through hdmi Edit
config.txt and add:hdmi_force_hotplug=1
hdmi_force_edid_audio=1A reboot is required for this change to take effectSome distributions use audio by default, even if nothing is being
played. If audio is needed, you can use a USB audio device instead.PCMWhen using PCM you cannot use digital audio devices which use I2S since
I2S uses the PCM hardware, but you can use analog audio.SPIWhen using SPI the ledstring is the only device which can be connected
to the SPI bus. Both digital (I2S/PCM) and analog (PWM) audio can be
used.Many distributions have a maximum SPI transfer of 4096 bytes. This can
be changed in/boot/cmdline.txtby appendingspidev.bufsiz=32768On a RPi 3 you have to change the GPU core frequency to 250 MHz,
otherwise the SPI clock has the wrong frequency. Do this by adding the
following line to /boot/config.txt and reboot.core_freq=250On a RPi 4 its dynamic frequency clocking has to be disabled, since it will
desync the SPI clock. Do this by adding this line to/boot/config.txt. (core_freqdoes not have to be changed, since
the default value of 500MHz is SPI compatible)core_freq_min=500SPI requires you to be in thegpiogroup if you wish to control your
LEDs without root.Comparison PWM/PCM/SPIBoth PWM and PCM use DMA transfer to output the control signal for the
LEDs. The max size of a DMA transfer is 65536 bytes. Since each LED
needs 12 bytes (4 colors, 8 symbols per color, 3 bits per symbol) this
means you can control approximately 5400 LEDs for a single strand in PCM
and 2700 LEDs per string for PWM (Only PWM can control 2 independent
strings simultaneously) SPI uses the SPI device driver in the kernel.
For transfers larger than 96 bytes the kernel driver also uses DMA. Of
course there are practical limits on power and signal quality. These
will be more constraining in practice than the theoretical limits above.When controlling a LED string of 240 LEDs the CPU load on the original
Pi 2 (BCM2836) are: PWM 5% PCM 5% SPI 1%5.0.0Bumped to rpi_ws281x v1.0.0 (15330cb)Full rpi_ws281x changes:https://github.com/jgarff/rpi_ws281x/compare/9be313f…15330cbNew: Added support for Revisions 0xa03141, 0xb03141, 0xc04141, 0xd03141 (CM4)New: Added support for Revision 0xa32082 (Pi 3 B)New: Added support for slices on PixelStripNew: Regenerated SWIG bindings with v4.0.2New: RGBW class for interfacing with pixel values4.3.4New: Added support for Revision 0xa03115 (Pi 4, 1GB v1.5)4.3.3New: Added support for Revision 0xc03115 (Pi 4, 4GB v1.5)New: Added support for Revision 0xd03115 (Pi 4, 8GB v1.5)4.3.2New: Added support for Revision 0xc03131 (Pi 400, 4GB v1.1)New: Added support for Revision 0xb03115 (Pi 4, 2GB v1.5)4.3.1New: Added support for Revision 0x902120 (Pi Zero 2 W v1.0)4.3.0Switched to upstream jgarff/rpi_ws281x libraryNew: Added support for Revision 0xd03140 (CM4 v1.0 WiFi)4.2.6New: Added support for Revision 0xc03114 (Pi 4, 4GB v1.4)New: Added support for Revision 0xa03140 (CM4 v1.0 eMMC)New: Added support for Revision 0xb03140 (CM4 v1.0 Lite)New: Added support for Revision 0xc03140 (CM4 v1.0 WiFi)4.2.5New: Added support for Revision 0xc03130 (Pi 400, 4GB)New: Added support for Revision 0xb03114 (Pi 4, 2GB v1.4)4.2.4Fix: Fixed rpi_hw_detect for aarch64New: Added support for Revision 0xD03114 (Raspberry Pi Model B - 8GB)4.2.3Fix: Added support for Pi 4 Rev 1.2 - 0xa03112, 0xb03112, 0xc031124.2.2Fix: Fixed Slice support when setting pixelsNew: Added support for Revision 0xa02083New: Added support for Revision 0xa220834.2.1Fix: Added white colour channel to Color()4.2.0New: Added support for Raspberry Pi 44.1.0New: Added support for the Pi 3A+Fix: Bugfix for ARM64 support4.0.0Warning: Removed “neopixel” module from this library, use “rpi_ws281x” instead, see #83.1.0New: Exposed all contents of ws for easy access to strip_type constantsFix: Matched functionality of upstream legacy library by supporting strip_typeNote: Default strip type is WS2811_STRIP_GRB3.0.7New: Added support for Pi 3B+