Is a Python event polled or interrupt driven?

Chris Green cl at isbd.net
Thu Oct 12 05:21:07 EDT 2023


In the following code is the event polled by the Python process
running the code or is there something cleverer going on such that
Python sees an interrupt when the input goes high (or low)?



    import Adafruit_BBIO.GPIO as GPIO

    Pin = "P8_8"
    GPIO.setup(Pin, GPIO.IN)    # set GPIO25 as input (button)

    def my_callback(channel):
        if GPIO.input(Pin):
            print "Rising edge detected on 25"
        else:                  # if port 25 != 1
            print "Falling edge detected on 25"

    GPIO.add_event_detect(Pin, GPIO.BOTH, my_callback, 1)


-- 
Chris Green
·


More information about the Python-list mailing list