bibliopixel.drivers.PiWS281X module

class bibliopixel.drivers.PiWS281X.PiWS281X(num, gamma=<bibliopixel.colors.gamma.Gamma object>, c_order='RGB', gpio=18, ledFreqHz=800000, ledDma=5, ledInvert=False, color_channels=3, brightness=255, **kwds)[source]

Bases: bibliopixel.drivers.driver_base.DriverBase

Driver for controlling WS281X LEDs via the rpi_ws281x C-extension. Only supported on the Raspberry Pi 2, 3, and Zero

This driver needs to be run as sudo and requires the rpi_ws281x C extension.

Install rpi_ws281x with the following shell commands:

git clone https://github.com/jgarff/rpi_ws281x.git cd rpi_ws281x

sudo apt-get install python-dev swig scons sudo scons

cd python # If using default system python3 sudo python3 setup.py build install # If using virtualenv, enter env then run python setup.py build install

Provides the same parameters of driver_base.DriverBase as well as those below:

Parameters:
  • gpio (int) – GPIO pin to output to. Typically 18 or 13
  • ledFreqHz (int) – WS2812B base data frequency in Hz. Only change to 400000 if using very old WS218B LEDs
  • ledDma (int) – DMA channel to use for generating signal (between 1 and 14)
  • ledInvert (bool) – True to invert the signal (when using NPN transistor level shift)
set_brightness(brightness)[source]

Set the global brightness for this driver’s output.

Parameters:brightness (int) – 0-255 value representing the desired brightness level