I have been working with interrupts lately.
Which pins on the PyBoard are capable of being interrupt sources? I am using X17, X18, and X19 now, which do work as interrupt sources. However, X20, X21, and X22 do not seem to work as interrupts. It is also possible that I have something configured wrong for these pins. I have a rotary encoder with switch connected to them.
Code: Select all
from pyb import ExtInt, Pin from time import sleep interrupted = False last_position = 0 position = 0 direction = 0 direction_text = "" # Setup the rotary encoder def apin_callback(line): global interrupted, apin_clicked, bpin_clicked global direction if (apin_clicked and bpin_clicked): # Rotated clockwise direction = 1 elif (apin_clicked and (not bpin_clicked)): # Rotated counter clockwise direction = -1 else: direction = 0 interrupted = True apin_clicked = True return apin_clicked = False apin_int = ExtInt("X20", ExtInt.IRQ_FALLING, Pin.PULL_UP, apin_callback) def bpin_callback(line): global interrupted, bpin_clicked interrupted = True bpin_clicked = True return bpin_clicked = False bpin_int = ExtInt("X21", ExtInt.IRQ_FALLING, Pin.PULL_UP, bpin_callback) def encoder_switch_callback(line): global interrupted, encoder_switch_pressed interrupted = True encoder_switch_pressed = True encoder_switch_pressed = False encoder_switch_int = ExtInt("X22", ExtInt.IRQ_FALLING, Pin.PULL_UP, encoder_switch_callback) # Enable interrupts apin_int.enable() bpin_int.enable() encoder_switch_int.enable()