Skip to content

Commit

Permalink
Readme updates for callbacks to close #49
Browse files Browse the repository at this point in the history
  • Loading branch information
xtacocorex committed Jan 8, 2017
1 parent 6972f35 commit 5723bf1
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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**

Expand Down

0 comments on commit 5723bf1

Please sign in to comment.