TUTO POUR RETROPIE

Publié le : 03/12/2017 23:31:21
Catégories : Tuto, Manuel

TUTO RETROPIE

INTRODUCTION

OS/Distribution

RetroPie is v4.3 – released on the 21th September 2017

Raspberry Pi 3 Model B

SOMMAIRE

  • 1-Infrarouge-télécommande: recevoir et décoder les signaux infrarouge de la télécommande Nuxii. Naviguer dans les menus, de contrôler retroarch (LOAD/SAVE,QUIT,RESET....), ou votre environnement linux simplement depuis votre télécommande
  • 2- LEDS: allume une led verte lorsqu'un jeux est lancé et une led rouge quand vous êtes dans le menu
  • 3-Bouton:Eteindre le Raspberry Pi
  • 4-LCD:Afficher la consommation CPU/Memoire, la température, l'heure...

Utilisation

Ce tuto aborde les étapes nécessaires à la mise en fonctionnement des modules intégrables au boitier Nuxii SG et XG avec RetroPie v4.3, une distribution retrogaming/mediacenter pour Raspberry Pi 3 !

Prérequis

Raspberry Pi 3, Bouton Nuxii, Module infrarouge Led + Télécommande, LCD16x2

Niveau de difficulté: 3/5

Accès ssh

Création/Modification d'un fichier en ligne de commande Linux

Connaissance des commandes Linux

AVERTISSEMENT

CERTAINES ETAPES PEUVENT NÉCESSITER UN ACCES INTERNET

ATTENTION: LES MISES A JOURS PEUVENT SUPPRIMER CERTAINES CONFIGURATIONS. ASSUREZ-VOUS DE SUIVRE DE NOUVEAU CES ETAPES EN CAS PROBLEME APRES MAJ.

NOTE: CE TUTORIEL N'A ETE TESTE QUE SUR LA VERSION INDIQUEE EN TETE DE PAGE. AUCUN SUPPORT TECHNIQUE NE SERA APPORTE SUR LES PROBLEMES LIES AUX FUTURES MISES A JOUR

ETAPES

Etape 0 - Preparation de l'OS

Installez Retropie, connectez-vous en ssh puis lancez les commandes et modifiez les fichiers comme indiqué:

> apt-get update
> mkdir /home/pi/scripts

Etape 1 - Infrarouge/Telecommande

>apt-get install lirc

/boot/config.txt

dtoverlay=lirc-rpi,gpio_in_pin=17,gpio_out_pin=7

/etc/modules

i2c-dev

/opt/retropie/configs/all/retroarch.cfg
# Enable stdin/network command interface.
 network_cmd_enable = true
 network_cmd_port = 55355
 stdin_cmd_enable = true

~/.lircrc
begin
prog = irexec
button = KEY_BACK
config = /opt/retropie/emulators/retroarch/bin/retroarch --command LOAD_STATE
end
begin
prog = irexec
button = KEY_HOME
config = /opt/retropie/emulators/retroarch/bin/retroarch --command SAVE_STATE
end
begin
prog = irexec
button = KEY_UP
config = /opt/retropie/emulators/retroarch/bin/retroarch --command STATE_SLOT_PLUS
repeat = 1
end
begin
prog = irexec
button = KEY_DOWN
config = /opt/retropie/emulators/retroarch/bin/retroarch --command STATE_SLOT_MINUS
repeat = 1
end
begin
prog = irexec
button = KEY_LEFT
config = /opt/retropie/emulators/retroarch/bin/retroarch --command LOAD_STATE
repeat = 1
end
begin
prog = irexec
button = KEY_RIGHT
config = /opt/retropie/emulators/retroarch/bin/retroarch --command FAST_FORWARD
repeat = 1
end
begin
prog = irexec
button = KEY_OK
config = /opt/retropie/emulators/retroarch/bin/retroarch --command LOAD_STATE
end
begin
prog = irexec
button = KEY_STOP
config = /opt/retropie/emulators/retroarch/bin/retroarch --command QUIT
end
begin
prog = irexec
button = KEY_PLAY
config = /opt/retropie/emulators/retroarch/bin/retroarch --command PAUSE_TOGGLE
end
begin
prog = irexec
button = KEY_REWIND
config = /opt/retropie/emulators/retroarch/bin/retroarch --command RESET
repeat = 1
end
begin
prog = irexec
button = KEY_FASTFORWARD
config = /opt/retropie/emulators/retroarch/bin/retroarch --command FAST_FORWARD
end
begin
prog = irexec
button = KEY_VOLUMEDOWN
config = amixer set PCM -- $[$(amixer get PCM|grep -o [0-9]*%|sed 's/%//')-1]%
repeat = 1
end
begin
prog = irexec
button = KEY_VOLUMEUP
config = amixer set PCM -- $[$(amixer get PCM|grep -o [0-9]*%|sed 's/%//')+1]%
repeat = 1
end

>shutdown -r now
>irrecord -f -d /dev/lirc0 /etc/lirc/lircd.conf

Etape 2 - LEDS

/home/pi/scripts/nuxii-led.sh

#!/bin/bash
LED1=27
LED2=22
cd /sys/class/gpio/

if [ -e /sys/class/gpio/export ]
then
        echo "$LED1" > /sys/class/gpio/export
        echo "$LED2" > /sys/class/gpio/export
fi

echo out > /sys/class/gpio/gpio$LED1/direction
echo 0 > /sys/class/gpio/gpio$LED1/value

echo out > /sys/class/gpio/gpio$LED2/direction
echo 1 > /sys/class/gpio/gpio$LED2/value

while true;
 do retroarch=$(ps -ef | grep retroarch | grep -v "grep" | wc -l)
  if [ $retroarch -eq 0 ]; # If retroarch is not playing
   then
    echo 0 > /sys/class/gpio/gpio$LED1/value
    echo 1 > /sys/class/gpio/gpio$LED2/value
   else
    echo 0 > /sys/class/gpio/gpio$LED2/value
    echo 1 > /sys/class/gpio/gpio$LED1/value
  fi
  sleep 1
done

 /lib/systemd/system/nuxii-led.service
   [Unit]
   Description=ShutdownScript
   After=multi-user.target

   [Service]
   Type=idle
   ExecStart=/home/pi/scripts/nuxii-led.sh

   [Install]
   WantedBy=multi-user.target


  > sudo chmod 644 /lib/systemd/system/nuxii-led.service
 >  sudo systemctl daemon-reload
 >  sudo systemctl enable nuxii-led.service   

Etape 3 - Bouton

> sudo apt-get install python-pip

> pip install RPi.GPIO

 /home/pi/scripts/shutdown.py

#!/usr/bin/python
import RPi.GPIO as GPIO
import time
import subprocess
GPIOBUTTON=23
LEDBUTTON=14

def initGlobals():
       GPIO.setmode(GPIO.BCM)
       GPIO.setup(GPIOBUTTON, GPIO.IN)
       GPIO.setup(LEDBUTTON, GPIO.OUT)

def fct():
       subprocess.call("shutdown -h now", shell=True,
        stdout=subprocess.PIPE, stderr=subprocess.PIPE)

#########################################
#MAIN - entry point

if __name__ == '__main__':
    initGlobals()
    GPIO.output(LEDBUTTON, GPIO.HIGH)

    GPIO.setup(GPIOBUTTON, GPIO.IN, pull_up_down=GPIO.PUD_UP)
    GPIO.wait_for_edge(GPIOBUTTON, GPIO.FALLING, bouncetime=300)
    fct()
    GPIO.remove_event_detect(GPIOBUTTON)
    GPIO.cleanup(GPIOBUTTON)
    GPIO.cleanup(LEDBUTTON)
#########################################



 /lib/systemd/system/shutdown.service
   [Unit]
   Description=ShutdownScript
   After=multi-user.target

   [Service]
   Type=idle
   ExecStart=/usr/bin/python /home/pi/scripts/shutdown.py

   [Install]
   WantedBy=multi-user.target


  > sudo chmod 644 /lib/systemd/system/shutdown.service
 >  sudo systemctl daemon-reload
 >  sudo systemctl enable shutdown.service   
   

Etape 4 - Ecran LCD

>apt-get install lcdproc i2c-tools

wget -O /usr/lib/arm-linux-gnueabihf/lcdproc/ https://github.com/wilberforce/lcdproc/raw/master/hd44780.so

>raspi-config

->Interface options

->Activate i2c

## Server section with all kinds of settings for the LCDd server
 [server]
DriverPath=/usr/lib/arm-linux-gnueabihf/lcdproc/
#DriverPath=/path/to/hd44780.so
Driver=hd44780
Bind=127.0.0.1
Port=13666
User=root
Foreground=yes
# Hello message: each entry represents a display line; default: builtin Hello=" Welcome to"
Hello="RetroPie"
# GoodBye message: each entry represents a display line; default: buil$ GoodBye="Bye bye"
GoodBye=" C U"
# Sets the default time in seconds to displays a screen.
WaitTime=5
# set title scrolling speed [default: 10; legal: 0-10]
TitleSpeed=1
## Hitachi HD44780 driver
 [hd44780]
ConnectionType=i2c
# Port where the LPT is. Usual value are: 0x278, 0x378 and 0x3BC
Port=0x27
# Device of the serial interface [default: /dev/lcd]
Device=/dev/i2c-1
# Bitrate of the serial port (0 for interface default)
Speed=0
# Specifies the size of the LCD.
# In case of multiple combined displays, this should be the total size.
Size=16x2
CharMap=hd44780_default
DelayMult=4
#You may need to change some values depending on what i2c baclpack you use
i2c_line_RS=0x01
i2c_line_RW=0x02
i2c_line_EN=0x04
i2c_line_BL=0x08
i2c_line_D4=0x10
i2c_line_D5=0x20
i2c_line_D6=0x40
i2c_line_D7=0x80
Backlight=yes
BacklightInvert=yes

Specificités version BOUTON + ECRAN

Il faut changer la pin 3 dans le script du bouton

Source

Partager ce contenu