01-05-2021, 09:22 AM
(01-04-2021, 08:37 AM)JuanJB Wrote: In fact I'm exploring this line just now. The code is simple so it should be easy to translate it using Phyton based GPIO library.
Hi,
I have flashed a new Moode_R6.7_RaspDacMini image downloaded from https://mega.nz/file/gBpBCapQ#yagnsjvpH0...bhXZLuEUio
As python3 is installed here, I have “translated” the power management scripts into python. My setup is as follows:
1.- dtoverlays for GPIO17 and GPIO22 included in /boot/config.txt
2.- softshutdown.py launched from /var/local/www/comandw/restart.sh on “poweroff”
3.- softreboot.py launched from /var/local/www/comandw/restart.sh on “restart”. This was not used previously but it allows to make SPC-II board to react (via GPIO4) also to a restart from moode UI.
4.- sds.py is finally not used (and not tested also). I think that it is not needed.
Everything works well with this setup, I think. I have e-mail also to Audiophonics. They told me they are looking for a solution, hopefully in the near future. Maybe mine could help.
Please see also https://github.com/audiophonics/Raspberr...management
Here you have the scripts:
sds.py (not used in my setup, as I said before)
Code:
#!/usr/bin/python3
import os
import time
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(4, GPIO.OUT)
GPIO.output(4,GPIO.LOW)
GPIO.setup(17, GPIO.IN)
GPIO.setup(22, GPIO.OUT)
GPIO.output(22,GPIO.LOW)
while True:
if GPIO.input(17) == 1:
print ("ShutDown order received, RaspBerry pi will now enter in standby mode...")
os.system ('sudo shutdown -h -P now')
break
time.sleep(0.25)
softshutdown.py
Code:
#!/usr/bin/python3
# Shutdown detection script
# Script to set GPIO 4 High for 1sec
import os
import time
import RPi.GPIO as GPIO
print ("Setting pin GPIO4 High")
GPIO.setmode(GPIO.BCM)
GPIO.setup(4, GPIO.OUT)
GPIO.output(4,GPIO.HIGH)
time.sleep(1)
print ("Setting pin GPIO4 Low")
GPIO.output(4,GPIO.LOW)
print ("RaspberryPi shutdown")
os.system ('sudo shutdown -h -P now')
softreboot.py
Code:
#!/usr/bin/python3
# Reboot detection script
# Script to set GPIO 4 High and Reboot
# Reboot blink will stop after Boot OK return
import os
import time
import RPi.GPIO as GPIO
print ("Setting pin GPIO4 High")
GPIO.setmode(GPIO.BCM)
GPIO.setup(4, GPIO.OUT)
GPIO.output(4,GPIO.HIGH)
print ("RaspberryPi Reboot")
os.system ('sudo reboot')
Best regards
Juan