How to program (Python) and install a shut down button for your DHAP

Pubblicato il: 04 dicembre 2014
sul canale di: Joeteck
469
3

For those who want to have a shutdown button for your DHAP instead of remotely shutting it down from your radio.. You may have forgotten, and this allows you to just press a button to turn it off. Also how to add a soft reset button as well..

This could very well be "DHAP R3" for future production...

-- shutdown.py code --

DHAP/RPi Shutdown routine

import RPi.GPIO as GPIO
import time
import os

GPIO.setmode(GPIO.BCM)
GPIO.setup(25, GPIO.IN, pull_up_down = GPIO.PUD_UP)

def Shutdown(channel):
os.system("sudo shutdown -h now")

GPIO.add_event_detect(25, GPIO.FALLING, callback = Shutdown, bouncetime = 2000)
while 1:
time.sleep(1)

-- End code --

code for the rc.local file: sudo python /home/pi/scripts/shutdown.py

edit rc.local with this command: sudo nano /etc/rc.local


In questa pagina del sito puoi guardare il video online How to program (Python) and install a shut down button for your DHAP della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Joeteck 04 dicembre 2014, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 469 volte e gli è piaciuto 3 spettatori. Buona visione!