From 791321f1e93a9cb3e9080d3a3071a73dd7596514 Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Wed, 10 Jul 2019 09:52:09 +0100 Subject: [PATCH] fully disable gpio debounce if required --- hardware/PiGpio/nrgpio.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hardware/PiGpio/nrgpio.py b/hardware/PiGpio/nrgpio.py index 7908ca11..26bb595a 100755 --- a/hardware/PiGpio/nrgpio.py +++ b/hardware/PiGpio/nrgpio.py @@ -107,7 +107,8 @@ if len(sys.argv) > 2: #print("Initialised pin "+str(pin)+" to IN") bounce = float(sys.argv[4]) def handle_callback(chan): - sleep(bounce/1000.0) + if bounce > 0: + sleep(bounce/1000.0) print(GPIO.input(chan)) if sys.argv[3].lower() == "up": @@ -118,7 +119,10 @@ if len(sys.argv) > 2: GPIO.setup(pin,GPIO.IN) print(GPIO.input(pin)) - GPIO.add_event_detect(pin, GPIO.BOTH, callback=handle_callback, bouncetime=int(bounce)) + if bounce > 0: + GPIO.add_event_detect(pin, GPIO.BOTH, callback=handle_callback, bouncetime=int(bounce)) + else : + GPIO.add_event_detect(pin, GPIO.BOTH, callback=handle_callback) while True: try: