def user_shutdown_setup(shutdown_pin):
# setup the pin to check the shutdown switch - use the internal pull down resistor
GPIO.setup(shutdown_pin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
# create a trigger for the shutdown switch
GPIO.add_event_detect(shutdown_pin, GPIO.RISING, callback=user_shutdown, bouncetime=1000)
# User has pressed shutdown button - initiate a clean shutdown
评论列表
文章目录