-
Notifications
You must be signed in to change notification settings - Fork 5
Map a new remote for use with the radio software
Basic setup
First test with a remote
Mapping Keys to create lircd.conf
Test the mapping
Create actions
Verify input events
The following procedure assumes that you are root ;-)
The orange pi already does come with a infrared receiver. There is no need for additional Hardware on the receiver side. As a remote you can use most infrared remotes. They should have at least 6 buttons. Also old ones from a broken device would mostly work.
The Armbian image does already have all necessary software. To verify wether everything is working as needed you can do the following:
- Verify if kernel modul is loades
lsmod | grep sunxi_cir
- Verify if lirc daemon is running
systemctl status lirc
First we want to make sure that the lirc device is receiving data. Therefore we first stop the lircd.
systemctl stop lirc
Then use the following command to show what raw data lirc is receiving
mode2 -d /dev/lirc0
Now press some buttons on the remote and you should see something like this
pulse 504
space 1744
pulse 520
space 616
pulse 520
space 592
pulse 528
space 600
The purpose of this step is to map the raw data which is received to events which have names starting with KEY_ . We will use the tool irrecord to do that. To get a list of the available namespace enter
irrecord --list-namespace
For the radio software we only need to map the following keys
KEY_UP
KEY_DOWN
KEY_LEFT
KEY_RIGHT
KEY_ENTER
KEY_MENU
KEY_PLAYPAUSE
To start the recording and mapping process do the following:
cd /install
irrecord -d /dev/lirc0 lircd.conf
Please read the instructions and perform the needed steps. When all keys are mapped successfully we now have a file with the name lircd.conf in /install. Please open the file with an editor and change the name line to something usefull for instance
name appleremote
Now its time to test it. Therefor we need to copy the config file to /etc/lirc
cp /install/lircd.conf /etc/lirc/lircd.conf
To begin testing we have to start lirc
systemctl start lirc
now lets get a list of the keys we mapped in the last step to make sure nothing went wrong.
irsend LIST appleremote ""
The output should look look this:
irsend: 0000000000000001 KEY_UP
irsend: 0000000000000002 KEY_DOWN
irsend: 0000000000000003 KEY_LEFT
irsend: 0000000000000004 KEY_RIGHT
irsend: 0000000000000005 KEY_ENTER
irsend: 0000000000000006 KEY_MENU
irsend: 0000000000000007 KEY_PLAYPAUSE
If that is OK lets check what we receive
irw
If you press the buttons you have mapped you should get the following:
0000000000000001 00 KEY_UP appleremote
0000000000000002 00 KEY_DOWN appleremote
0000000000000003 00 KEY_LEFT appleremote
0000000000000004 00 KEY_RIGHT appleremote
0000000000000005 00 KEY_ENTER appleremote
0000000000000006 00 KEY_MENU appleremote
0000000000000007 00 KEY_PLAYPAUSE appleremote
In this step we will map the buttons to actions. To keep thing easy we will name the actions exactly like the in the last step. We will have to create a file called /etc/lirc/lircrc The script boes have a block like the following for every button:
begin
button = KEY_UP
prog = appleremote
config = KEY_UP
end
button - is the name of the remote button we have mapped before prog - target for the information config - string which is transferred The file for our remote should look like this at the end:
# KEY_UP
# KEY_DOWN
# KEY_LEFT
# KEY_RIGHT
# KEY_OK
# KEY_MENU
# KEY_PLAYPAUSE
begin
button = KEY_UP
prog = appleremote
config = KEY_UP
end
begin
button = KEY_DOWN
prog = appleremote
config = KEY_DOWN
end
begin
button = KEY_LEFT
prog = appleremote
config = KEY_LEFT
end
begin
button = KEY_RIGHT
prog = appleremote
config = KEY_RIGHT
end
begin
button = KEY_OK
prog = appleremote
config = KEY_OK
end
begin
button = KEY_MENU
prog = appleremote
config = KEY_MENU
end
begin
button = KEY_PLAYPAUSE
prog = appleremote
config = KEY_PLAYPAUSE
end
There is one thing we still have to do. Since we will not communicate directly with lirc in the radio software (I found it to be not reliable). We have to enable a feature of lirc which will enable the uinput feature of lirc. This will create an additional input device (like a keyboard). To enable this please open the file /etc/lirc/hardware.conf . There is a line starting with LIRCD_ARGS. Change it to:
LIRCD_ARGS="--uinput"
Now restart lirc again
systemctl restart lirc
To test input events we can use the tool evtest. When you start it you should get the following:
evtest
No device specified, trying to scan all of /dev/input/event*
Available devices:
/dev/input/event0: vmouse
/dev/input/event1: sunxi-gpiokey
/dev/input/event2: sunxi-ths
/dev/input/event3: sunxi-ir
/dev/input/event4: MCE IR Keyboard/Mouse (sunxi-ir)
/dev/input/event5: lircd
Select the device event number [0-5]:
The last line is our device (/dev/input/event5) created by lirc. Select this and press some buttons we have mapped before. You should get something like this:
Event code 234 (KEY_SAVE)
Event code 235 (KEY_DOCUMENTS)
Event code 236 (KEY_BATTERY)
Event code 237 (KEY_BLUETOOTH)
Event code 238 (KEY_WLAN)
Event code 239 (KEY_UWB)
Event code 240 (KEY_UNKNOWN)
Key repeat handling:
Repeat type 20 (EV_REP)
Repeat code 0 (REP_DELAY)
Value 250
Repeat code 1 (REP_PERIOD)
Value 33
Properties:
Testing ... (interrupt to exit)
Event: time 1479769455.203104, type 1 (EV_KEY), code 103 (KEY_UP), value 1
Event: time 1479769455.203116, -------------- EV_SYN ------------
Event: time 1479769455.449339, type 1 (EV_KEY), code 103 (KEY_UP), value 2
Event: time 1479769455.449349, -------------- EV_SYN ------------
Event: time 1479769455.489325, type 1 (EV_KEY), code 103 (KEY_UP), value 2
Event: time 1479769455.489334, -------------- EV_SYN ------------
Event: time 1479769455.491905, type 1 (EV_KEY), code 103 (KEY_UP), value 0
Event: time 1479769455.491920, -------------- EV_SYN ------------
Event: time 1479769456.618365, type 1 (EV_KEY), code 108 (KEY_DOWN), value 1
Event: time 1479769456.618379, -------------- EV_SYN ------------
Event: time 1479769456.859355, type 1 (EV_KEY), code 108 (KEY_DOWN), value 2
Event: time 1479769456.859364, -------------- EV_SYN ------------
Event: time 1479769456.899360, type 1 (EV_KEY), code 108 (KEY_DOWN), value 2
Event: time 1479769456.899368, -------------- EV_SYN ------------
Event: time 1479769456.907095, type 1 (EV_KEY), code 108 (KEY_DOWN), value 0
Event: time 1479769456.907110, -------------- EV_SYN ------------
Event: time 1479769457.503465, type 1 (EV_KEY), code 105 (KEY_LEFT), value 1
Event: time 1479769457.503478, -------------- EV_SYN ------------
If this is Ok you are done !!