Thursday, August 16, 2012

Raspberry Pi and the WS2801



Update (October 29th):
Big update here:
http://thegreatgeekery.blogspot.ca/2012/10/pixelpi-update.html

Update (August 19th):
 - Pixel Invaders support provided in the 1.3.0-Beta4 release of pixel controller (Here: https://github.com/neophob/PixelController/downloads)
- Tested and working with the latest checked in version of PixelPi
- Run it like this: " sudo python pixelpi.py --chip WS2801 --mode all_off "
- It works by sending the pixel data to the pixelPi software using a UDP network connection.  So in pixelcontroller you must setup a UDP output device with the IP set to the IP address of your Raspberry Pi board  (Keep the port set at 6803)
- The PixelPi software receives the packet and sets the pixels accordingly.

Update (august 17th):
- Just added preliminary support for pixel invaders; Neophob (from http://www.pixelinvaders.ch) just added UDP support so the pixelcontroller software can talk to the Raspberry Pi (https://github.com/neophob/PixelController/issues/23)  Its still a work in progress but should be functional(ish)


What it does so far:
- Supports POV LED Strip (Like the original Adafruit Software)
- Now Support matrix displays (2D Panels)
- Added some test modes (fade and chase modes)
- Supports pixel remapping (by using a CSV file with the location of your pixels in the array)
- Adjustable refresh rate / chase rate
- All options selectable by command line args (no python tweaking required (hopefully))
 
What's up next.
 - panning on large images across the pixel array.  Ideally I was thinking it would be cool to pass in some images from vgamaps.com and have it pan around them.
- animation support (maybe animated GIF)
- TCP/IP support (support sending display data from another PC)





Installation:

Grab the python file:
git clone git://github.com/scottjgibson/PixelPi.git

Install Python Image library:
sudo aptitude install python-imaging-tk

UsageL
pi@raspberrypi ~/git/PixelPi $ sudo python pixelpi.py  --help
usage: pixelpi.py [-h] [-v] [--chip {WS2801,LDP8806}] --filename FILENAME
                  --mode {strip,array,fade,chase} [--verbose]
                  [--array_width ARRAY_WIDTH] [--array_height ARRAY_HEIGHT]
                  [--spi_dev SPI_DEV_NAME] [--refresh_rate REFRESH_RATE]

optional arguments:
  -h, --help            show this help message and exit
  -v, --version         show program's version number and exit
  --chip {WS2801,LDP8806}
                        Specify chip type LDP8806 or WS2801
  --filename FILENAME   Specify the image file eg: hello.png
  --mode {strip,array,fade,chase}
                        Choose the display mode, either POV strip or 2D array,
                        color, chase
  --verbose             enable verbose mode
  --array_width ARRAY_WIDTH
                        Set the X dimension of your pixel array (width)
  --array_height ARRAY_HEIGHT
                        Set the Y dimension of your pixel array (height)
  --spi_dev SPI_DEV_NAME
                        Set the SPI device descriptor
  --refresh_rate REFRESH_RATE
                        Set the refresh rate in ms (default 500ms)


Test with a fade:
sudo python pixelpi.py  --chip WS2801 --mode fade --refresh_rate 1

Test with a chase:
sudo python pixelpi.py  --chip WS2801 --mode chase--refresh_rate 1

Display an image (POV mode):
sudo python pixelpi.py  --chip WS2801 --mode strip --filename test.png --refresh_rate 1

Display an image (Array mode):
sudo python pixelpi.py  --chip WS2801 --mode array --filename test.png --refresh_rate 1


Wire up the RGB LED string:
I did something similar to this:
http://learn.adafruit.com/light-painting-with-raspberry-pi/hardware

My starting point:
http://learn.adafruit.com/light-painting-with-raspberry-pi/software