Simple client-server python library for rpi_ws281x.
PWM GPIO pins on Raspberry Pi that are used for driving the LEDs require root access. To avoid running everything with sudo, only the server runs priviliged and writes color data to LEDs, while client provides user-friendly functions for drawing on the LED matrix and can be imported elsewhere.
- Clone the base repository: https://github.com/jgarff/rpi_ws281x (This doesn't have to be catkin workspace. It is recommended to make a new directory in /home/user for such packages, e.g. /home/user/CustomPackages)
- Follow the Build instructions (using Scons) of the base repository
- Check their Running section to test out the build.
- Install necessary python packages:
sudo pip3 install rpi_ws281x pyzmq numpy
(Using sudo is important!) - Clone this repository (wherever).
- Install the library so it can be imported from anywhere:
cd <path_to_cloned_repository>/src
pip3 install .
- Make a symlink so server can be run from anywhere.
sudo ln -s <full_path_to_package>/LED_server.py /usr/local/bin/LED_server
To test the installation, run sudo python3 rpi_ws281x_pylib/examples/test_example.py
.
To control the LEDs, first run sudo python3 LED_server.py
. Then, in a separate process, run python3 LED_client.py
. Client currently cycles through 32 colors for a few seconds and then exits. In general, you want to import the client to your application, create an instance and then use the API functions to get the desired effects.
All examples assume you are positioned in the examples
directory.
- Set color from CMD.
bash set_cmd.sh