Software

UPDATE: Thanks to the July Raspbmc update, it is now even easier to get boblight working on your Raspberry Pi. See details here:
http://blog.nadnerb.co.uk/?p=166
(Yes, that means the majority of guide below is now outdated and shouldn't be followed)

Below are the steps to set up boblight on a Raspbmc system on a Raspberry Pi.
I have compiled these instructions from various sources including:

- This Raspberry Pi Forum thread
- Boblight wiki @ googlecode
- Adalight Arduino tutorial

And thanks to: Stasik0, VZoltan, crckmc and nyar for their hardwork on developing the patch and providing support.

If you have any issues or need help, then feel free to contact me on Twitter or leave a comment on my blog.

There are 4 parts to the software setup:

1. Install Raspbmc

2. Compile/install Boblight

3. Configure and test Boblight

4. Configure XBMC

Do NOT install the XBMC boblight plugin at any stage - it is not needed for this guide and will stop boblight from working.

Part 1 - Install Raspbmc

1.1 - Download and install Raspbmc
See http://www.raspbmc.com/download/ for instructions.

Part 2 - Compile/install Boblight

2.1 - Boot up your Pi and your fresh installation of XBMC should be running. To speed up the installation of other components you can stop the XBMC process. You also need to run some updates before you begin:
sudo initctl stop xbmc
sudo apt-get update

2.2 - Install the packages make, gcc, g++ and subversion. Remember to type 'Y' when prompted to confirm installation.
sudo apt-get install make gcc g++ subversion

2.3 - Download boblight source from Googlecode
svn checkout http://boblight.googlecode.com/svn/trunk/ /home/pi/boblight_source

2.4 - Configure and check boblight source is ready to compile
cd /home/pi/boblight_source/
./configure --without-portaudio --without-x11 --without-libusb

2.5 - Check it has completed ok without any errors. There may be warnings, but thats ok, so go ahead and run make...
make;sudo make install

Part 3 - Configure and test Boblight

To tell Boblight how to control your LEDs you need to create a boblight.conf file, depending on what LEDs you have follow one of these steps:

3.1A - If you have 50 WS2801 LEDs, (13 on the sides, 24 on the top, clockwise from bottom left when looking at the TV) then download my boblight.conf:
sudo wget http://dl.dropboxusercontent.com/u/6885567/boblight_50xWS2801_speedy.conf -O /etc/boblight.conf

3.1B - If you have 6 LDP8806 LEDs (unlikely) then this is a starting point and will at least let you test your set up.
sudo cp /home/pi/boblight-read-only/conf/LPD8806.conf /etc/boblight.conf

3.1C - If you have a different amount of LEDs or you have ordered your LEDs differently you can hopefully modify either of the scripts above using info provided by the BoblightConfigTool

3.2 - Start the boblight daemon
sudo boblightd -f > /dev/null

3.3 - You should hopefully see "Pibob: setup succeeded" or something similar. Now you can test the boblight daemon by telling it to turn all LEDs green:
sudo boblight-constant 00FF00

3.4 - At this stage, you may find your LEDs don't do anything and you get an error complaining about "libboblight.so", if so, try a reboot
sudo reboot

3.5 - Test again by turning all the LEDs a nice raspberry colour, or grab any other colour you like from ColorPicker.com
You can press CTRL+C to stop boblight-constant and run it again with a different colour.
sudo boblight-constant AB0030

3.6 - If not all of your LEDs are lit up, you may need to make some changes to boblight.conf (step 3.1c)

3.7 - You don't want to have to manually start the daemon every time you start Raspbmc so you can put an entry in rc.local so it starts automatically. Start editing rc.local:
sudo nano /etc/rc.local

Paste this on the line before "exit 0"
/usr/local/bin/boblightd -f

If you also want to set a static colour for your LEDs you can add another line directly below the code above (but above "exit 0")
sudo /usr/local/bin/boblight-constant AB0030 -p 254

Part 4 - Configure XBMC

So your LEDs are working, you can now send basic colours to boblight daemon via boblight-constant and you set Raspbmc to do both automcatically on boot. You now need to get XBMC to send colour information to each LED when a video plays. This currently requires a custom build of XBMC with a modified OMXplayer. crckmc and nyar have kindly done the hardwork and provided such a build.

4.1 - Download the XBMC build
cd ~
wget https://www.dropbox.com/s/mf3p4ubuujlr8qg/xbmc-rbp-pibob-20130429.tar.gz

4.2 - Stop the current build of XBMC and unzip the new build. This step can take a while.
sudo initctl stop xbmc
sudo tar -xzf xbmc-rbp*.tar.gz -C /opt

4.3 - The custom XBMC is now installed and will be looking for a config file which tells XBMC where and how to communicate with boblightd which in turn communicates with the LEDs. Create the config file:
sudo nano /home/pi/boboptions.txt

Paste this into the new file and save
enabled=true
host=localhost
port=19333
priority=128
sizedown=112
margin=5
timeout=35
interpolation=0
speed=100
autospeed=0
saturation=1.0
threshold=15

4.4 - And we're done! All that's left to do now is reboot. Provded you followed all the steps above, your Pi will boot up, your LEDs will come on with a static colour and when you play a video you should see the LEDs change colour in sync with the video. When you stop the video, your static colour should return.
So, reboot and give it a try:
sudo reboot
Finally, don't forget to disbale automatic updates within the Raspbmc settings. If you do, you may lose boblight functionality next time Raspbmc updates (if you're running the June 2013 Raspbmc build or newer, then you can obviously leave this option enabled).

If you've found this guide helpful, why not donate 50p/50c or whatever you can, thanks.