I found that the issue with the sound not working happens when the shutdown script is invoked.
I'm just running the script manaully and not committing it to the autostart.sh and it turns the sound off.
I'm going with the vanilla script again, and providing I can get this working, I'll go with PB's other suggestions.
Code:
#!/usr/bin/python
import sys
sys.path.append('/storage/.kodi/addons/virtual.rpi-tools/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("echo 1 > /sys/class/backlight/rpi_backlight/bl_power && shutdown -h now", shell=True,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
oldButtonState1 = buttonState1
time.sleep(.1)
Going through the manual again, there's a section of what's passed through the GPIO.
The DAC uses pin 5 for I2C. I reckon if I'm now scripting that 5 is something else, that's what's kicking the sound out of touch. On that diagram though GPIO5 is pin 29, so as the script mentions it must be using the physical layout as only the first 10 pins are presented on top the Amp card and when the script runs, the power button works, but has the undesirable sound side effect.
So, with the attached diagram(s) in mind I'm guessing I could swap pins 5 (gpio3) and 6 (gnd) to be 9 (gnd) and 10 (gpio15). Would that be feasable?!
UPDATE - I've tried a combination of the other pins and updated the script accordingly. No joy there.
The pin diagram from the manual shows 7, 8 and 10 are available pins and I've tried them all against a pin 9 ground and it's just not doing anything when the shutdown button's pushed. I read that pins 5 and 6 are somehow favoured for the two pins that when shorted will put the Pi into a sleep mode. I haven't yet found whether this can be changed.
EDITED: 25 Aug 2018 21:13 by GRAPHITONE