Page 1 of 3

Re: Lightning button on the rear...?

Posted: Tue 2 Jan 2018 14:42
by roostaar
I found a small note in the installation guide...

“5 - V1.2 Has some difference :

Button with a lightning bolt at the back is now a GPIO button.”

So what can we do with the his GPIO button??

Re: Lightning button on the rear...?

Posted: Tue 2 Jan 2018 15:45
by Graylag
On v1.2 revision (second batch) devices it does nothing on default. But it is connected to one of the GPIO pins of raspberry (specifically GPIO 17) and it can be accessed from command line, through script or other programs. So in theory it can be used for anything and only your programming skills are the limit.

Most obvious use would be as shutdown or soft reset button, checked by bash script. But it might be programmed even as controller button.

Personally I intend to programm it as soft reset button and cut it flat with case to prevent accidental pushing. This would be great for those "stucked" situation where you don't have keyboard around to restore (typically "file manager" - this one is my personal nightmare). Only I have been too busy playing instead of programming :D

Re: Lightning button on the rear...?

Posted: Thu 4 Jan 2018 13:15
by roostaar
Cheers for reply

I have tried using the program 'retrogame' to program the button but having followed the instructions, still cannot get it to simulate a keypress.

Fancy giving it it a go?

https://learn.adafruit.com/retro-gaming ... s-software

Re: Lightning button on the rear...?

Posted: Thu 4 Jan 2018 13:39
by thomas
This Tutorial ist based on http://www.instructables.com/id/Simple- ... wn-Button/.

Download the script:

Code: Select all

wget http://tinyurl.com/off-button-py -O /home/pi/off-button.py
alternatively

Code: Select all

wget https://www.instructables.com/files/orig/FVM/K0WJ/IA0WRZBF/FVMK0WJIA0WRZBF.py -O /home/pi/off-button.py
edit the script:

Code: Select all

nano /home/pi/off-button.py
replace

Code: Select all

gpio_pin_number=YOUR_CHOSEN_GPIO_NUMBER_HERE
with

Code: Select all

gpio_pin_number=17
Set the Script to Run at Boot-up:

Code: Select all

sudo nano /etc/rc.local
and write befor

Code: Select all

exit 0
the line

Code: Select all

python /home/pi/off-button.py &
Don*t forget the & sign on the end, otherwise the Pi does hang in the bootprozess.

Re: Lightning button on the rear...?

Posted: Sun 14 Jan 2018 23:28
by roostaar
Hi Thomas

Thanks for this!

Have tried the steps but no joy. :?

Have you tried this successfully?

Cheers

Re: Lightning button on the rear...?

Posted: Wed 17 Jan 2018 17:47
by breeman
I followed this tutorial for a soft shutdown button https://www.youtube.com/watch?v=4nTuzIY0i3k

And I got it working with the following script (they used Pin 5, Lightning button uses Pin 11)

Code: Select all

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

GPIO.setmode(GPIO.BOARD)  

GPIO.setup(11, GPIO.IN, pull_up_down = GPIO.PUD_UP)  

oldButtonState1 = True

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

    # 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)

Re: Lightning button on the rear...?

Posted: Sat 20 Jan 2018 16:12
by roostaar
Thanks for this breeman

I have followed this to the letter and it still won't work for me!

Is it possible my BIB is not actually connected to ground/faulty?

I have tried this so many times now. :(

Re: Lightning button on the rear...?

Posted: Sat 20 Jan 2018 16:27
by Vilikt
Try to add

Code: Select all

(sleep 10;python /home/pi/off-button.py) & 
instead of simply

Code: Select all

python /home/pi/off-button.py &

Re: Lightning button on the rear...?

Posted: Mon 22 Jan 2018 01:21
by roostaar
Vilikt wrote:Try to add

Code: Select all

(sleep 10;python /home/pi/off-button.py) & 
instead of simply

Code: Select all

python /home/pi/off-button.py &
Thank you for your advice. Still no joy i'm afraid...

BTW, what does 'sleep 10;' do to the code?

Re: Lightning button on the rear...?

Posted: Mon 22 Jan 2018 22:43
by roostaar
Ok, so I rigged up an arcade button to my RPi3 to pins 5 & 6 and followed the tutorial by barryhubbard.

http://www.barryhubbard.com/raspberry-p ... io-button/

This works perfectly on my RPi3!

I followed the steps again for my Raspiboy and altered the script to Pin 11 and nothing.

Surely I have a dodgy PCB?

Edit: Have just tried a fresh clean install with a different SD on RetroPie 4.3 and same result. :(