Skip to main content

Conecting WS2801 LED strip to Raspberry Pi

Project description

A python module connecting RPI with WS2801

This is version 1.0.0.dev4. It is in development. Code may change without notice.

It is based on the spidev module you can find here.

You can use it like this:

import WS2801_RPI as w
s=w.set_led_colors_buffer_list_multi_call
w.set_number_of_leds(100)                      # adjust to the number of leds in your project
w.s(1)                                         # to let led number 1 shine in white
w.flush()                                      # to communicate your settings to the led strip via spi

You can call set_leds as often as you like before flushing it out. And of course you can flush as often as you need to create effects.

Other convenience functions are:

  • clear(): turn off all leds. Remember you need to call flush() to see the effect.

  • get_led_colors_buffer_dict(): Get all rgb values currently in the buffer as dictionary. This might differ from what you see on your LED strip.

  • set_led_colors_buffer_dict_multi_call(): After you adjusted the dict of the function above: Write it back to the buffer. Don’t forget flush().

  • set_max_speed_hz(hz): Default is 1MHz. You may change this but not below 1,5KHz.

  • set_gamma(): Set the gamma value. Formula is: int(((rgb/255)**gamma)*255). Default is 2.1 which reduces the number of rgb values to approx. 187. Set it to 1 you will have 255 values per color but you won’t be able to see them. Your eye will turn many into white.

Installation

pip install WS2801_RPI.

Hint

You can raise the log level if you like to suppress warnings:

import logging
logging.getLogger().setLevel(31)

Acknowledgement

General remarks on WS2801:

  • In the Data Sheet of WS2801 I found the following passage I didn’t fully understand: When the WS2801 receives total 24 clock rising edges, the WS2801 enters relay mode .... In addition one can read this explanation. I found it helpful.

  • WS2801 is using the raising flag of the clock to retrieve the data and expects clock being low for 500 microseconds between data transmissions. Hence there is no need to chance the mode of spidev. It must be zero, regardless which effects you see.

Would be glad if this code was used often in your projects. Feedback and pull requests are more than welcome.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

WS2801_RPI-1.0.0.dev4-py2.py3-none-any.whl (8.4 kB view details)

Uploaded Python 2Python 3

File details

Details for the file WS2801_RPI-1.0.0.dev4-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for WS2801_RPI-1.0.0.dev4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 95db8ee5cdf6835d6061a5337c797cc6464d18745ae0ecc4252683ddbfb537d1
MD5 9212fcd6f444814fe1e51ab7a65a791f
BLAKE2b-256 7bc0ea21a66bbf7e01a526e9c72320182f3243d04e0755d8454c67666e235cbf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page