I have a main while True loop which looks like this:
Code: Select all
sw = pyb.Switch()
sw_state = 1
def toggle():
global sw_state
if sw_state == 0:
sw_state = 1
else:
sw_state = 0
sw.callback(toggle)
def main():
while sw_state:
#main code....
pyb.delay(100)
main()
Which brings me to my following problem. I'm trying to display the state of a rotary encoder which uses two ExtInts:
Code: Select all
self.Bint = pyb.ExtInt(self.B,pyb.ExtInt.IRQ_RISING_FALLING,pyb.Pin.PULL_UP,self.callback)
self.Aint = pyb.ExtInt(self.A,pyb.ExtInt.IRQ_RISING_FALLING,pyb.Pin.PULL_UP,self.callback)
This works fine, until I add the toggle callback! As soon as I do that, the rotary fails to get the necessary interrupts and doesn't update properly.