[HOW TO] Build Ambilight on Linux (AppleTV; Sams image; Ubuntu 8.04;...)
How to build ambilight (amblone) on Linux.
This guide is focused on AppleTV with Sam.Nazarko image build on Ubuntu 8.04 LTS, but it will also work for other Linux versions.

I did this with standard configuration and Ubuntu installed on internal disk.
I think it will also work with USB pen drive install and USB hub with small modification of boblight.conf (line: output /dev/ttyUSB0) file.

So lets get started. First you will need some hardware. This guide is using the hardware idea from Amblone project. So for building the hardware just go to http://amblone.com/guide On this site there is also schema for building the circuit board.

In this guide i will be using Arduino Mega1280 (http://arduino.cc/en/Main/ArduinoBoardMega) micro-controller with four channels output but it is the same on Arduino Duemilanove (http://www.arduino.cc/en/Main/ArduinoBoardDuemilanove). The only difference is that Duemilanove uses just two channels (one channel means one led stripe and one led stripe one colour). They are both USB type.

Basically you will need:

- 1x Arduino micro-controller (Arduino Mega1280 (4 channels) or. Arduino Duemilanove (2 channels))
(BUY: http://cgi.ebay.de/ws/eBayISAPI.dll?View...fe=sidebar or. http://cgi.ebay.de/Arduino-Duemilanove-2...3a64a21838 )
- 1x RGB LED stripes without lens. I'd recommend this one (5-m) (BUY: http://www.dealextreme.com/p/rgb-multico...-12v-14963
Or. http://www.dealextreme.com/p/rgb-multico...-12v-14965 )
- 1x A USB A to B cable (at some stores on e-Bay you get one with Arduini board as a gift
- 12x 2N 3904 transistors http://www.dz3w.com/uploadfile/2010/0807...813814.gif (BUY: http://cgi.ebay.com/30-x-2N3904-NPN-Gene...3a65d520b2 )
- 12x 2200ohm resistors (BUY: http://cgi.ebay.com/100-x-Resistors-2-2K...3a55380b13 )
- 1x power supply 12v 1A to fit in Arduino and powering RGB LED stripes (BUY: http://www.dealextreme.com/p/ac-to-dc-12...240v-15991 )
- 1x PCB Board (BUY: http://cgi.ebay.com/Paper-Phenolic-Proto...3360240fc5 )
- PIN Headers (BUY: http://cgi.ebay.com/5-X-40-pin-2-54mm-PC...2562e5eeb5 )
- Some wires (BUY: http://cgi.ebay.com/Arduino-Solderless-B...56412e01ab )

Now you have all parts for start building. Use Amblone guide on how to build the board from resistors and transistors. http://amblone.com/guide
First you have to program the micro-controller with the .pde file.
Download .pde for Arduino board from http://code.google.com/p/boblight/source...no_pwm.pde (copy and paste content to notepad and save as f.e. arduino.pde file) (This .pde is suitable for both Arduino Mega1280 and Arduino Duemilanove)

After that download software from http://arduino.cc/en/Main/Software or. direct link http://arduino.googlecode.com/files/arduino-0022.zip
Connect micro-controller to the PC and install drivers (included in software). Then run the program, select com port, Arduino board type and upload the .pde you have downloaded).
If you are having troubles, you can read on Arduino site the how too guide.

Now if you have uploaded the .pde to the controller, you are ready to install Boblight on ATV (Linux).

How to ride on Linux

First i did enable root account on Sams image. Later you can disable it.
Quote:sudo passwd root
This will prompt for a new root password and once you confirm it, you can start using the root account to login.
If you want to disable root account in Ubuntu you need to lock the root account by using the following command
Quote:sudo passwd -l root

Quote:sudo apt-get install libx11-dev libgl1-mesa-dev libxrender-dev portaudio19-dev libavcodec-dev libavformat-dev libswscale-dev libxext-dev

Download http://packages.ubuntu.com/natty/libavdevice-dev (libav_0.6.2.orig.tar.gz) and upload it with WinSCP into /tmp folder on AppleTV. You can also wget it.

Quote:cd /tmp
wget http://archive.ubuntu.com/ubuntu/pool/ma...rig.tar.gz
tar -zxvf libav_0.6.2.orig.tar.gz
cd libav-0.6.2
make install

cd /tmp
svn checkout http://boblight.googlecode.com/svn/trunk/ boblight-read-only
cd boblight-read-only
./configure --without-ffmpeg
make install

Download .conf file from SVN. Conf file for Mega1280 http://code.google.com/p/boblight/source.../mega.conf and for Duemilanove http://code.google.com/p/boblight/source...anove.conf After that, rename it to boblight.conf and copy it into /etc (/etc/boblight.conf) with WinSCP. You can of course direct download it from Ubuntu if you know how to Smile

Now you can start boblight.

sudo boblightd -f
export DISPLAY=:0.0
boblight-X11 -f -x

You can experiment then a little with settings.
At the moment i have those
Quote:boblight-X11 -f -x -o speed=70 -o value=10 -o saturation=5.5 -o threshold=100

This are options for boblight-X11:
Quote:Usage: boblight-X11 [OPTION]


-p priority, from 0 to 255, default is 128
-s address:[port], set the address and optional port to connect to
-o add libboblight option, syntax: [light:]option=value
-l list libboblight options
-i set the interval in seconds, default is 0.1
prefix the value with v to wait for a number of vertical blanks instead
-u set the number of pixels/rows to use
default is 64 for xrender and 16 for xgetimage
-x use XGetImage instead of XRender
-d debug mode
-f fork
-y set the sync mode, default is on, valid options are "on" and "off"

name type min max default
speed float 0.0 100.0 100.0
autospeed float 0 100.0 0.0
interpolation bool 0 1 0
use bool 0 1 0
saturation float 0.0 20.0 1.0
saturationmin float 0.0 1.0 0.0
saturationmax float 0.0 1.0 1.0
value float 0.0 20.0 1.0
valuemin float 0.0 1.0 0.0
valuemax float 0.0 1.0 1.0
threshold int 0 255 0
hscanstart float 0.0 100.0 -1.0
hscanend float 0.0 100.0 -1.0
vscanstart float 0.0 100.0 -1.0
vscanend float 0.0 100.0 -1.0

Some tips:
- If you run
without switch, it will run in foreground (useful for troubleshooting). With CTRL+c you can cancel foreground deamon)
- First test lights with
Quote: boblight-constant ff
should run blue light. To exit CTRL+c.
- If it says: (root@appletv-ubuntu:/tmp/boblight-read-only# boblight-constant ff ERROR: libboblight.so: cannot open shared object file: No such file or directory root@appletv-ubuntu:/tmp/boblight-read-only#) then (run
Quote:ldconfig[quote] as root)
- [quote]killall boblightd
Stops boblight deamon.
Quote:killall boblight-X11
Stops boblight-X11 deamon.
Quote:boblight-X11 --help
Help info for more config options.
- Read this to auto-start "boblightd" http://forum.xbmc.org/showpost.php?p=800...stcount=10
- Advance Launcher with Ambilight: http://forum.xbmc.org/showpost.php?p=851...stcount=36
- To dim the lights select Screensaver as black.
- It makes no affect on CPU if using one or four channels.
- On my AppleTV the processor is:
- around 37% when on idle (on system info screen)
- 47% when playing 1080p movie (Avatar 8GB file) (Using CrystalHD 70012)
- 40% when playing 720p movie (Law Abinding Citizen 4GB file) (Using CrystalHD 70012)
- 30% on standard divx film (Animal United 1,57 - 2cd file)

TNX to bobo1on1 for making this possible and great IRC support.
Feedback and tips are welcome.

Here you can see some pictures of power circuit that I have build. This is just for better ''imagination''.
You have to be careful that you do insert some sort of isolation between the Arduino and power circuit.

Also when soldering use paste to achieve good contacts between the components and solder. And when you are finished done soldering clean the PCB board (i have used Acetone and brush) to avoid conductibility between electronic parts. Also double check that there is no shortcuts between transistors.
I need this too for my system! So I connect this via USB to my HTPC?

Great Post!

Please don't enable root. If you don't want sudo infront of every command run sudo -s to elevate your privileges temporarily. Can I add this to Ubuntu documentation on my blog please?
Also: 60% CPU usage idle? That is high.. If you want advice for start-up you could add it to /etc/rc.local -- but bare in mind the May 2011 update changed rc.local, and I do reserve the right to update this file again, so it might get overwritten one day
Sam.Nazarko Wrote:Please don't enable root. If you don't want sudo infront of every command run sudo -s to elevate your privileges temporarily. Can I add this to Ubuntu documentation on my blog please?

You can of course add this to your site.
I will make modifications to the tutorial so the root will not be enabled.
About startup i'm having still some troubles and as soon i will succeed i will update the tutorial.
I presume there is a command to fire up the daemon? You can either make an init.d script which allows you to stop, restart or start. Or you can take a much simpler route and append it to rc.local, adding it in just before the xinit statement to launch XBMC
You can start boblightd any time you want, but if you start boblight-X11 you have to be running an X server.
I see. Problem is that X11 is not started till XBMC launches, and that hangs up rc.local, so adding the boblight command after it would not initialise till XBMC closes.

Maybe spawn two concurrent processes, like this:

(xinit /usr/local/bin/xbmc --standalone);(boblight-X11 &)

But that relies on the fact that Boblight does not hang at the command line and wait for someone to end the process -- X for example hangs, but once XBMC closes, it closes letting rc.local finish. If this didn't happen - you'd have to edit the file to get to the tty1 session.

What I've wrote should be okay though -- it should run Boblight in backgorund
I have made two scripts. Copied it into /etc/init.d
Chmod 755

Lights.sh script starts Boblight and boblight-X11

boblightd -f > /dev/null 2>&1
export DISPLAY=:0.0
boblight-X11 -f -x > /dev/null 2>&1

Lights_kill.sh script stops Boblight and boblight-X11

echo atv | sudo -S killall boblightd
killall boblight-X11

To run it just go with terminal:
cd /etc/init.d
sudo ./lights.sh

To stop it just go with terminal:
cd /etc/init.d
sudo ./lights_kill.sh

The problem is that this two scripts are working after the XBMC is up and only through terminal.
Does someone know how this two scripts could be initiated inside XBMC?

Can someone write small how to add bobolightd and x11 to auto start.
Where in rc.local should the command be inserted so that the startup will work.
Well i'm still trying to do auto startup of boblight.

The first part is working. And this is to start the boblight.
Boblight startup:
- Create lights.sh script under /etc/init.d
echo atv | sudo -S boblightd -f > /dev/null 2>&1
- give lights.sh 755 permissions
- create symbolic link
Quote:ln -s /etc/init.d/lights.sh /etc/rc2.d/S10lights.sh

But the second one is making troubles. With this one i'd like to start the DISPLAY=:0.0 and boblight-x11. So i have put the following into rc.local file but it will not start. I have tried without quotes and nothing. The boblight-x11 has to start after X. If i enter manually command
Quote:DISPLAY=:0.0 boblight-X11 -f -x -o speed=65 -o value=5.5 -o saturation=1.7 -o threshold=75 > /dev/null 2>&1
into terminal it works but automatic does not.

Quote:#!/bin/sh -e
# rc.local
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
# In order to enable or disable this script just change the execution
# bits.
# By default this script does nothing.

cd /home/atv/scripts
xinit /usr/local/bin/xbmc --standalone


pidof "$name"

while [ $exitcode -ne 0 ]; do
sleep 1
pidof "$name"

sleep 10
su - atv -c "DISPLAY=:0.0 boblight-X11 -f -x -o speed=65 -o value=5.5 -o saturation=1.7 -o threshold=75 > /dev/null 2>&1"
exit 0

Great, thank you very much for that !
Any chance it will work on the atv2 ?
Does this works on linux if hardware acceleration is enabled on XBMC ?
On ATV2 it will not work, because ATV2 has not USB port to accept usb input.

And it does work with CrystalHD enabled.

We only have to figure out how to autostart the boblight, display and boblight-x.

You can still run a boblightd client on the atv2 and use a machine with usb to drive the leds.
You might have to write the client yourself though.
ok, thanks for the answer.
Many thanks for the atv support anyway

Logout Mark Read Team Forum Stats Members Help
[HOW TO] Build Ambilight on Linux (AppleTV; Sams image; Ubuntu 8.04;...)1
This forum uses Lukasz Tkacz MyBB addons.