Linux Format

The light fantastic

Add a touch of pizazz to your media centre with a border of colourful Ambilight-like, picture-reactive LEDs.

-

You might have seen the Ambilight system found on some Philips TVs, sometimes known as Bias Lighting. If not, the idea is quite simple: a perimeter of RGB LEDs is fixed to the back of the television, and these are light up in correspond­ence with what’s happening on screen. This has the effect of extending the image onto the walls behind the screen.

There are a number of approaches to recreating this system with open source tools and plugging this into Kodi. The most popular is called Hyperion, which has been around for about as long as Ambilight TVs. Hyperion is flexible, and a common setup is to have Kodi

running on a device, your PC say, and connected to an HDMI splitter and capture device. The HDMI capture is then sent (over USB) to Pi running Hyperion, which drives the LEDs.

That setup is a little complicate­d for our liking, so we thought we’d try and come up with our own, ideally with fewer moving parts. Annoyingly, there’s no way to run everything on a Pi 4, since no one has figured out how to reliably capture the frame buffer (see https://github.com/hyperion-project/hyperion.ng/ issues/983). So if we were to use the latest Kodi we’d need to invest in some capture hardware, either in the form of a loop capture (if we were to do everything on the Pi) or separate splitter and capture devices (if the Pi is just running the LEDs). Both can be achieved for less than £20 with a little Amazon scouring. The advantage of using a capture device is that you can use it for whatever HDMI input you happen to be watching, so your Pi can ambient-light your Smart TV’s interface, your desktop background or the frantic explosions from your CS:GO exploits.

Instead we’ll go back in time briefly and use Kodi 18 on a Pi 2 or 3. If there are no Kodi 19 builds for these devices by the time you read this, then you will surely be tempted to do this anyway, LEDs or no. You’ll find the previous LibreELEC release (9.2.8, which includes Kodi 18.9 at the time of writing) on the downloads page, or you could take a standard Raspberry Pi OS install and augment it with Kodi. It’s in the official repos so that would be just a matter of sudo apt install kodi .

Capture the moment

We won’t cover LibreELEC 9’s setup: that and the navigation are much the same as in the new version. The Hyperion-NG (successor to the original Hyperion) software doesn’t currently use Kodi’s plugin system. So to install it we’ll need to set up SSH access and fetch it ourselves. And this is where you realise that “Just Enough OS” is entirely accurate. Usually on the Pi we’re used to installing things from the repos with Apt, or at a pinch installing packages manually with Dpkg, but neither of those tools are present on LibreELEC. Fortunatel­y the Hyperion developers have created a handy script to get everything installed and set up. Before you use it though, check the relevant thread on the Hyperion forum at https://bit.ly/lxf284-hyperionin­stall in case anything has changed.

We found the script had a typo which caused it to fetch the ARMv6 build of the software. If this bothers you (it bothered us) follow these instructio­ns instead.

SSH into the Pi, download the script and edit with:

# wget https://git.io/Jz5Qp -O hyperion.sh

# nano hyperion.sh

Now scroll down to the lines beginning:

RPI_1=…

RPI_2_3_4=…

Remove the \|BCM2835 from the RPI_1 line, and add it to the line beginning RPI_2, so that it now begins:

RPI_2_3_4=`grep -m1 -c ‘BCM2709\|BCM2710\|BCM283 5\|BCM2836...

Most Pi 3 and 4s it turns out report the BCM2835 SoC, so this was not a reliable detection scheme. Nevermind, we’ve fixed it now, so we can go ahead and run the script with:

# bash hyperion.sh

The script will automatica­lly modify config.txt to enable the SPI bus and allow communicat­ion with your LEDs, but this will require a restart first. Once you do that Hyperion will be running in the background, ready to light things up. So let’s arrange some lights, but first check the box (below) for some words of illuminati­on.

As you may have gathered, some wires are going to be involved in this setup, but no soldering is needed and it all fits nicely on a breadboard. Since we have two power sources (the Pi and the LED’s power source), we need to establish a common earth. Otherwise we’ll start introducin­g ground loops (where current flows from one “0V” rail to the other, because potential is relative). This is easy, just connect the Pi’s GND to the negative rail on our breadboard. It’s then tempting, of course, to connect the Pi’s 5V line to the breadboard too, but don’t do this. If you were to accidental­ly turn off your LEDs’ power source and then try and use them, they’ll try and draw power from the Pi, which will be fine for a couple of blinkenlig­hts, but won’t work (and may even damage) anything more.

Rather than start arguments about GPIO pin numberings or how much power to provide to one’s Neopixels/Dotstars, we’ll just show you we set ours up. Feel free to tell us we’re doing it wrong. One thing we learned is that while it’s common for the +5V and 0V wires to be to be red and black, and at opposite sides of the connector, the clock and data lines seem to move around between manufactur­ing runs. So the wiring might not agree with any diagrams given by the manufactur­er or vendor. One symptom of clock and data being wired backwards is LEDs not lighting as commanded, but with occasional wild flickering if you gently wiggle the jumper wires.

Hopefully you’re able to get something working. Next, visit the Hyperion web configurat­ion page at http://192.168.x.x:8090, again replacing the IP address with that of your LibreELEC 9/Kodi 18 box. The first step is to tell Hyperion about the nature and number of our LEDs, which is done from LED Instances>LED Output. We set the Controller type to apa102 and set the SPI Device to 0.0 (we used GPIO pins 10 (MOSI) and 11 (SCLK) for the data and clock lines). Now set the Hardware LED count to the number of LEDs you have, save settings and proceed to the LED Layout tab.

Configurin­g the layout is straightfo­rward, and you can test things are working by selecting Remote Control and picking random colours and effects. Activate Screen Capture in the Capturing Hardware section, and your LEDs should fluoresce into life.

 ?? ?? Use the LED Numbers button to tell Hyperion the Input Position (where the LED strip starts).
Use the LED Numbers button to tell Hyperion the Input Position (where the LED strip starts).
 ?? ??
 ?? ??
 ?? ??
 ?? ??
 ?? ??
 ?? ??
 ?? ?? This looked much less tidy in real life. Pro tip though: the negative end of a capacitor usually has a stripe on it.
This looked much less tidy in real life. Pro tip though: the negative end of a capacitor usually has a stripe on it.
 ?? ?? Hyperion’s web interface makes configurin­g tiny blinking lights an absolute charm.
Hyperion’s web interface makes configurin­g tiny blinking lights an absolute charm.

Newspapers in English

Newspapers from Australia