同步操作将从 QuecPython/microPython 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
.. currentmodule:: pyb
There are a total of 22 interrupt lines. 16 of these can come from GPIO pins and the remaining 6 are from internal sources.
For lines 0 through 15, a given line can map to the corresponding line from an arbitrary port. So line 0 can map to Px0 where x is A, B, C, ... and line 1 can map to Px1 where x is A, B, C, ...
def callback(line):
print("line =", line)
Note: ExtInt will automatically configure the gpio line as an input.
extint = pyb.ExtInt(pin, pyb.ExtInt.IRQ_FALLING, pyb.Pin.PULL_UP, callback)
Now every time a falling edge is seen on the X1 pin, the callback will be called. Caution: mechanical pushbuttons have "bounce" and pushing or releasing a switch will often generate multiple edges. See: Constructors
Create an ExtInt object:
pinis the pin on which to enable the interrupt (can be a pin object or any valid pin name).modecan be one of: -ExtInt.IRQ_RISING- trigger on a rising edge; -ExtInt.IRQ_FALLING- trigger on a falling edge; -ExtInt.IRQ_RISING_FALLING- trigger on a rising or falling edge.pullcan be one of: -pyb.Pin.PULL_NONE- no pull up or down resistors; -pyb.Pin.PULL_UP- enable the pull-up resistor; -pyb.Pin.PULL_DOWN- enable the pull-down resistor.callbackis the function to call when the interrupt triggers. The callback function must accept exactly 1 argument, which is the line that triggered the interrupt.
.. classmethod:: ExtInt.regs() Dump the values of the EXTI registers.
.. method:: ExtInt.disable() Disable the interrupt associated with the ExtInt object. This could be useful for debouncing.
.. method:: ExtInt.enable() Enable a disabled interrupt.
.. method:: ExtInt.line() Return the line number that the pin is mapped to.
.. method:: ExtInt.swint() Trigger the callback from software.
.. data:: ExtInt.IRQ_FALLING interrupt on a falling edge
.. data:: ExtInt.IRQ_RISING interrupt on a rising edge
.. data:: ExtInt.IRQ_RISING_FALLING interrupt on a rising or falling edge
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。