distraction in action
In a recent post I discussed the URC-300 universal remote, one of my favorite new toys. I yakked a bit about discrete codes and left off with a tantalizing tease about using discrete codes from the Remote Central database with LIRC. Just to refresh your memory, this would be nifty because it would allow me to learn the discrete codes into the URC-300 (or any other learning remote), which otherwise wouldn’t be able to use them.
I’m not going to cover setting up LIRC or choosing an IR transceiver, since those topics are covered in detail on the LIRC website. Let’s just say that there are many options available to you at pretty cheap prices, and if you’ve got any skill at all with a soldering iron you can build an IR transceiver for pocket change.
Discrete codes are almost always distributed in Philips Pronto format. It’s sort of the lingua franca of remote controls. What we really want is a nice little utility that reads a pronto code and spits out a LIRC config file. There’s lots of info out there on the pronto format and IR codes in general, but, sadly, no such utility exists, so we have to do things the hard way.
First, an overview of our strategy. When you push a button on a remote control it transmits a number to the device it controls. There are a variety of techniques manufacturers use for encoding numbers as IR pulses, but in the end it’s all about getting one number (or “code”) to that device. As you’ll see, it’s not too hard to get that code out of a pronto code, but it can be tricky to translate the encoding information to LIRC. What we’re going to do is let LIRC worry about all the encoding details by either using a pre-existing config file for the device or learning one from its remote. Once we have that config it’s trivial to insert the new discrete codes.
To start with, we need a LIRC config file for the device in question. I’m going to use the Roku Soundbridge as an example device here. If you’re lucky there’s a ready-made config file on the LIRC website for your device. If you’re really lucky it already has the discrete codes and you’re finished! For the Soundbridge I’m not so lucky1. Thankfully we have the original remote, so we can use LIRC to build a config file. We fire up
begin remote name soundbridge bits 16 [snip] pre_data_bits 16 pre_data 0xF609 [snip] begin codes power 0x6897 menu 0xE817 [snip] end codes end remote
There’s no need to understand everything in the file, so I’ve snipped out everything but the interesting parts. What do we see here? It looks like the Soundbridge remote sends 32-bit codes (a 16-bit header and a 16-bit code). The code for toggling power is 0xF6096897 and the code for the menu button is 0xF609E817. All the codes start with the same prefix (0xF609) so it’s only written once.
Now all we need is are the discrete power codes (we’ll call them power_on and power_off). These are normally provided in one of two ways — as pronto codes or .ccf files. We can use either one, but for now let’s assume you have a .ccf file. In fact, Roku Labs provides a .ccf file for the Soundbridge on their website. We’re going to use Tonto, the open-source ccf editor, to examine the contents of the .ccf file. I’m not going to talk about installing Tonto, just suffice to say that it’s much the same as setting up any other Java program.
So now we do the following steps (here’s a screenshot you can follow if you get lost):
Bingo! In the expert details view there’s a HexValue field that reads f609c23d. Remember how our other codes started with F609? So all we need to do is add a line to the codes section of the LIRC config file:
begin codes power 0x6897 menu 0xE817 power_on 0xC23D end codes end remote
Save this file in the appropriate place, point your IR transmitter at the Soundbridge (or whatever your device is), restart lircd, and try
One last detail. If you don’t have a full ccf file and just have the pronto code (a very long string of hex digits) for a command, you can still extract the code. In the first (non-expert) IR Signal dialog we saw in Tonto, the text field contains the pronto code for the button. If you paste in a different pronto code and then click “expert” you’ll see the hex code for that code. So just use any old ccf file you can find, any device, any button, and paste in the code you need. This is how I got the discrete power codes for my JVC TV.
 If you have a Soundbridge your luck should be much better now. I’ve sent in the Soundbridge config file to the LIRC developers so it should be in their database soon.