P.S. It looks like the new users like me are limited to 3 messages per post so this would be my last message for now.
P.P.S. Please see below the Python code for a RPI shutdown. CPU usage next to none. Just save this code into a whatever_name.py file and execute it. Then hold the fan shim button for 3 seconds and you will get a clean shutdown (make sure to save first whatever other work you have open…just saying ;-) ).
Off topic: I still find the Pimoroni policy of putting a 3 messages limit per post for new users pure BS so how about my own policy: one pimoroni product on my desk is one too many.
This being said, really nice chatting with you, alphanumeric!
import RPi.GPIO as GPIO
import os
button_pin = 17
hold_time = 3000 # in ms
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(button_pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
while True:
GPIO.wait_for_edge(button_pin, GPIO.FALLING)
if GPIO.wait_for_edge(button_pin, GPIO.RISING, timeout=hold_time) is None:
os.system("sudo shutdown -h now")