Could someone give me directions, advices or examples on following;
I have created a Python program that is counting pulses from inputs and showing it to user via Tkinter GUI. Pulses are 1< sec long. The pulses should be increasing the same global counter.
It is working for me now, however, the device is missing pulses even when I'm using only one input. At the moment I am (atleast I think so) running the counter functions in another thread in parallel to main thread.
When I try to read 5 inputs for same counter, I just use the GPIOZERO when_pressed function, which calls the function that increments the counter. Below you see what I have running in the parallel thread (readbutton() function is started in parallel thread)
Code: Select all
def readbutton():
def increment():
global counter
if is_transfer == False:
counter = counter+1
print(counter)
else:
pass
while True:
nappi.when_pressed = increment
nappi2.when_pressed = increment
nappi3.when_pressed = increment
nappi4.when_pressed = increment
nappi5.when_pressed = incrementWhen I follow the counter value from GUI or terminal, the counter sometimes freezes - I mean, that it doesnt count for certain button push even if I hold the button for a while. But after I release button and press it again, it starts counting again.
Anyt tips what to look for, what would be the correct solution to read 5 simultaneous inputs to same counter? If you have a example I would be glad. This is just part of bigger code, but very important to get it straight.