ADVERTISEMENT
If you are using your raspberry pi as a media player (using raspbmc/xbmc), it is often convenient to use the same TV remote control (infra red remote) to handle most of the features rather than using the wifi remote on a smart phone or tablet. It is also more child or girl friend,wife or grandma friendly. Often the raspbmc/xbmc freezes and it is very convenient for the non techie family member to press the magic button on an ir remote to gracefully restart the xbmc rather than pulling the powercord for the raspberry pi.
Even for me, it is inconvenient to ssh in to the raspberry pi and do a
And here is my TV remote where i used some of the buttons for the built in DVD player functions which i do not use and are mapped for XBMC
I used the record button to restart the xbmc, but it is possible to map any tv remote button for the purpose as long as it wont produce any valid result on the TV, while it is used with hdmi input.
If you are starting from scratch with a brand new raspberry pi, you need to install an operating system to use it as a media player. The easiest solution is raspbmc.
To get infrared remote receiver, the cheapest solution is to use the GPIO pins. Installation instructions can be seen here. If you search for HX1838 you can spot a reasonable ir sensor. Take care while hooking it on to the pi, so that you wont damage the board.
Raspbmc has the required softwares built in to it. You just need to configure it (in raspbmc settings menu)and it usually works out of the box with those small remotes like the one shown below
Now let us test the installation and the remote control. Reboot the pi and stop the lirc and fire up a small program which shows the signals from ir remote
If things are fine ,something like pulse and some numbers pops up in the console/ssh window. Next step is to use a program called irrecord to make a config file which contains the fingerprints for each buttons in your remote by recording the infrared pulses from your remote
A sample lircd.conf
end
Even for me, it is inconvenient to ssh in to the raspberry pi and do a
sudo initctl stop xbmc
sudo initctl start xbmc
or more violently,
sudo reboot xbmc
Think of doing this, with out turning on the ssh program and typing it on a smartphone with wifi on :), so i mapped some extra buttons on the TV remote to do all these.And here is my TV remote where i used some of the buttons for the built in DVD player functions which i do not use and are mapped for XBMC
I used the record button to restart the xbmc, but it is possible to map any tv remote button for the purpose as long as it wont produce any valid result on the TV, while it is used with hdmi input.
If you are starting from scratch with a brand new raspberry pi, you need to install an operating system to use it as a media player. The easiest solution is raspbmc.
To get infrared remote receiver, the cheapest solution is to use the GPIO pins. Installation instructions can be seen here. If you search for HX1838 you can spot a reasonable ir sensor. Take care while hooking it on to the pi, so that you wont damage the board.
Raspbmc has the required softwares built in to it. You just need to configure it (in raspbmc settings menu)and it usually works out of the box with those small remotes like the one shown below
If you are happy with having two or more remotes, the process is simple and almost done.
For non raspbmc (starting from scratch ) users
CLICK FOR DETAILS
Now let us test the installation and the remote control. Reboot the pi and stop the lirc and fire up a small program which shows the signals from ir remote
sudo /etc/init.d/lirc stop
mode2 -d /dev/lirc0
If things are fine ,something like pulse and some numbers pops up in the console/ssh window. Next step is to use a program called irrecord to make a config file which contains the fingerprints for each buttons in your remote by recording the infrared pulses from your remote
irrecord -d /dev/lirc0 ~/lircd.conf
sudo cp lircd.conf /etc/lirc/lircd.conf
Next step is to run a script using irexec to reboot/restart the xbmc with a specific keypress. Often mapping the keys to correct xbmc function is needed and is achieved with Lircmap.xml file placed at (home/pi/.xbmc/userdata). More details will follow in my next post [click here]. Please post a comment , if you face any difficulties.A sample lircd.conf
# Please make this file available to others
# by sending it to <[email protected]>
#
# this config file was automatically generated
# using lirc-0.9.0-pre1(default) on Fri Oct 25 21:47:45 2013
#
# contributed by
#
# brand: /home/pi/lircd.conf.new
# model no. of remote control:
# devices being controlled by this remote:
#
begin remote
name /home/pi/lircd.conf.new
flags RAW_CODES|CONST_LENGTH
eps 30
aeps 100
gap 114780
begin raw_codes
name KEY_RECORD
1147 624 1147 660 2015 681
1093 700 1087 705 1077 1626
998 798 988 821 1855 825
958 1729 953 837 938
name KEY_PLAY
1142 635 2004 692 1095 702
1091 705 1094 705 1035 1667
1876 1705 980 816 1862 823
947 1748 924
name KEY_PAUSE
1139 667 1099 688 1988 715
1082 699 1078 785 953 1686
987 804 985 806 1872 817
961 833 955 1738 934
name KEY_STOP
1134 655 1123 669 1996 698
1087 712 1079 737 1000 1674
1886 1739 951 819 1858 825
945 839 935
name KEY_PREVIOUS
1161 622 2033 662 1112 686
1103 687 1088 705 1085 1614
1891 1714 979 823 947 827
1851 1741 928
name KEY_NEXT
1116 673 1084 707 1946 766
984 806 978 811 968 1719
1844 1744 933 865 910 892
890 907 1776
name KEY_FASTFORWARD
1173 621 2052 633 1148 647
1136 655 1117 677 1089 1600
1926 1685 982 806 972 818
1844 850 950
name KEY_REWIND
1169 668 1088 663 2006 683
1089 699 1089 707 1083 1623
1883 1712 968 822 1848 1747
928 847 925
name KEY_RED
1151 640 2010 685 1093 709
1077 719 1070 709 1157 1551
991 802 982 819 1864 1717
954 835 943 846 940
name KEY_GREEN
1179 609 1140 652 2015 684
1088 698 1088 705 1081 1616
1013 788 986 808 1864 1733
949 836 1824
name KEY_YELLOW
1183 608 2048 657 1121 658
1146 646 1121 673 1090 1628
1057 724 1015 783 1884 805
965 1725 1835
name KEY_MENU
1172 621 2020 666 1120 680
1100 700 1081 700 1114 1595
1003 786 1883 1724 958 819
963 838 1814
name KEY_BLUE
1166 622 1165 627 2029 668
1103 683 1107 685 1088 1599
1177 679 951 802 1876 1713
1845 836 947
name KEY_ENTER
1149 632 2033 656 1136 660
1110 687 1091 703 1085 1611
1894 1707 1862 1718 956 831
948 844 933
end raw_codes
end remote
Re mapping the IR remote keys for xbmc under Raspbmc
If we need to use a specific key on the remote control for a different function on the raspbmc/xbmc we need to remap the keys. For e.g. we can remap the record button on a tv remote to stop button on raspbmc and so on. For this, create a file called Lircmap.xml and keep it at ~/.xbmc/userdata
An example file is given below nano ~/.xbmc/userdata/Lircmap.xml
<lircmap>
<remote device="devinput">
<stop>KEY_RECORD</stop>
<play>KEY_PLAY</play>
<pause>KEY_PAUSE</pause>
<stop>KEY_STOP</stop>
<left>KEY_PREVIOUS</left>
<right>KEY_NEXT</right>
<up>KEY_FASTFORWARD</up>
<down>KEY_REWIND</down>
<back>KEY_RED</back>
<start>KEY_GREEN</start>
<mute>KEY_YELLOW</mute>
<close>KEY_BLUE</close>
<select>KEY_ENTER</select>
</remote>
</lircmap>
Notes on Recording and debugging irremotes with irrecord/lirc
A simple log of recording an irremote and debugging the keypresses with irw
pi@raspbmc:~$ sudo /etc/init.d/lirc stop
[ ok ] Stopping remote control daemon(s): LIRC:.
pi@raspbmc:~$ sudo lircd -d /dev/lirc0
pi@raspbmc:~$ irw
00000000e17a28d7 00 KEY_BACK philipsxbmc
00000000e17a28d7 01 KEY_BACK philipsxbmc
00000000e17a28d7 02 KEY_BACK philipsxbmc
Routines
========
pi@raspbmc:~$ irrecord -d /dev/lirc0 ~/newconf.conf
irrecord - application for recording IR-codes for usage with lirc
Copyright (C) 1998,1999 Christoph Bartelmus([email protected])
This program will record the signals from your remote control
and create a config file for lircd.
A proper config file for lircd is maybe the most vital part of this
package, so you should invest some time to create a working config
file. Although I put a good deal of effort in this program it is often
not possible to automatically recognize all features of a remote
control. Often short-comings of the receiver hardware make it nearly
impossible. If you have problems to create a config file READ THE
DOCUMENTATION of this package, especially section "Adding new remote
controls" for how to get help.
If there already is a remote control of the same brand available at
http://www.lirc.org/remotes/ you might also want to try using such a
remote as a template. The config files already contain all
parameters of the protocol used by remotes of a certain brand and
knowing these parameters makes the job of this program much
easier. There are also template files for the most common protocols
available in the remotes/generic/ directory of the source
distribution of this package. You can use a template files by
providing the path of the file as command line parameter.
Please send the finished config files to <[email protected]> so that I
can make them available to others. Don't forget to put all information
that you can get about the remote control in the header of the file.
Press RETURN to continue.
Now start pressing buttons on your remote control.
It is very important that you press many different buttons and hold them
down for approximately one second. Each button should generate at least one
dot but in no case more than ten dots of output.
Don't stop pressing buttons until two lines of dots (2x80) have been
generated.
Press RETURN now to start recording.
................................................................................
Found const length: 108501
Please keep on pressing buttons like described above.
................................................................................
Space/pulse encoded remote control found.
Signal length is 67.
Found possible header: 9047 4522
Found trail pulse: 562
Found repeat code: 9040 2245
Signals are space encoded.
Signal length is 32
Now enter the names for the buttons.
Please enter the name for the next button (press <ENTER> to finish recording)
KEY_0
Now hold down button "KEY_0".
=========================
end
No comments:
Post a Comment