Després d'aconseguir un comandament a distància universal del lidl, se'm va acudir que potser el podria fer servir per a controlar la meva raspberry pi amb openelec. Fins al moment feia servir l'aplicació kore al mobil, però volia provar que tal aniria amb un comandament "de veritat". Vaig comprar a dealextreme un receptor d'infrarojos molt bé de preu i amb uns cables que tenia a casa vaig començar a preparar l'invent. Vaig estar agafant coses de diferents webs, i aquí escric els passos que vaig haver de fer per a configurar-ho tot.
1.- Connectar el sensor a la raspberry
El primer pas va ser connectar el sensor IR a la raspberry, per a fer-ho, primer cal identificar els 3 pins del sensor. En el meu cas van marcats amb les lletres G, R i Y. G es el terra, R es el voltatge i Y es el de dades. Els connecto als pins GPIO de la raspberry de la següent forma:
G al pin 14, R al 1 i Y al 12
Un cop fet això, al comandament a distància universal agafo un dispositiu que no tingui definit i comprovo que cap dels botons interfereix amb els altres dispositius. Amb això ja estem a punt per a fer que la raspberry "aprengui" a interpretar les ordres que li arriben des del comandament. Per a això hem de definir les tecles a fer servir, ens connectem per ssh a la raspberry amb root (si no hem canviat la contrasenya, serà openelec). Per veure totes les possibilitats executem irrecord -list namespace
En el meu cas he definit les següents tecles
KEY_POWER
KEY_VOLUMEUP
KEY_VOLUMEDOWN
KEY_0
KEY_1
KEY_2
KEY_3
KEY_4
KEY_5
KEY_6
KEY_7
KEY_8
KEY_9
KEY_BACK
KEY_INFO
KEY_SELECT
KEY_LEFT
KEY_RIGHT
KEY_UP
KEY_DOWN
KEY_MENU
KEY_PLAY
KEY_REWIND
KEY_FASTFORWARD
KEY_SUBTITLE
KEY_PAUSE
Un cop decidides les tecles que volem fer servir, hem d'executar irrecord -d /dev/lirc0 /storage/.config/lircd.conf
Ens demanarà apretar botons del comandament, per anar omplint uns punts a la pantalla. Això serveix per a calibrar el sensor amb el comandament, i després ens anirà demanant tecles a definir. Haurem d'escriure cadascun dels codis que haguem decidit, i a continuació ens demanarà prémer la tecla. Això es un procés una mica farragós, però en 10 minuts ho he enllestit.
Un cop fet això, hem de crear el fitxer Lircmap.xml al directori /storage/.kodi/userdata, en el meu cas té el següent contingut
<lircmap>
<remote device="remote">
<power>KEY_POWER</power>
<subtitle>KEY_SUBTITLE</subtitle>
<volumeplus>KEY_VOLUMEUP</volumeplus>
<volumeminus>KEY_VOLUMEDOWN</volumeminus>
<zero>KEY_0</zero>
<one>KEY_1</one>
<two>KEY_2</two>
<three>KEY_3</three>
<four>KEY_4</four>
<five>KEY_5</five>
<six>KEY_6</six>
<seven>KEY_7</seven>
<eight>KEY_8</eight>
<nine>KEY_9</nine>
<zero>KEY_0</zero>
<back>KEY_BACK</back>
<info>KEY_INFO</info>
<select>KEY_SELECT</select>
<left>KEY_LEFT</left>
<right>KEY_RIGHT</right>
<up>KEY_UP</up>
<down>KEY_DOWN</down>
<menu>KEY_MENU</menu>
<play>KEY_PLAY</play>
<reverse>KEY_REWIND</reverse>
<forward>KEY_FORWARD</forward>
<stop>KEY_STOP</stop>
<pause>KEY_PAUSE</pause>
</remote>
</lircmap>
També haurem de crear el fitxer remote.xml al directori /storage/.kodi/userdata/keymaps amb el contingut següent:
<keymap>
<global>
<remote>
<play>Play</play>
<pause>Pause</pause>
<stop>Stop</stop>
<forward>FastForward</forward>
<reverse>Rewind</reverse>
<left>Left</left>
<right>Right</right>
<up>Up</up>
<down>Down</down>
<select>Select</select>
<enter>FullScreen</enter>
<pageplus>PageUp</pageplus>
<pageminus>PageDown</pageminus>
<back>ParentDir</back>
<menu>ContextMenu</menu>
<title>ContextMenu</title>
<info>Info</info>
<skipplus>SkipNext</skipplus>
<skipminus>SkipPrevious</skipminus>
<display>FullScreen</display>
<start>XBMC.ActivateWindow(Favourites)</start>
<record>Stop</record>
<volumeplus>VolumeUp</volumeplus>
<volumeminus>VolumeDown</volumeminus>
<mute>Mute</mute>
<power>XBMC.RestartApp()</power>
<myvideo>XBMC.ActivateWindow(VideoLibrary,MovieTitles)</myvideo>
<mymusic>XBMC.ActivateWindow(Weather)</mymusic>
<mypictures>XBMC.ActivateWindow(MyPictures)</mypictures>
<mytv>XBMC.ActivateWindow(VideoLibrary,TvShowTitles)</mytv>
<zero>XBMC.RestartApp()</zero>
<one>Number1</one>
<two>JumpSMS2</two>
<three>JumpSMS3</three>
<four>JumpSMS4</four>
<five>JumpSMS5</five>
<six>JumpSMS6</six>
<seven>JumpSMS7</seven>
<eight>JumpSMS8</eight>
<nine>JumpSMS9</nine>
<hash>Screenshot</hash>
<!-- <star>EjectTray()</star> -->
<xbox>scanitem</xbox>
</remote>
</global>
<Home>
<remote>
<info>XBMC.ActivateWindow(SystemInfo)</info>
<clear>XBMC.ActivateWindow(Weather)</clear>
<hash>Screenshot</hash>
</remote>
</Home>
<MyFiles>
<remote>
<clear>Delete</clear>
<zero>Highlight</zero>
<star>Move</star>
<hash>Rename</hash>
</remote>
</MyFiles>
<MyMusicPlaylist>
<remote>
<back>Playlist</back> <!-- Close playlist -->
<clear>Delete</clear>
<zero>Delete</zero>
</remote>
</MyMusicPlaylist>
<MyMusicPlaylistEditor>
<remote>
<zero>Queue</zero>
</remote>
</MyMusicPlaylistEditor>
<MyMusicFiles>
<remote>
<zero>Queue</zero>
<star>Queue</star>
</remote>
</MyMusicFiles>
<MyMusicLibrary>
<remote>
<zero>Queue</zero>
<star>Queue</star>
</remote>
</MyMusicLibrary>
<FullscreenVideo>
<remote>
<zero>Number0</zero>
<one>Number1</one>
<two>Number2</two>
<three>Number3</three>
<four>Number4</four>
<five>Number5</five>
<six>Number6</six>
<seven>Number7</seven>
<eight>Number8</eight>
<nine>Number9</nine>
<left>StepBack</left>
<right>StepForward</right>
<up>BigStepForward</up>
<down>BigStepBack</down>
<back>SmallStepBack</back>
<menu>OSD</menu>
<start>TakeScreenshot</start>
<select>AspectRatio</select>
<title>CodecInfo</title>
<info>Info</info>
<teletext>XBMC.ActivateWindow(Teletext)</teletext>
<display>ShowSubtitles</display>
<subtitle>ShowSubtitles</subtitle>
<star>EjectTray()</star>
<language>AudioNextLanguage</language>
<hash>Screenshot</hash>
</remote>
</FullscreenVideo>
<VideoTimeSeek>
<remote>
<select>Select</select>
<enter>Select</enter>
</remote>
</VideoTimeSeek>
<FullscreenInfo>
<remote>
<title>CodecInfo</title>
<info>Close</info>
<menu>OSD</menu>
</remote>
</FullscreenInfo>
<PlayerControls>
<remote>
<menu>Close</menu>
</remote>
</PlayerControls>
<Visualisation>
<remote>
<left>PreviousPreset</left>
<right>NextPreset</right>
<up>IncreaseRating</up>
<down>DecreaseRating</down>
<back>LockPreset</back>
<title>CodecInfo</title>
<select>XBMC.ActivateWindow(VisualisationPresetList)</select>
<menu>XBMC.ActivateWindow(MusicOSD)</menu>
<start>XBMC.ActivateWindow(MusicOSD)</start>
<info>Info</info>
</remote>
</Visualisation>
<MusicOSD>
<remote>
<menu>Close</menu>
<title>Info</title>
<info>CodecInfo</info>
</remote>
</MusicOSD>
<VisualisationSettings>
<remote>
<menu>Close</menu>
<back>Close</back>
</remote>
</VisualisationSettings>
<VisualisationPresetList>
<remote>
<menu>Close</menu>
<back>Close</back>
</remote>
</VisualisationPresetList>
<SlideShow>
<remote>
<zero>ZoomNormal</zero>
<one>ZoomLevel1</one>
<two>ZoomLevel2</two>
<three>ZoomLevel3</three>
<four>ZoomLevel4</four>
<five>ZoomLevel5</five>
<six>ZoomLevel6</six>
<seven>ZoomLevel7</seven>
<eight>ZoomLevel8</eight>
<nine>ZoomLevel9</nine>
<info>CodecInfo</info>
<skipplus>NextPicture</skipplus>
<skipminus>PreviousPicture</skipminus>
<title>Info</title>
<select>Rotate</select>
<back>PreviousMenu</back>
</remote>
</SlideShow>
<ScreenCalibration>
<remote>
<select>NextCalibration</select>
<zero>ResetCalibration</zero>
<display>NextResolution</display>
<xbox>NextResolution</xbox>
</remote>
</ScreenCalibration>
<GUICalibration>
<remote>
<select>NextCalibration</select>
<zero>ResetCalibration</zero>
</remote>
</GUICalibration>
<SelectDialog>
<remote>
<back>Close</back>
</remote>
</SelectDialog>
<VideoOSD>
<remote>
<back>PreviousMenu</back>
<menu>Close</menu>
<start>Close</start>
</remote>
</VideoOSD>
<VideoMenu>
<remote>
<menu>OSD</menu>
<back>PreviousMenu</back>
<info>Info</info>
<title>CodecInfo</title>
<zero>Number0</zero>
<one>Number1</one>
<two>Number2</two>
<three>Number3</three>
<four>Number4</four>
<five>Number5</five>
<six>Number6</six>
<seven>Number7</seven>
<eight>Number8</eight>
<nine>Number9</nine>
<play>Select</play>
</remote>
</VideoMenu>
<OSDVideoSettings>
<remote>
<back>Close</back>
<menu>Close</menu>
<start>Close</start>
</remote>
</OSDVideoSettings>
<OSDAudioSettings>
<remote>
<back>Close</back>
<menu>Close</menu>
<start>Close</start>
</remote>
</OSDAudioSettings>
<VideoBookmarks>
<remote>
<back>Close</back>
<menu>Close</menu>
<start>Close</start>
<zero>Delete</zero>
</remote>
</VideoBookmarks>
<MyVideoLibrary>
<remote>
<zero>Queue</zero>
<clear>Delete</clear>
</remote>
</MyVideoLibrary>
<MyVideoFiles>
<remote>
<zero>Queue</zero>
<star>Queue</star>
</remote>
</MyVideoFiles>
<MyVideoPlaylist>
<remote>
<back>Playlist</back> <!-- Close playlist -->
<clear>Delete</clear>
<zero>Delete</zero>
</remote>
</MyVideoPlaylist>
<VirtualKeyboard>
<remote>
<back>BackSpace</back>
<star>Shift</star>
<hash>Symbols</hash>
<zero>Number0</zero>
<one>Number1</one>
<two>Number2</two>
<three>Number3</three>
<four>Number4</four>
<five>Number5</five>
<six>Number6</six>
<seven>Number7</seven>
<eight>Number8</eight>
<nine>Number9</nine>
<enter>Enter</enter>
<pageminus>CursorLeft</pageminus>
<pageplus>CursorRight</pageplus>
</remote>
</VirtualKeyboard>
<ContextMenu>
<remote>
<title>Close</title>
<back>Close</back>
</remote>
</ContextMenu>
<FileStackingDialog>
<remote>
<back>Close</back>
</remote>
</FileStackingDialog>
<Scripts>
<remote>
<info>info</info>
</remote>
</Scripts>
<NumericInput>
<remote>
<zero>Number0</zero>
<one>Number1</one>
<two>Number2</two>
<three>Number3</three>
<four>Number4</four>
<five>Number5</five>
<six>Number6</six>
<seven>Number7</seven>
<eight>Number8</eight>
<nine>Number9</nine>
<enter>Enter</enter>
<back>BackSpace</back>
</remote>
</NumericInput>
<Weather>
<remote>
<back>PreviousMenu</back>
</remote>
</Weather>
<Settings>
<remote>
<back>PreviousMenu</back>
</remote>
</Settings>
<AddonBrowser>
<remote>
</remote>
</AddonBrowser>
<AddonInformation>
<remote>
<back>Close</back>
</remote>
</AddonInformation>
<AddonSettings>
<remote>
<back>Close</back>
</remote>
</AddonSettings>
<TextViewer>
<remote>
<back>Close</back>
</remote>
</TextViewer>
<MyPicturesSettings>
<remote>
<back>PreviousMenu</back>
</remote>
</MyPicturesSettings>
<MyProgramsSettings>
<remote>
<back>PreviousMenu</back>
</remote>
</MyProgramsSettings>
<MyWeatherSettings>
<remote>
<back>PreviousMenu</back>
</remote>
</MyWeatherSettings>
<MyMusicSettings>
<remote>
<back>PreviousMenu</back>
</remote>
</MyMusicSettings>
<SystemSettings>
<remote>
<back>PreviousMenu</back>
</remote>
</SystemSettings>
<MyVideosSettings>
<remote>
<back>PreviousMenu</back>
</remote>
</MyVideosSettings>
<NetworkSettings>
<remote>
<back>PreviousMenu</back>
</remote>
</NetworkSettings>
<AppearanceSettings>
<remote>
<back>PreviousMenu</back>
</remote>
</AppearanceSettings>
<Profiles>
<remote>
<back>PreviousMenu</back>
</remote>
</Profiles>
<systeminfo>
<remote>
<back>PreviousMenu</back>
</remote>
</systeminfo>
<shutdownmenu>
<remote>
<back>PreviousMenu</back>
</remote>
</shutdownmenu>
<submenu>
<remote>
<back>PreviousMenu</back>
</remote>
</submenu>
<MusicInformation>
<remote>
<back>Close</back>
</remote>
</MusicInformation>
<MovieInformation>
<remote>
<info>Close</info>
<back>Close</back>
</remote>
</MovieInformation>
<LockSettings>
<remote>
<menu>Close</menu>
<back>PreviousMenu</back>
</remote>
</LockSettings>
<ProfileSettings>
<remote>
<menu>Close</menu>
<back>PreviousMenu</back>
</remote>
</ProfileSettings>
<PictureInfo>
<remote>
<skipplus>NextPicture</skipplus>
<skipminus>PreviousPicture</skipminus>
<info>Close</info>
<back>Close</back>
</remote>
</PictureInfo>
<Teletext>
<remote>
<zero>number0</zero>
<one>number1</one>
<two>number2</two>
<three>number3</three>
<four>number4</four>
<five>number5</five>
<six>number6</six>
<seven>number7</seven>
<eight>number8</eight>
<nine>number9</nine>
<info>Info</info>
<back>Close</back>
<menu>Close</menu>
<start>Close</start>
<teletext>Close</teletext>
</remote>
</Teletext>
<Favourites>
<remote>
<back>Close</back>
</remote>
</Favourites>
</keymap>
Fet això, ja podem reiniciar amb un reboot, i començar a navegar pels menús de kodi amb el comandament a distància