XBMC Live / Linux with amBX lighting

I have recently been experimenting with XBMC and a Philips amBX Starter Kit, this is a little howto for when i inevitably hose my installation and have to reinstall, i hope it helps others as well. The video on the right doesn’t do justice to the effect in real life.This howto would not be possible without the guys from the XBMC forums.

If you can’t get the files from their official sources you can get light and ruby USB here:

Changelog

2010-05-22 – Initial draft published
2010-06-07 – Updated step 4 and 10 to use combustd 0.2 rather than 0.1 and removed step 11 as depreciated.
2010-06-07 – Removed libc6-dev-i386 as it breaks installation but doesn’t seem to be needed.

Ok so lets start

Getting started

  1. First open a terminal, either Ctrl + Alt + F1 in xbmc or ssh into the machine
  2. Create a working directory and move into itmkdir ambx cd ambx
  3. (If not installed) install Subversionsudo apt-get install subversion
  4. get combustd from svnsvn checkout http://combustd.googlecode.com/svn/branches/combustd-ruby-0.2
  5. Download Boblight and extract it to something you want, there is an svn version on googlecode, but i couldnt get it to makewget http://www.xs4all.nl/~loosen/boblight/boblight-1.3.tar.gz tar zxvf boblight-1.3.tar.gz
  6. Get dependencies to compile Boblight, if you have any issues try one package at a time to find the problem, also some of these packages were already installed, can’t remember which ones though.sudo apt-get update sudo apt-get install gcc libusb-dev ruby ruby-dev libportaudio-dev libavdevice-dev libswscale-dev libavformat-dev libavcodec-dev libxrender-dev libsdl1.2-dev libx11-dev
  7. Build the package ‘Boblight’:cd boblight-1.3 sudo ./configure sudo make sudo make install cd ..
  8. Configure Boblight
    Open a text-editor, i use nano, but its up to you and edit the file ‘boblight.conf (It probably wont already exist, thats fine).sudo nano /etc/boblight.confAdd the following code into the file, this is courtesy of jaaps and allows use of all 5 lights, Z3rO also added some lines to allow adding things like proportional, satuation, black threshold in the config rather than on the commandline.[global] interface 127.0.0.1 port 19333

[device]

name AmbX_Combust output “ruby /usr/local/combustd/applications/boblight/boblight.rb” channels 15 type popen interval 20000

[color]

name red rgb FF0000

[color]

name green rgb 00FF00

[color]

name blue rgb 0000FF

[light]

name left color red AmbX_Combust 1 color green AmbX_Combust 2 color blue AmbX_Combust 3 hscan 0 33.33 vscan 0 66.66 saturation 3.0 proportional 20.0 value 3 threshold 20 interpolation on

[light]

name right color red AmbX_Combust 4 color green AmbX_Combust 5 color blue AmbX_Combust 6 hscan 66.66 100 vscan 0 66.66 saturation 3.0 proportional 20.0 value 3 threshold 20 interpolation on

[light]

name wwleft color red AmbX_Combust 7 color green AmbX_Combust 8 color blue AmbX_Combust 9 hscan 0 40 vscan 0 33.33 saturation 3.0 proportional 20.0 value 3 threshold 20 interpolation on

[light]

name wwright color red AmbX_Combust 10 color green AmbX_Combust 11 color blue AmbX_Combust 12 hscan 60 100 vscan 0 33.33 saturation 3.0 proportional 20.0 value 3 threshold 20 interpolation on

[light]

name wwcenter color red AmbX_Combust 13 color green AmbX_Combust 14 color blue AmbX_Combust 15 hscan 33 66 vscan 0 33.33 saturation 3.0 proportional 20.0 value 3 threshold 20 interpolation on

Save the file and exit. (Ctrl + O then Ctrl + X)

If you are hiding the left and right lights behind the TV, use value 15 on the appropriate lines of the config as above, if you aren’t then use value 3, value sets how bright the lights are.

Boblight is now configured.Download, Install and compile Ruby-usb

wget http://www.a-k-r.org/ruby-usb/ruby-usb-0.2.tar.gz
tar -zxvf ruby-usb-0.2.tar.gz
cd ruby-usb-0.2
sudo ruby extconf.rb
sudo make && sudo make install
cd ..

CombustD

sudo mv combustd-ruby-0.2 /usr/local/combustd

Running boblight

That should be everything configured, now start the daemon.

sudo boblightd

Test if its working

boblight-constant ff00ff; sleep 5; killall boblight-constant

All the lights should come on for 5 seconds (they will be a pinky color) then go off.

Time to start the magic

boblight-X11 -s 5 -t 0.1 -a 20 -v 3
boblight-X11 -t 0.1

This starts the binary, sets the saturation to 5, the interval between refreshes to 0.1 seconds, brightness to 3 and the speed to 20 and sets the interval between refreshes to 0.1 seconds (the other options aren’t needed as they are now set in the config). If you get an error about ERROR: Can’t open display (null) the DISPLAY environment variable isn’t set, just type:

export DISPLAY=:0.0

You will need to redo this when you reboot.

Boblight Configuration Options

You can change the way boblight works by supplying options, the list of options is:

boblight-X11 1.3

Usage: boblight-x11 [OPTION]
Start the X11 grabber for boblight

  -s	set the saturation
  -v	set the value
  -i	set the interpolation, use "-i on" or "-i off"
  -a	set the proportional
  -p	set the priority, default is 128
  -t	set the timer interval, default is 0.5 second,
  -u	set the lights to use, comma separated list
  -e	set the server address[:port]
  -g	grab n pixels on n lines
    	default is 100 for XShmGetImage and 16 for XGetImage
  -m	grab method, use "-m average" or "-m median"
  -x	use XGetImage instead of XShmGetImage (slow!)
  -b	set the black threshold

Todo.

Look into starting boblight on startup
Look into creating a boblight script for xbmc allowing users to change settings and start/stop through GUI
Add some pictures and a youtube video

Automatically starting amBX

By utilising udev we can set amBX to turn on when we press the power button on the amBX system, if you never turn the system off by the power button on the amBX unit, then the lights will automatically come on when xbmc boots.

Create a new udev rule:

sudo nano /etc/udev/rules.d/99-ambx.rules

Copy the code below into it and save:

SUBSYSTEM=="usb", ATTRS{idVendor}=="0471", ATTRS{idProduct}=="083f", ACTION=="add", RUN+="/usr/bin/startambx"

Create the startambx script:

sudo nano /usr/bin/startambx

Copy the code below into it and save:

#!/bin/sh
boblightd
sudo su - xbmc -c "DISPLAY=:0.0 boblight-X11 -t 0.1"

If you are using a username other than xbmc replace the instance above with the appropriate username.

Leave a Reply

Your email address will not be published. Required fields are marked *

*