You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have re-installed everything and still each time last tap is registering the pour. So it will always come from tap 5 as I have 5 taps.
I have modified the code as I am not good with python and objects. So it's a bit ugly but it works for 5 taps. So there's something with the GPIO.add_event_detect that refers always to the last object initialized. I tried both in the docker container and running it from the PI outside the docker container.
There is still little things with the toolkit with hardcoded number of tap to 4 but that's an easy fix.
I replaced this:
for tap in self.taps: # setup all the taps. add event triggers to the opening of the taps.
By this for 5 taps. But it's not really clean and I do not know how to fix previous function.
tap=self.taps[0]
GPIO.add_event_detect(tap.get_pin(), GPIO.RISING, callback=lambda a: self.register_tap(self.taps[0]), bouncetime=20)
tap=self.taps[1]
GPIO.add_event_detect(tap.get_pin(), GPIO.RISING, callback=lambda a: self.register_tap(self.taps[1]), bouncetime=20)
tap=self.taps[2]
GPIO.add_event_detect(tap.get_pin(), GPIO.RISING, callback=lambda a: self.register_tap(self.taps[2]), bouncetime=20)
tap=self.taps[3]
GPIO.add_event_detect(tap.get_pin(), GPIO.RISING, callback=lambda a: self.register_tap(self.taps[3]), bouncetime=20)
tap=self.taps[4]
GPIO.add_event_detect(tap.get_pin(), GPIO.RISING, callback=lambda a: self.register_tap(self.taps[4]), bouncetime=20)
The text was updated successfully, but these errors were encountered:
Hello,
I have re-installed everything and still each time last tap is registering the pour. So it will always come from tap 5 as I have 5 taps.
I have modified the code as I am not good with python and objects. So it's a bit ugly but it works for 5 taps. So there's something with the GPIO.add_event_detect that refers always to the last object initialized. I tried both in the docker container and running it from the PI outside the docker container.
There is still little things with the toolkit with hardcoded number of tap to 4 but that's an easy fix.
I replaced this:
for tap in self.taps: # setup all the taps. add event triggers to the opening of the taps.
GPIO.add_event_detect(tap.get_pin(), GPIO.RISING, callback=lambda *a: self.register_tap(tap), bouncetime=20)
By this for 5 taps. But it's not really clean and I do not know how to fix previous function.
tap=self.taps[0]
GPIO.add_event_detect(tap.get_pin(), GPIO.RISING, callback=lambda a: self.register_tap(self.taps[0]), bouncetime=20)
tap=self.taps[1]
GPIO.add_event_detect(tap.get_pin(), GPIO.RISING, callback=lambda a: self.register_tap(self.taps[1]), bouncetime=20)
tap=self.taps[2]
GPIO.add_event_detect(tap.get_pin(), GPIO.RISING, callback=lambda a: self.register_tap(self.taps[2]), bouncetime=20)
tap=self.taps[3]
GPIO.add_event_detect(tap.get_pin(), GPIO.RISING, callback=lambda a: self.register_tap(self.taps[3]), bouncetime=20)
tap=self.taps[4]
GPIO.add_event_detect(tap.get_pin(), GPIO.RISING, callback=lambda a: self.register_tap(self.taps[4]), bouncetime=20)
The text was updated successfully, but these errors were encountered: