在樹莓派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

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