This is my complete code, that does not work as expected. The issue is if
f_trigger def while loop runs, then
f_reset is deaf - not listening anymore and not triggered. therefore
alarm_cancel is never turned to True. Is this something documented, that if loop runs in one callback function, then another callback is ignored?
import RPi.GPIO as GPIO GPIO.setmode(GPIO.BCM) _gpin = 11 _gpin_reset = 12 alarm_cancel = False def f_trigger(channel): global alarm_cancel while alarm_cancel == False: print('alarm cancel status: %s' % (alarm_cancel)) time.sleep(.3) alarm_cancel = False def f_reset(channel): global alarm_cancel print('f_reset called') alarm_cancel = True # Define INPUTs GPIO.setup( _gpin, GPIO.IN, pull_up_down=GPIO.PUD_UP ) # input #1 # Trigger #1 GPIO.add_event_detect( _gpin, GPIO.BOTH, callback=f_trigger, bouncetime=100 ) # Define INPUTs GPIO.setup( _gpin_reset, GPIO.IN, pull_up_down=GPIO.PUD_UP ) # input #2 # Trigger #2 GPIO.add_event_detect( _gpin_reset, GPIO.BOTH, callback=f_reset, bouncetime=100 ) while True: print('main thread loop running') time.sleep(60)