Instalar LIRC
Ubuntu 20.04 - 20.10
https://www.lirc.org/
LIRC para LINUX é um pacote que permite receber e enviar sinais de IR(Infra Red, Infra Vermelhos) normalmente usados nos comandos remotos. Pode-se, assim, desenvolver programas que controlam os dispositivos(TV, AC, HI-FI etc), memorizar os códigos existentes e usar esses códigos a partir do sistema. Existem várias listas algumas disponibilizadas pelos fabricantes que permitem ter, de imediato, o LIRC a funcionar para o dispotivo que precisamos (http://lirc-remotes.sourceforge.net/remotes-table.html).
$ sudo apt update
$ sudo apt upgrade
$ sudo apt install lirc
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libftdi1-2 liblirc-client0 liblirc0 libportaudio2 libusb-0.1-4
Suggested packages:
lirc-compat-remotes lirc-drv-irman lirc-doc lirc-x setserial ir-keytable
Recommended packages:
gir1.2-vte
The following NEW packages will be installed:
libftdi1-2 liblirc-client0 liblirc0 libportaudio2 libusb-0.1-4 lirc
0 upgraded, 6 newly installed, 0 to remove and 0 not upgraded.
Need to get 660 kB of archives.
After this operation, 3010 kB of additional disk space will be used.
Do you want to continue? [Y/n]
Editar /etc/lirc/lirc_options.conf alterando estas duas linhas:
...
driver = default
device = /dev/lirc0
...
Editar /boot/config.txt ou /boot/firmware/config.txt
dtoverlay=gpio-ir,gpio_pin=23
dtoverlay=gpio-ir-tx, gpio_pin=22
[pi4]
max_framebuffers=2
[all]
arm_64bit=1
kernel=vmlinuz
cmdline=cmdline.txt
initramfs initrd.img followkernel
# Enable the audio output, I2C and SPI interfaces on the GPIO header
dtparam=audio=on
dtparam=i2c_arm=on
dtparam=spi=on
# Enable the serial pins
enable_uart=1
# Comment out the following line if the edges of the desktop appear outside
# the edges of your display
disable_overscan=1
# If you have issues with audio, you may try uncommenting the following line
# which forces the HDMI output into HDMI mode instead of DVI (which doesn't
# support audio output)
#hdmi_drive=2
# If you have a CM4, uncomment the following line to enable the USB2 outputs
# on the IO board (assuming your CM4 is plugged into such a board)
#dtoverlay=dwc2,dr_mode=host
# configuração adicionada para o LIRC
dtoverlay=gpio-ir,gpio_pin=23
dtoverlay=gpio-ir-tx, gpio_pin=22
Parar, Iniciar e Verificar estado do serviço e reiniciar
sudo systemctl stop lircd.service
sudo systemctl start lircd.service
sudo systemctl status lircd.service
sudo reboot
Testar controlo remoto
Se existir um recetor de IR no pino definido em config.txt, podemos testar
Paramos o serviço e atuamos com mode2
sudo systemctl stop lircd.service
sudo mode2 -d /dev/lirc0
ou
sudo mode2 -d /dev/lirc1
Como saber se está a funcionar?
Apontando o remoto para o LED IR recetor aparecem os comaando enviados, por exemplo,
space
pulse
Instalar IR key-table
Instalar
sudo apt install ir-keytable
Verificar remotos pré instalados
ls /lib/udev/rc_keymaps/
sudo ir-keytable
sudo ir-keytable
Found /sys/class/rc/rc1/ with:
Name: gpio_ir_recv
Driver: gpio_ir_recv
Default keymap: rc-rc6-mce
Input device: /dev/input/event3
LIRC device: /dev/lirc1
Attached BPF protocols: Operation not supported
Supported kernel protocols: lirc rc-5 rc-5-sz jvc sony nec sanyo mce_kbd rc-6 sharp xmp imon
Enabled kernel protocols: lirc
bus: 25, vendor/product: 0001:0001, version: 0x0100
Repeat delay = 500 ms, repeat period = 125 ms
sudo ir-keytable -v -t -p rc-5,rc-5-sz,jvc,sony,nec,sanyo,mce_kbd,rc-6,sharp,xmp
Gravar comando remoto
The output of the command below is shown in the screenshot
irrecord --list-namespace
irrecord -d /dev/lirc0 my.conf
https://github.com/mtraver/rpi-ir-remote
Verificar portas gpio
sudo dtc -I fs /sys/firmware/devicetree/base -O dts -o loaded\_device\_tree.dts
https://github.com/layman-n-ish/ProjectorController9000
https://github.com/josemotta/IoT.Starter.Pi.Lirc/blob/master/RPI_Setup.md
https://github.com/AnaviTechnology/anavi-docs/blob/master/anavi-infrared-phat/anavi-infrared-phat.md#using-ir-led
https://devkimchi.com/2020/08/12/turning-raspberry-pi-into-remote-controller/
apt install v4l-utils
ir-ctl - -send=KEY\_POWER.txt
Verificar estado dos pinos
sudo cat /sys/kernel/debug/pinctrl/3f200000.gpio-pinctrl-bcm2835/pinmux-pins