Hey, im new to python.
Im using python3 with raspberrypi3 and GPIO. i have this code which supposed to iterate on list of lists :
#json file goes to python as s.settings
flagInPin value ( which works) but i need it to have the flagInService to. because it will send me the last value which not match the pin that was activated, only the last value the loop went through, and i cannot send GPIO.add_event_detect with another value.
Any ideas?
I just want function to know that flagInPin has to match with flagInService that it comes from the same list.
Thanks.
Im using python3 with raspberrypi3 and GPIO. i have this code which supposed to iterate on list of lists :
#json file goes to python as s.settings
"gpio": [ { "pin":21, "type": "input", "services": ["gps_mon"], "status": false }, { "pin": 27, "type": "input", "services": ["ntp_mon"], "status": false }]And this is the code :
serviceCallbackList = s.settings["watchdog"]["services"] #gets all watchdog services def button_callback(flagInPin): s.print_info("Button was pushed from pin", flagInPin) for item in serviceCallbackList: # checks if the services i set in the GPIO list is if item in flagInService: # in the watchdog services and delete the key if so. del serviceCallbackList[flagInService] for n in s.setting["gpio"]: try: if n["type"] == "input": flagInPin = n["pin"] flagInService = n["services"] GPIO.setup(flagInPin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) GPIO.add_event_detect(flagInPin, GPIO.RISING, callback=button_callback) except Exception as e: print("No Input settings", e)My problem is that "GPIO.add_event_detect" has to send to button_callback() function the
flagInPin value ( which works) but i need it to have the flagInService to. because it will send me the last value which not match the pin that was activated, only the last value the loop went through, and i cannot send GPIO.add_event_detect with another value.
Any ideas?
I just want function to know that flagInPin has to match with flagInService that it comes from the same list.
Thanks.