Using a Pi 3+ in an animated display. The servos in the display are run from a 16 channel "bonnet" on the Pi. I am using RPI.GPIO to deal with GPIO issues.
What I want is for one set of instructions to run the servos until a sensor triggers a GPIO pin. Then, a second set of instructions needs to run. When that set of instructions is finished, I need to go back to the original set of instructions. This should continue ad infinitum.
So - the first set of instructions is like a holding pattern waiting for the interrupt.
I have both sets of instructions working. Am having difficulty implementing the description above.
Am using GPIO.add_event_detect(Pin, callback, debounce) to call a function that runs the second set of instructions. What I get, when the interrupt is sensed, is both sets of instructions trying to run at the same time. I think this is multi-threading which is not what I want.
Is there a way to run one set of instructions at a time and then revert back to the original ?
RPI.GPIO
and trygpiozero
.