Just got a Raspberry Pi kit and started tinkering with it. I have the following interrupt in place:
GPIO.add_event_detect(23, GPIO.FALLING, callback=partial(sensor1, LastPour1, PourCounter1)
and the definition of the method is as follows:
def sensor1(LastPour1, Pourcounter1):
yet when I trip the event, I get:
TypeError: sensor1() takex exactly 2 arguments (3 given)
please enlighten me! here is most of the relevant code
# GPIO 23 set up as input. It is pulled up to stop false signals
GPIO.setup(23, GPIO.IN, pull_up_down=GPIO.PUD_UP)
VOL_PER_TICK = 5
PourCounter1 = 0
PourCounter2 = 0
LastPour1 = time.time()
LastPour2 = time.time()
Vol1 = 0
Vol2 = 0
Beer1 = ""
Beer2 = ""
workfile = 'beer_data.txt'
def sensor1(LastPour1, PourCounter1):
"sensor 1 tripped"
if time.time() - LastPour1 < 5:
PourCounter1 = PourCounter1 + 1
else:
print "NEW POUR\n"
PourCounter1 = 1
LastPour1 = time.time()
GPIO.output(19, True)
time.sleep(0.05)
GPIO.output(19, False)
GPIO.add_event_detect(23, GPIO.FALLING, callback=partial(sensor1, LastPour1, PourCounter1))