Menu

#33 add_event_detect edge as argument to callback function

Accepted
None
Medium
Enhancement
2016-05-15
2013-04-07
Anonymous
No

Originally created by: timpur...@gmail.com
Originally owned by: btcros...@googlemail.com

When using add_event_detect function to detect pin state changes, it would be nice if edge comes as argument to callback function like this:

def my_cb_function(gpio, edge):
  if edge == GPIO.FALLING:
    print "Falling edge"

GPIO.add_event_detect(pin_number, GPIO.BOTH, callback=my_cb_function)

Now I have to check pin state in my callback function.

Discussion

  • Anonymous

    Anonymous - 2013-04-22

    Originally posted by: btcros...@googlemail.com

    (No comment was entered for this change.)

    Labels: -Type-Defect Type-Enhancement
    Owner: btcros...@googlemail.com

     
  • Anonymous

    Anonymous - 2013-08-19

    Originally posted by: patr...@eldwick.org.uk

    Maybe the argument passing could be even more general. For instance if you want the callback function to do something useful (rather than just print something) then it would be nice to be able to pass a pointer to some object to be updated (otherwise only way seems to be to have globals). You could do worse than the threading.Tread system i.e.

    GPIO.add_event_detect(pin, GPIO.BOTH, my_func, args=(a, b ,c))

     

    Last edit: Anonymous 2017-11-11
  • Ben Croston

    Ben Croston - 2016-02-09
    • Description has changed:

    Diff:

    
    
    • status: New --> Accepted
    • assigned_to: Ben Croston
     

Log in to post a comment.

Auth0 Logo