jobin-sun / raspberry-gpio-python

Automatically exported from code.google.com/p/raspberry-gpio-python
MIT License
0 stars 0 forks source link

add_event_detect edge as argument to callback function #33

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
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.

Original issue reported on code.google.com by timpur...@gmail.com on 7 Apr 2013 at 8:58

GoogleCodeExporter commented 9 years ago

Original comment by btcros...@googlemail.com on 22 Apr 2013 at 8:22

GoogleCodeExporter commented 9 years ago
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))

Original comment by paddyww...@gmail.com on 19 Aug 2013 at 5:11

GoogleCodeExporter commented 9 years ago
You said in a forum post that you planned to implement this, did that ever 
happen?

Original comment by jam...@brandwatch.com on 9 Mar 2015 at 8:51