Skip to content

Instantly share code, notes, and snippets.

@hartzell
Last active January 19, 2021 11:42
Show Gist options
  • Save hartzell/2099b36a4fd806a5e936890806211da3 to your computer and use it in GitHub Desktop.
Save hartzell/2099b36a4fd806a5e936890806211da3 to your computer and use it in GitHub Desktop.
Configuring a headless PiCorePlayer to use an Apple 1294 IR remote
begin
remote = Apple_A1156
button = KEY_UP
repeat = 0
prog = squeezelite
config = volup
end
begin
remote = Apple_A1156
button = KEY_DOWN
repeat = 0
prog = squeezelite
config = voldown
end
begin
remote = Apple_A1156
button = KEY_LEFT
repeat = 0
prog = squeezelite
config = rew
end
begin
remote = Apple_A1156
button = KEY_RIGHT
repeat = 0
prog = squeezelite
config = fwd
end
# the A1156 lircd.conf maps ">||" (center button) to KEY_PAUSE
begin
remote = Apple_A1156
button = KEY_PAUSE
repeat = 0
prog = squeezelite
config = pause
end
# The "menu" key does power
begin
remote = Apple_A1156
button = KEY_ESC
repeat = 0
prog = squeezelite
config = power
end
begin
remote = Apple_A1294
button = KEY_UP
repeat = 0
prog = squeezelite
config = volup
end
begin
remote = Apple_A1294
button = KEY_DOWN
repeat = 0
prog = squeezelite
config = voldown
end
begin
remote = Apple_A1294
button = KEY_LEFT
repeat = 0
prog = squeezelite
config = rew
end
begin
remote = Apple_A1294
button = KEY_RIGHT
repeat = 0
prog = squeezelite
config = fwd
end
begin
remote = Apple_A1294
button = KEY_OK
repeat = 0
prog = squeezelite
config = pause
end
# The "menu" key does power
begin
remote = Apple_A1294
button = KEY_ESC
repeat = 0
prog = squeezelite
config = power
end
begin
remote = Apple_A1294
button = KEY_PLAY
repeat = 0
prog = squeezelite
config = play
end

Setup

This describes getting a silver apple remote (A1294) working with a headless piCorePlayer. It requires v5.0.0, which includes fixes for how squeezelite is called so that it finds the ~tc/.lircrc file.

I'm using it with an IQaudio DAC+ with a 3-pin header soldered into the appropriate holes.

LIRC has a git repository, lirc git repo, but unfortunately its web-based git browser isn't working. If you clone the repo, you'll find a configuration document that's interesting reading.

The LIRC project web site includes a database of lircd.conf files for various remotes that includes entries for the silver and white apple remotes. BUT, they're for an older version of LIRC and don't work with the piCorePlayer version. I found functional versions on the net for the A1294 and the [A1156][lirc-1156] (*untested).

Squeezelite uses the lirc_client API to interact with LIRC. It compares events that it receives with a set of cmds from the "squeezeplayer" remote and then from a table populated from a .lircrc file. When piCorePlayer has LIRC installed and you've uploaded a custom lircrc file, squeezeplayer is run with the -i /home/tc/.lircrc option.

Debugging

  1. use sudo mode2 -d /dev/lirc0 to see the raw events coming from LIRC. This is the lowest-ish level and will confirm that you have the kernel bits in place and the hardware wired up correctly.
  2. use irw to dump the higher level events (e.g. KEY_OK), which confirms that you have a lircd.conf file that works for your device.
  3. enable ir debug (or sdebug?) output in the piCorePlayer squeezelite page and watch the log file (e.g. ssh into the pi at tc and tail -f /var/log/pcp_squeezelite.log) to see what squeezelite is doing with the events.
#
# I found this via searching the Intertubes, here:
# https://github.com/osmc/osmc/blob/master/package/remote-osmc/files/etc/lirc/apple-white-A1156-lircd.conf
#
# Please make this file available to others
# by sending it to <lirc@bartelmus.de>
#
# this config file was automatically generated
# using lirc-0.9.0(default) on Tue Jun 2 22:56:05 2015
#
# contributed by DBMandrake
#
# brand: Apple
# model no. of remote control: A1156 (white)
# devices being controlled by this remote:
#
#
# "+" -> 0x50 -> KEY_UP
# "-" -> 0x30 -> KEY_DOWN
# "|<<" -> 0x90 -> KEY_LEFT
# ">>|" -> 0x60 -> KEY_RIGHT
# ">||" (play/pause) -> 0xA0 -> KEY_PAUSE
# "MENU" -> 0xC0 -> KEY_ESC
begin remote
name Apple_A1156
bits 8
flags SPACE_ENC|CONST_LENGTH
eps 30
aeps 100
header 9140 4510
one 633 1666
zero 633 537
ptrail 631
repeat 9137 2220
pre_data_bits 16
pre_data 0x77E1
post_data_bits 8
post_data 0x2C
gap 108756
toggle_bit_mask 0x0
ignore_mask 0x80ff
begin codes
KEY_UP 0x50
KEY_DOWN 0x30
KEY_LEFT 0x90
KEY_RIGHT 0x60
KEY_PAUSE 0xA0
KEY_ESC 0xC0
end codes
end remote
#
# I found this via searching the Intertubes, here:
# https://github.com/osmc/osmc/blob/master/package/remote-osmc/files/etc/lirc/apple-silver-A1294-lircd.conf
#
# See also:
# https://github.com/osmc/osmc/blob/master/package/remote-osmc/files/etc/lirc/apple-white-A1156-lircd.conf
#####
# Please make this file available to others
# by sending it to <lirc@bartelmus.de>
#
# this config file was automatically generated
# using lirc-0.9.0(default) on Tue Jun 2 22:56:05 2015
#
# contributed by DBMandrake
#
# brand: Apple
# model no. of remote control: A1294 (silver)
# devices being controlled by this remote:
#
begin remote
name Apple_A1294
bits 8
flags SPACE_ENC|CONST_LENGTH
eps 30
aeps 100
header 9140 4510
one 633 1666
zero 633 537
ptrail 631
repeat 9137 2220
pre_data_bits 16
pre_data 0x77E1
post_data_bits 8
post_data 0x2C
gap 108756
toggle_bit_mask 0x0
ignore_mask 0x80ff
begin codes
KEY_UP 0x50
KEY_DOWN 0x30
KEY_LEFT 0x90
KEY_RIGHT 0x60
KEY_OK 0x3A 0xA0
KEY_ESC 0xC0
KEY_PLAY 0xFA 0xA0
end codes
end remote
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment