在樹莓派3上使用紅外遙控器控制libreELEC和Raspbian系統

使用紅外接收頭在樹莓派上遙控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.

  • use dtoverlay=gpio-ir to activate the kernel drvier (make sure you DON’T use lirc_rpi)
  • apt-get install v4l-utils ir-keytable to get ir-keytable
  • if necessary change the IR remote settings (protocol, scancodes) via /etc/rc_maps.cfg and/or custom keymaps in /etc/rc_keymaps
  • apt-get install inputlirc and configure it to translate the linux input events from the IR driver into lirc events - this is what kodi currently supports best

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