mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
fully disable gpio debounce if required
This commit is contained in:
parent
52dcfdbd97
commit
791321f1e9
@ -107,6 +107,7 @@ if len(sys.argv) > 2:
|
|||||||
#print("Initialised pin "+str(pin)+" to IN")
|
#print("Initialised pin "+str(pin)+" to IN")
|
||||||
bounce = float(sys.argv[4])
|
bounce = float(sys.argv[4])
|
||||||
def handle_callback(chan):
|
def handle_callback(chan):
|
||||||
|
if bounce > 0:
|
||||||
sleep(bounce/1000.0)
|
sleep(bounce/1000.0)
|
||||||
print(GPIO.input(chan))
|
print(GPIO.input(chan))
|
||||||
|
|
||||||
@ -118,7 +119,10 @@ if len(sys.argv) > 2:
|
|||||||
GPIO.setup(pin,GPIO.IN)
|
GPIO.setup(pin,GPIO.IN)
|
||||||
|
|
||||||
print(GPIO.input(pin))
|
print(GPIO.input(pin))
|
||||||
|
if bounce > 0:
|
||||||
GPIO.add_event_detect(pin, GPIO.BOTH, callback=handle_callback, bouncetime=int(bounce))
|
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:
|
while True:
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user