使用红外接收头在树莓派上遥控libreELEC
1.修改config.txt文件:
默认只读模式,重新挂载为读写模式
文档地址:https://wiki.libreelec.tv/config.txt
mount -o remount,rw /flash
nano /flash/config.txt
mount -o remount,ro /flash
2.添加gpio-ir
Add the following line to /flash/config.txt (read Raspberry Pi Config.txt for detailed instructions):
dtoverlay=gpio-ir
Add the gpio_pin parameter if you used a custom GPIO (default is 18). eg:
dtoverlay=gpio-ir,gpio_pin=5
3.测试按键输出代码,建立keymaps
ir-keytable -t
Testing events. Please, press CTRL-C to abort.
293.356686: lirc protocol(nec): scancode = 0x46
293.406665: lirc protocol(nec): scancode = 0x46 repeat
293.636664: lirc protocol(nec): scancode = 0x46
293.690013: lirc protocol(nec): scancode = 0x46 repeat
294.560006: lirc protocol(nec): scancode = 0x15
294.613348: lirc protocol(nec): scancode = 0x15 repeat
294.879998: lirc protocol(nec): scancode = 0x15
295.180040: lirc protocol(nec): scancode = 0x15
295.436699: lirc protocol(nec): scancode = 0x15
295.786679: lirc protocol(nec): scancode = 0x15
295.836676: lirc protocol(nec): scancode = 0x15 repeat
296.059997: lirc protocol(nec): scancode = 0x15
296.556677: lirc protocol(nec): scancode = 0x44
297.140018: lirc protocol(nec): scancode = 0x44
根据编码在/storage/.config/rc_keymaps/下创建my_custom_remote
我的定义:注意nec是上面的协议,可再用ir-keytable -t -p nec进行测试
# table my_custom_remote, type: nec
0x46 KEY_UP
0x15 KEY_DOWN
0x44 KEY_LEFT
0x43 KEY_RIGHT
0x40 KEY_OK
0x7 KEY_BACK
0x9 KEY_MENU
4.停止服务:
systemctl stop kodi
systemctl stop eventlircd
5.载入新的keymaps:
ir-keytable -c -w /storage/.config/rc_keymaps/my_custom_remote
再进行测试
ir-keytable -t
如果能看到上面的按键显示输出,表明测试成功
6. 开启服务,进行测试
systemctl start kodi
systemctl start eventlircd
7.添加:/storage/.config/rc_maps.cfg文件
文档说明:When you’re finished with all buttons, save the keytable, stop ir-keytable -t with CTRL+C and then test if it works. If testing succeeds, make it permanent via a /storage/.config/rc_maps.cfg file like this:
* * my_custom_remote
总结:在4.19内核版本和前面4.14内核版本中lirc配置有所不同。
本文主要参考官方文档:
文档地址:Infrared Remotes
8.在树莓派Raspbian系统中使用方法:
注意:在4.19版本内核下,不要安装lirc软件,只安装ir-keytable.
That’s about the same setup as we use in LibreELEC, only difference is that we use eventlircd instead of inputlirc (and, before you ask: no, eventlircd isn’t in debian and you also are better off with inputlirc)
You can stick to the guide in the LibreELEC wiki https://wiki.libreelec.tv/infrared_remotes - just keep in mind that the paths are a bit different than in Debian/Raspbian (/storage/.config instead of /etc, /flash instead of /boot)
参考:网址
不知道怎么默认启动通过/etc/rc_maps.cfg方式,直接把下面加入到rc.local中
sudo ir-keytable -c -w /etc/rc_keymaps/my_custom_remote.toml
my_custom_remote.toml:
[[protocols]]
name = "my_custom_remote"
protocol = "nec"
variant = "nec"
[protocols.scancodes]
#0x25 = "KEY_POWER"
#0x0a = "KEY_MUTE"
#0x01 = "KEY_1"
#0x02 = "KEY_2"
#0x03 = "KEY_3"
#0x04 = "KEY_4"
#0x05 = "KEY_5"
#0x06 = "KEY_6"
#0x07 = "KEY_7"
#0x08 = "KEY_8"
#0x09 = "KEY_9"
#0x00 = "KEY_0"
0x46 = "KEY_UP"
0x15 = "KEY_DOWN"
#0x12 = "KEY_VOLUMEUP"
#0x13 = "KEY_VOLUMEDOWN"
#0x1f = "KEY_RECORD"
#0x17 = "KEY_PLAY"
#0x16 = "KEY_PAUSE"
#0x0b = "KEY_STOP"
#0x27 = "KEY_FASTFORWARD"
#0x26 = "KEY_REWIND"
0x40 = "KEY_OK"
0x44 = "KEY_LEFT"
0x43 = "KEY_RIGHT"
0x07 = "KEY_BACK"
0x09 = "KEY_MENU"
#0x2b = "KEY_EPG"
#0x1e = "KEY_RED"