LIRC on a Raspberry Pi for a silver Apple TV remote
The idea here is to control a full-screen chromium webpage via a simple remote control (I'm using it for full-screen TV-like prototypes). It's very straightforward really, but
- I couldn't find the right kind of summary of LIRC, the linux infrared remote tool
- It look me a while to realise that the receiver end of IR was so easy if you have a GPIO (as on a Raspberry Pi) rather than using USB
- Chromium 51 is now the default on Raspberry Pi's Jessie, making it easy to do quite sophisticated web interfaces on the Pi3
The key part is the mapping between what LIRC (or its daemon version) does when it hears a keypress and what you want it to do. Basically there's
- an lircd.conf file that maps the IR data to the names of keys on the remote
- an .lircrc file that maps the key press on the remote it receives to a command (e.g. a bash script like this one)
- I've used xdotool to send keyboard commands to the web page I'm interested in
- I've provided some examples of using keyboard keycodes in the webpage
It's all a bit confusing as we're using remote key presses mapped to the nearest keyboard commands in HTML in Javascript. But it works perfectly.
I've provided an example lircd.conf for silver Apple TV remotes, but you can generate your own for any IR remote easily enough.
The way I've used xdotool assumes there's a single webpage open in chromium with a specific title - "lirc-example".
Full instructions are in github.
Links
lirc
- Testing if remote works: https://discourse.osmc.tv/t/how-to-check-if-the-ir-remote-control-works-gpio/6423/3
- Lirc help: https://github.com/OpenELEC/OpenELEC.tv/issues/3908
- Best lirc config how to that I found: https://learn.adafruit.com/using-an-ir-remote-with-a-raspberry-pi-media-center/configure-and-test
- More tips: https://wiki.ubuntu.com/LircHowto
- keycodes list
xdotool
irexec
- http://stackoverflow.com/questions/22423114/cant-get-irexec-to-work-on-rpi
- irexec tips for rc.local https://volumio.org/forum/how-installed-lirc-with-receiver-and-remote-volumio-t360.html
- debugging rc.local https://www.raspberrypi.org/forums/viewtopic.php?f=31&t=49158