在树莓派3上使用红外遥控器控制libreELEC

使用红外接收头在树莓派上遥控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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章