1
0
mirror of https://github.com/xtacocorex/CHIP_IO synced 2025-07-19 20:33:21 +00:00

Readme updates for callbacks to close #49

This commit is contained in:
Robert Wolterman
2017-01-08 20:45:16 +00:00
parent 6972f352ae
commit 5723bf15b3

View File

@ -206,7 +206,21 @@ Detecting events::
if GPIO.event_detected("XIO-P0"):
print "event detected!"
CHIP_IO can also handle adding callback functions on any pin that supports edge detection.
CHIP_IO can also handle adding callback functions on any pin that supports edge detection.::
def mycallback(channel):
print("we hit the edge we want")
GPIO.setup("GPIO3", GPIO.IN)
# Add Callback: Falling Edge
GPIO.add_event_callback("GPIO3", GPIO.FALLING, mycallback)
# Add Callback: Rising Edge
GPIO.add_event_callback("GPIO3", GPIO.RISING, mycallback)
# Add Callback: Both Edges
GPIO.add_event_callback("GPIO3", GPIO.BOTH, mycallback)
# Remove callback
GPIO.remove_event_detect("GPIO3")
**GPIO Cleanup**