My problem that I can't figure out as I'm not very versed in python/gpio event aspect. I'm trying to use the event detect e.g.
GPIO.add_event_detect(7, GPIO.FALLING, callback=press, bouncetime=300)
But I also want it to detect hold time.
My old script was
Code: Select all
def press() global previoustime ontime = time.time() - previoustime if ontime > 1and ontime < 3: print "hold" elif ontime > 3: print "long hold" elif ontime > 0.01: print "click" else: print "ignore" while True: if(GPIO.input(7) == 0): ## this line I was attempting to change to GPIO.wait_for_edge(7, GPIO.FALLING) previoustime = time.time () GPIO.wait_for_edge(7, GPIO.RISING) press()