Audiophonics SPC II - LED turn off on GUI LE shutdown

  • Hey there,

    I enabled the Audiophonics SPC II power module on LE and I had used GPIO's 4, 13 and 22. I had to move the GPIO 17 to 13 because it conflicted with the LCD and DigiOne board. It is working great. When I push the power button, the LE will shutdown, and the LED on the power button will go off.

    However, if I use the LE GUI to shutdown, the power button stays on. Anyone knows how to send the correct signals to the Power Module via GPIO to turn the LED and power off? I was thinking to place the script in the shutdown.sh, which would be able to turn the LED off once I shutdown LE from the TV.

    Here is my current working scripts:

    autostart.sh

    #!/bin/sh

    sleep 5;

    python /storage/.config/afterBoot.py

    python /storage/.config/shutdownirq.py &

    /storage/.kodi/addons/http://service.lcdd/bin/lcdd.start

    /storage/.config/afterBoot.py

    #!/usr/bin/python

    import sys

    sys.path.append('/storage/.kodi/addons/virtual.rpi-tools/lib')

    import subprocess

    import RPi.GPIO as gpio

    import time

    print "Audiophonics Shutdown script starting..."

    print "Asserting pins : "

    print "ShutDown : GPIO13=in, Low"

    print "BootOK : GPIO22=out, High"

    gpio.setmode(gpio.BCM)

    gpio.setup(13, gpio.OUT)

    gpio.output(13, 0)

    gpio.setup(22, gpio.OUT)

    gpio.output(22, 1)

    time.sleep(1) #important to have this or else script won't work X(

    gpio.cleanup()


    python /storage/.config/shutdownirq.py

    #!/usr/bin/python

    # ATXRaspi interrupt based shutdown/reboot script

    # Script based on Tony Pottier, Felix Rusu

    # modified by Juergen Schweighoer

    import sys

    sys.path.append("/storage/.kodi/addons/virtual.rpi-tools/lib")

    import RPi.GPIO as GPIO

    import os

    import time

    GPIO.setmode(GPIO.BCM)

    pulseStart = 0.0

    REBOOTPULSEMINIMUM = 0.2 #reboot pulse signal should be at least this long (seconds)

    REBOOTPULSEMAXIMUM = 1.0 #reboot pulse signal should be at most this long (seconds)

    SHUTDOWN = 13 #GPIO used for shutdown signal - org 6

    BOOT = 22 #GPIO used for boot signal - org 5

    # Set up GPIO 5 and write that the PI has booted up

    GPIO.setup(BOOT, GPIO.OUT, initial=GPIO.HIGH)

    # Set up GPIO 6 as interrupt for the shutdown signal to go HIGH

    GPIO.setup(SHUTDOWN, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)

    print "\n=========================================================================================="

    print " ATXRaspi shutdown IRQ script started: asserted pins (",SHUTDOWN, "=input,LOW; ",BOOT,"=output,HIGH)"

    print " Waiting for GPIO", SHUTDOWN, "to become HIGH (short HIGH pulse=REBOOT, long HIGH=SHUTDOWN)..."

    print "=========================================================================================="

    try:

    while True:

    GPIO.wait_for_edge(SHUTDOWN, GPIO.RISING)

    shutdownSignal = GPIO.input(SHUTDOWN)

    pulseStart = time.time() #register time at which the button was pressed

    while shutdownSignal:

    time.sleep(0.2)

    if(time.time() - pulseStart >= REBOOTPULSEMAXIMUM):

    print "\n====================================================================================="

    print " SHUTDOWN request from GPIO", SHUTDOWN, ", halting Rpi ..."

    print "====================================================================================="

    os.system("poweroff")

    sys.exit()

    shutdownSignal = GPIO.input(SHUTDOWN)

    if time.time() - pulseStart >= REBOOTPULSEMINIMUM:

    print "\n====================================================================================="

    print " REBOOT request from GPIO", SHUTDOWN, ", recycling Rpi ..."

    print "====================================================================================="

    os.system("poweroff")

    sys.exit()

    shutdownSignal = GPIO.input(SHUTDOWN)

    if time.time() - pulseStart >= REBOOTPULSEMINIMUM:

    print "\n====================================================================================="

    print " REBOOT request from GPIO", SHUTDOWN, ", recycling Rpi ..."

    print "====================================================================================="

    os.system("reboot")

    sys.exit()

    if GPIO.input(SHUTDOWN): #before looping we must make sure the shutdown signal went low

    GPIO.wait_for_edge(SHUTDOWN, GPIO.FALLING)

    except:

    pass

    finally:

    GPIO.cleanup()


    Thank you for anyone who contributed to getting this working. I hope this will help someone else looking for these scripts.


    AlleyCat

  • Problem solved:

    I created the following softshutdown1 script, and add one line to the shutdown.sh script:

    softshutdown1

    #! / Usr / bin / python

    # "Audiophonics softshutdown script"

    # " Openelec Version"

    # "softShutdown: GPIO4 = out, low to high"

    import sys

    sys.path.append('/storage/.kodi/addons/virtual.rpi-tools/lib')

    import RPi.GPIO as GPIO

    import time

    import subprocess

    GPIO.setmode (GPIO.BCM)

    GPIO.setwarnings (False)

    GPIO.setup (4, GPIO.OUT)

    GPIO.output (4, GPIO.HIGH)

    time.sleep (1)

    GPIO.output (4, GPIO.LOW)

    GPIO.cleanup ()


    shutdown.sh

    case "$1" in

    halt)

    # your commands here

    ;;

    poweroff)

    # your commands here

    python /storage/.config/softshutdown1

    ;;

    reboot)

    # your commands here

    ;;

    *)

    # your commands here

    ;;

    esac

    • Official Post

    The act of asking for public help usually allows people to instantly spot the obvious mistake made or it provides a sudden burst of inspiration to solve something :)

    Thanks for sharing the solution.