12 Nov 2020, 15:48

@MisterAngus le hat wm8960 utilise l'i2c et bien sur ... PIN56PUSH utilise une pin utilsée par l'I2C, il lya donc conflit. Le seul moyen pour l'instant de régler le soucis est de modifier les scripts de gestion du bouton. Mais à la prochaine mise à jour il faudra refaire la manip.

Bouton ON/Off
Pour le bouton on/off tout est déjà prévu dans Recalbox : https://github.com/recalbox/recalbox-os/wiki/Ajouter-un-bouton-on-off-a-votre-recalbox-(FR)

cependant cela utilise les pin 5 et 6 qui sont utilisées par le module wm8960.

Il faut donc décaler les pins utilisées à 29 et 30, (GPIO5 et masse) (cf. le brochage du GPIO http://www.pinout.xyz )

le script est lancé par le fichier S92switch qui utilise le fichier : /recalbox/scripts/powerswitch.sh. Ce dernier définit des fonctions à utiliser en fonction de la méthode choisie dans le fichier recalbox.conf :

# ------------ A - System Options ----------- #
#    Uncomment the system.power.switch you use
;system.power.switch=ATX_RASPI_R2_6      # http://lowpowerlab.com/atxraspi/#installation
;system.power.switch=MAUSBERRY           # http://mausberry-circuits.myshopify.com/pages/setup
;system.power.switch=REMOTEPIBOARD_2003  # http://www.msldigital.com/pages/support-for-remotepi-board-2013
;system.power.switch=REMOTEPIBOARD_2005  # http://www.msldigital.com/pages/support-for-remotepi-board-plus-2015
;system.power.switch=WITTYPI             # http://www.uugear.com/witty-pi-realtime-clock-power-management-for-raspberry-pi
;system.power.switch=PIN56ONOFF          # https://github.com/recalbox/recalbox-os/wiki/Add-a-start-stop-button-to-your-recalbox-(EN)
system.power.switch=PIN56PUSH           # https://github.com/recalbox/recalbox-os/wiki/Add-a-start-stop-button-to-your-recalbox-(EN)
;system.power.switch=PIN356ONOFFRESET    # https://github.com/recalbox/recalbox-os/wiki/Add-a-start-stop-button-to-your-recalbox-(EN)
;system.power.switch=PIN356PUSHRESET     # https://github.com/recalbox/recalbox-os/wiki/Add-a-start-stop-button-to-your-recalbox-(EN)

Nous allons ici choisir la méthode system.power.switch=PIN56PUSH car on utilise une bouton poussoir temporaire.

les fonctions sont les suivantes dans le script :

pin56_start()
{
    mode=$1                 
    python /recalbox/scripts/rpi-pin56-power.py -m "$mode" &
    pid=$!
    echo "$pid" > /tmp/rpi-pin56-power.pid
    wait "$pid"
}
pin56_stop()
{
    if [[ -f /tmp/rpi-pin56-power.pid ]]; then
        kill `cat /tmp/rpi-pin56-power.pid`
    fi
}

La fonction utilise le script rpi-pin56-power.py qu'il va nous falloir modifier comme suit pour utiliser les nouveau GPIO :

import RPi.GPIO as GPIO
import os
import argpa**e
 
pa**er = argpa**e.ArgumentPa**er(description='power manager')
pa**er.add_argument("-m", help="mode onoff or push", type=str, required=True)
args = pa**er.pa**e_args()
 
mode = args.m
 
GPIO.setmode(GPIO.BCM)
# GPIO on pin 29 is the GPIO 5 in BCM mode
GPIO.setup(5, GPIO.IN, pull_up_down=GPIO.PUD_UP)
 
def shutdown():
  os.system("shutdown -h now")
 
try:
  if mode == "onoff" :
    GPIO.wait_for_edge(5, GPIO.RISING)
    shutdown()
  elif mode == "push":
    GPIO.wait_for_edge(5, GPIO.FALLING)
    shutdown()
  else:
    print("Unrecognized mode")
except KeyboardInterrupt:
    print ""
 
finally:
    print "cleaning up gpio"
    GPIO.cleanup()

la fonction On/Off est cablée sur les pin 29 et 30.