Thanks Ant, I've had a look around and I've decided to just go for a standard button, the LED status isn't going to make much of an impact in practical terms.
I've attached some pictures of the project so far.
Tonight I've been fiddling with some code and getting a power button working (at the moment a fugly switch nicked from an old PC case, but it has the female pin headers, so no breadboard needed
:) ).
I had some trouble as when the DAC and Amp are stacked on top of the Pi, they cover all of the GPIO. Some pins are passed up the stack and the Amp on top gives a 10 pin array (pins 1 - 10) to work with. IMG_3284 has the best view of these.
The instructions say to connect the 7" touchscreen up to pins 5 and 6. However, the pins that are hardwired for wake/shutdown are 5 and 6, so I guess this is how they bring the screen on at power on. I've moved the screen to take the 5V power from pin 2 and the GND at pin 9, and fit the switch to cover pins 5 and 6. It's all working and uses this script (albeit mine has a few tweaks in the path append to look in an updated folder on this version of LibreElec, this is cribbed from a site):
Code:
#!/usr/bin/python
import sys
sys.path.append('storage/.kodi/addons/python.RPi.GPIO/lib')
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)
What it doesn't do is power off the backlight to the screen. So, the Pi goes off and the screen stays bright white. Using these commands I'm able to turn the screen on and off:
Code:
echo 0 > /sys/class/backlight/rpi_backlight/bl_power
echo 1 > /sys/class/backlight/rpi_backlight/bl_power
Echo 0 turns it on, Echo 1 turns it off. What I don't know due to my coding inadequacies is how to shoehorn those commands into the previous script so they work in tandem - so that a push of the power button would wake the system and turn on the backlight, and a subsequent push would shutdown and turn off the backlight. Any ideas anyone please?!
EDITED: 24 Aug 2018 15:08 by GRAPHITONE