Pi install

From: graphitone25 Aug 2018 07:57
To: ALL42 of 92
The pre-configured builds hosted on IQaudIO's site are either too old for the most recent Pi3, or are corrupted in some way, 'cos they don't run :C

Back to the backup plan of using a backup of Kodi on LibreElec and seeing at what point the sound buggers up.
From: graphitone25 Aug 2018 14:16
To: All 43 of 92
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
From: Peter (BOUGHTONP)26 Aug 2018 14:12
To: graphitone 44 of 92
The GPIO.setmode(GPIO.BOARD) makes it use pin numbers, but you can use GPIO.setmode(GPIO.BCM) to use GPIO numbers instead.

The DAC/AMP might only provide the first 10 pins on top, but it's not clear from photos if they actually prevent you connecting to the other pins underneath?

From: graphitone26 Aug 2018 18:41
To: Peter (BOUGHTONP) 45 of 92
Yeah, they do. The DAC covers all 40 pins, while the amp takes the first ten and passes them through to the headers on top of the whole stack. I'm pretty sure it's passing  pins 1 - 10 through as shorting 5 and 6 with the script configured to use them did shut it down. I don't get that if /a/ GPIO pin can be utilised to do a thing, then why couldn't /another/ GPIO be used to do the same thing, providing it's (apparently) unused?
From: Peter (BOUGHTONP)26 Aug 2018 20:44
To: graphitone 46 of 92
Well yeah, if GPIO is supposed to be general purpose then any unused pin should work.

It seems counter to the point of this to take all pins, only use some, and pass through ones that can't be properly used. What about sending a message to IQaudio seeing if they're willing to help?

Failing that, maybe you can de-solder the connector and replace it with several smaller ones, including a right-angle connector for the unused ports? Or I guess cables would be easier at the expense of compactness.

From: graphitone26 Aug 2018 20:55
To: Peter (BOUGHTONP) 47 of 92
That's a fair idea, I'll send them a message. There must also be some kind of inbuilt shutdown script, as there's a software power button within the Kodi interface. If I can find that, I might be able to add in the backlight commands, which would be half the battle won.
From: Peter (BOUGHTONP)26 Aug 2018 21:19
To: graphitone 48 of 92
> There must also be some kind of inbuilt shutdown script

Heh, so yeah, that's a really simple solution - that loser Xen would have pointed it out ages ago if he were here.

You can use systemd to hook into system events (like shutdown), so you can create simple service like this one with Before=shutdown.target:

[Unit]
Description=/etc/rc.local.shutdown Compatibility
Before=shutdown.target

[Service]
ExecStart=/bin/true
ExecStop=/etc/rc.local.shutdown
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

Where /etc/rc.local.shutdown is a script containing the original echo 0 > /sys/class/backlight/rpi_backlight/bl_power (prepended with #!/bin/bash line) and once you've enabled that service, any time the system is shutdown - whether via Kodi or command line or the button - it triggers the script and turns off the backlight.

From: graphitone26 Aug 2018 21:19
To: All Peter (BOUGHTONP) 49 of 92
Okaaaaay... I've created a shutdown file here:
 
Code: 
/storage/.config/shutdown.sh

And created this script, putting in the backlight command under the poweroff option.
 
Code: 
case "$1" in
  halt)
    # your commands here
    ;;
  poweroff)
    # your commands here
    ;;
  reboot)
    # your commands here
    ;;
  *)
    # your commands here
    ;;
esac

This works with the software power off, but will mean I need to flick the power switch (which'll be mounted in an under counter cupboard) to get it to turn back on. So, not ideal, but it'll work for now. :)
EDITED: 26 Aug 2018 21:20 by GRAPHITONE
From: ANT_THOMAS26 Aug 2018 21:21
To: graphitone 50 of 92
If I'm understanding what you want to do there is a pin available on the RPi to reset the board/power. Connect a button, press it, and it'll act a soft on type button by resetting the RPi from its shutdown state.
From: graphitone26 Aug 2018 21:23
To: ANT_THOMAS 51 of 92
Ah, that'd be damned useful, providing it's somewhere between 1 & 10 and isn't 5!
From: ANT_THOMAS26 Aug 2018 21:24
To: graphitone 52 of 92
It's totally separate. It's called "run". Different location on different versions of raspberry pis but the newer ones have it.
From: graphitone26 Aug 2018 21:27
To: ANT_THOMAS 53 of 92
Found this which seems useful, I'll have a read before bed:

https://www.raspberrypi.org/forums/viewtopic.php?t=218600
 
From: ANT_THOMAS26 Aug 2018 21:31
To: graphitone 54 of 92
That's the one. When you momentarily connect Run to Ground it resets.
On previous models the pin next to Run was also ground, so you could just use those two pins. But on the latest 3B+ (?) the pin next to Run isn't ground, so you need to use a ground on the GPIO header. Which can be any, even if it's used by something else. Ground is ground.
From: graphitone26 Aug 2018 21:33
To: ANT_THOMAS 55 of 92
Brilliant. Yeah, the GPIO ground advice is on that site too.

Now I just need a 2 pin header and some soldering skills. :/
EDITED: 26 Aug 2018 21:33 by GRAPHITONE
From: ANT_THOMAS26 Aug 2018 21:37
To: graphitone 56 of 92
It's a doddle. But understandably daunting if you don't solder much. You can probably buy a big bag of headers on ebay for 99p.

Watch a few video tutorials on soldering headers. Bluetack is useful.
From: graphitone27 Aug 2018 15:36
To: ANT_THOMAS 57 of 92
Ok, I dug out an old circuit board from a long unused modem and found a set of headers on there that I could remove. I watched a lot of youtube videos on soldering and unsoldering and have discovered that many americans can't pronounce solder. Preferring to leave the 'l' out and making it 'sodder'. :|


Anywho, after a bit of practicing, I unsoldered them, took two out and soldered them onto the Pi. It's not the neatest or straightest, but they're in.

The circuit does work, I've just got to test it now with the whole thing assembled. :)

Edit - Yay, the software switch powers it off and the push switch powers it back on. It's working, but there's room for improvement, but that can all be done later, for now it's something I can give to the builders and say stick this in the wall for me.

I wonder if you can script anything on that Run pin... If that can be used to shutdown/sleep the Pi, that'd be ideal.
EDITED: 27 Aug 2018 15:43 by GRAPHITONE
From: graphitone27 Aug 2018 21:08
To: ALL58 of 92
Thanks for your help with getting this far PB and Ant. Tonight's job is getting the momentary switch hooked up. It's got 4 poles and didn't come with a wiring diagram, so a little more experimentation is taking place. :)
From: graphitone 8 Sep 2018 21:47
To: ALL59 of 92
The kitchen project is continuing, albeit slowly, which is why I've not updated this for a while. If anyone's interested in seeing what it's like let me know and I'll post a link to a google drive file with pictures of how the whole thing's going, but although the Pi is working it won't be installed for a good few days as yet.
From: CHYRON (DSMITHHFX) 9 Sep 2018 12:11
To: graphitone 60 of 92
I want to see.
From: graphitone 9 Sep 2018 14:48
To: CHYRON (DSMITHHFX) 61 of 92
Alrighty then. Concept art at the top of the folder, which is what it all should look like by the end of this week. :)

linky
 
EDITED: 9 Sep 2018 14:50 by GRAPHITONE