HackerShackOfficial / Smart-Bartender

🍻
MIT License
147 stars 96 forks source link

Problems with buttons #2

Open MrTwinkleMoon opened 6 years ago

MrTwinkleMoon commented 6 years ago

So after testing and researching I found out that there's a problem with the gpio pins detecting false Inputs with momentary switch buttons which leads them into a state of floating and therefore not beeing able to correctly detect the input gut rather detect multiple ones. After changing the code in a way that it doesn't recognise these false inputs I manage to get it to work so that it only pours one at a time but now I got the problem that after some pours the system doesn't recognise any inputs anymore where could be the problem that something like that happens? I will add a link to the changed code.

The link to the Raspberry forum where I also stated my problem: https://www.raspberrypi.org/forums/viewtopic.php?f=37&t=214560&p=1320522#p1320522

atainter commented 6 years ago

Did you disable the interrupts using this code?

    def startInterrupts(self):
        GPIO.add_event_detect(self.btn1Pin, GPIO.FALLING, callback=self.left_btn, bouncetime=LEFT_PIN_BOUNCE)  
        GPIO.add_event_detect(self.btn2Pin, GPIO.FALLING, callback=self.right_btn, bouncetime=RIGHT_PIN_BOUNCE)  

    def stopInterrupts(self):
        GPIO.remove_event_detect(self.btn1Pin)
        GPIO.remove_event_detect(self.btn2Pin)

I also had the same issue, but I think it was because the program crashed. I didn't have time to solve the root problem, so I disabled that code and used something else.

MrTwinkleMoon commented 6 years ago

Also tried that code with the same result, crashing the program. Wasn't sure if it only didn't register any inputs anymore or the program just crashed.

hoofta commented 6 years ago

I am also having issues with the multiple drink pours. Mine seems to be random though. Sometimes it will get in an endless loop where other times it will only pour 2-3.

I will try disabling the interrupts using the above code when I get home.

MrTwinkleMoon commented 6 years ago

I think I found a solution to the problem of the program crashing when you include remove_event_detect. Sadly I'm not so into coding and don't really know how to correctly change the code but here's the side with the solution if there's someone able to include it: http://schlierf.info/raspberry/pi/gpio/python/2016/04/15/RPi.GPIO_SegFault.html