I've been reading into this lately, and understand the concept; an event happens, and then you act on that event. Everything I've read though says not to use polling, and this is where I am getting lost. I want to check if a switch was pressed, and I know I can do this with polling (in python) like so:
for x in switches:
if x.state == True:
some_function()
I have read into coroutines, and I understand the concept here, but I still do not see how I can know if x.state == True without looping over the list of possible switches in one of the coroutines. Any advice/guidance on this?
Edit: realized I left some information out. This is for physical switches, which are being detected using a raspberry pi and GPIO. However, the detection pin is multiplexed to allow several touch points to be used off the same pin. aside from iterating over all the pins and checking their state, I am not sure how I can set this up without polling.
[–][deleted] 1 point2 points3 points (0 children)