Página 1 de 1

AGREGAR UN PULSADOR PARA APAGAR Y ENCENDER NUESTRA RETROPIE

Publicado: 17 Feb 2017, 17:57
por mbustos.solar
HOLA JUNTO CON SALUDARLES LES DEJO EL PROCEDIMIENTO QUE UTILIZE PARA ENCENDER Y APAGAR MI RETROPIE
imagen para conexión del pulsador (se utiliza la conexión 5 y 6)
Bueno sigan paso por paso lo que les dejare a continuación:
Nº1.

Código: Seleccionar todo

sudo apt-get install update

Nº 2.

Código: Seleccionar todo

sudo apt-get install python-dev

Nº3.

Código: Seleccionar todo

 sudo apt-get install python3-dev 

Nº4.

Código: Seleccionar todo

sudo apt-get install gcc 

Nº 5.

Código: Seleccionar todo

sudo apt-get install python-pip
Nº6. Ahora deben obtener RPi.GPIO de la siguiente manera:

Código: Seleccionar todo

wget https://pypi.python.org/packages/source/R/RPi.GPIO/RPi.GPIO-0.5.11.tar.gz
Nº7. Descomprimir el paquete:

Código: Seleccionar todo

sudo tar -zxvf RPi.GPIO-0.5.11.tar.gz
Nº8. Mover el contenido al directorio creado:

Código: Seleccionar todo

cd RPi.GPIO-0.5.11
Nº9Instale el módulo haciendo:

Código: Seleccionar todo

sudo python setup.py install

Código: Seleccionar todo

sudo python3 setup.py install
Nº10.Crearemos un directorio para mantener sus scripts:

Código: Seleccionar todo

mkdir /home/pi/scripts
Nº11. Llamaremos a nuestro script shutdown.py (está escrito en python). Cree y edite el script haciendo:

Código: Seleccionar todo

sudo nano /home/pi/scripts/shutdown.py
Nº12.Copiar el contenido del script en area blanca creada

Código: Seleccionar todo

#!/usr/bin/python
import RPi.GPIO as GPIO
import time
import subprocess

# we will use the pin numbering to match the pins on the Pi, instead of the 
# GPIO pin outs (makes it easier to keep track of things)

GPIO.setmode(GPIO.BOARD)  

# use the same pin that is used for the reset button (one button to rule them all!)
GPIO.setup(5, GPIO.IN, pull_up_down = GPIO.PUD_UP)  

oldButtonState1 = True

while True:
    #grab the current button state
    buttonState1 = GPIO.input(5)

    # check to see if button has been pushed
    if buttonState1 != oldButtonState1 and buttonState1 == False:
      subprocess.call("shutdown -h now", shell=True, 
        stdout=subprocess.PIPE, stderr=subprocess.PIPE)
      oldButtonState1 = buttonState1

    time.sleep(.1)
Presionar CRTL+X y luego Y
Nº13. Resetear raspberry

Código: Seleccionar todo

sudo reboot
Nº14. Configurar nuestra secuencia de comandos para ejecutar en el inicio

Código: Seleccionar todo

sudo nano /etc/rc.local
Nº15. Agregamos la siguiente linea al archivo

Código: Seleccionar todo

sudo python /home/pi/scripts/shutdown.py &
Nº16. Presionar CRTL+X luego Y
Nº17. EJECUTA:

Código: Seleccionar todo

sudo reboot
listo luego presiona el pulsador para apagar tu raspberry y presiona de nuevo para encender... :xd

Re: AGREGAR UN PULSADOR PARA APAGAR Y ENCENDER NUESTRA RETROPIE

Publicado: 17 Feb 2017, 19:44
por wat3r
Magnífico tutorial y todo muy claro. Gracias compañero

Enviado desde mi SM-G900F mediante Tapatalk

Re: AGREGAR UN PULSADOR PARA APAGAR Y ENCENDER NUESTRA RETROPIE

Publicado: 17 Feb 2017, 20:45
por Pol
Muy interesante! buena idea.

Re: AGREGAR UN PULSADOR PARA APAGAR Y ENCENDER NUESTRA RETROPIE

Publicado: 17 Feb 2017, 20:48
por ganadinerito
Muy buen tutorial compañero. Muchas gracias !!!

Re: AGREGAR UN PULSADOR PARA APAGAR Y ENCENDER NUESTRA RETROPIE

Publicado: 04 Mar 2017, 20:02
por fjttu
Muchas gracias,buen trabajo..

Re: AGREGAR UN PULSADOR PARA APAGAR Y ENCENDER NUESTRA RETROPIE

Publicado: 04 Mar 2017, 20:05
por armadiyo
Me lo apunto, gracias por el tutorial.

Re: AGREGAR UN PULSADOR PARA APAGAR Y ENCENDER NUESTRA RETROPIE

Publicado: 05 Mar 2017, 09:28
por XLoopinX
muy buena, lo probare y te dire como me funciona! gracias

Re: AGREGAR UN PULSADOR PARA APAGAR Y ENCENDER NUESTRA RETROPIE

Publicado: 05 Mar 2017, 21:57
por Awstin
Esto viene genial. gracias!

Re: AGREGAR UN PULSADOR PARA APAGAR Y ENCENDER NUESTRA RETROPIE

Publicado: 06 Mar 2017, 15:47
por manopla
Tiene muy buena pinta, gracias compañero.

Re: AGREGAR UN PULSADOR PARA APAGAR Y ENCENDER NUESTRA RETROPIE

Publicado: 07 Mar 2017, 01:22
por laguntxu
Buen aporte compañero, gracias.

Re: AGREGAR UN PULSADOR PARA APAGAR Y ENCENDER NUESTRA RETROPIE

Publicado: 11 Mar 2017, 11:13
por javiilade
gracias por la informacion, enhorabuena

Re: AGREGAR UN PULSADOR PARA APAGAR Y ENCENDER NUESTRA RETROPIE

Publicado: 11 Mar 2017, 19:28
por Reichmachine
Muchas gracias gran tutorial

Re: AGREGAR UN PULSADOR PARA APAGAR Y ENCENDER NUESTRA RETROPIE

Publicado: 14 Mar 2017, 09:34
por MrBeaker
Buen tutorial y buen curro que te has pegado!! :D
Hace un tiempo abrí yo un tuto parecido, podríamos complementarlos
viewtopic.php?f=6&t=1572

Saludos.

Re: AGREGAR UN PULSADOR PARA APAGAR Y ENCENDER NUESTRA RETROPIE

Publicado: 17 Mar 2017, 09:33
por ManuTdi
Para recalbox no hay nada parecido?

Re: AGREGAR UN PULSADOR PARA APAGAR Y ENCENDER NUESTRA RETROPIE

Publicado: 17 Mar 2017, 10:00
por SamSepiol
ManuTdi escribió:Para recalbox no hay nada parecido?

Re: AGREGAR UN PULSADOR PARA APAGAR Y ENCENDER NUESTRA RETROPIE

Publicado: 01 Ago 2017, 14:51
por geldanaqr
Gracias, tengo que probar esto poque hice una minibartop y el crio la apaga de golpe y miedo me da la sd

Re: AGREGAR UN PULSADOR PARA APAGAR Y ENCENDER NUESTRA RETROPIE

Publicado: 03 Ago 2017, 13:08
por Dragon.Kalos
Añado la imagen para que no haya que abrir una nueva ventana

Imagen

Re: AGREGAR UN PULSADOR PARA APAGAR Y ENCENDER NUESTRA RETROPIE

Publicado: 07 Sep 2017, 17:26
por melli3ds
Gracias por compartir no sabia que se le podía añadir un botón de apagado y encendido

Re: AGREGAR UN PULSADOR PARA APAGAR Y ENCENDER NUESTRA RETROPIE

Publicado: 10 Sep 2017, 09:32
por el_miranda
ManuTdi escribió:Para recalbox no hay nada parecido?
Hola, entiendo poco de la materia aún, pero creo que aquí se explica para retropie como para recalbox:

viewtopic.php?f=6&t=1572

A ver si algún día llego a entender todas éstas configuraciones y las pongo en práctica :lol: , un saludo!! ;)