class ExtInt – configure I/O pins to interrupt on external events
“There are a total of 22 interrupt lines. 16 of these can come from GPIO pins and the remaining 6 are from internal sources.”
my code :
# Hello World Example # # Welcome to the OpenMV IDE! Click on the green run arrow button below to run the script! import sensor, image, time #import time from pyb import Pin, ExtInt from pyb import UART from pyb import LED red_led = LED(1) green_led = LED(2) blue_led = LED(3) ir_led = LED(4) sensor.reset() # Reset and initialize the sensor. sensor.set_pixformat(sensor.GRAYSCALE) # Set pixel format to RGB565 (or GRAYSCALE) sensor.set_framesize(sensor.VGA) # Set frame size to QVGA (320x240) sensor.skip_frames(time = 2000) # Wait for settings take effect. clock = time.clock() # Create a clock object to track the FPS. uart = UART(3, 19200) buf=66 data = bytearray(10) # create a buffer def print_X1(line): red_led.toggle()#print("X1 is pressed") print("X1 is pressed") ext = ExtInt(Pin('P5'), ExtInt.IRQ_FALLING, Pin.PULL_NONE, print_X1) ext.enable() while(True): clock.tick() # Update the FPS clock. img = sensor.snapshot() # Take a picture and return the image. img.draw_rectangle((100,100,100,100),128)#设置坐标(10,10)的像素点为红色(255,0,0) print(clock.fps()) # Note: OpenMV Cam runs about half as fast when connected # to the IDE. The FPS should increase once disconnected.
but when I send “a”,I saw 3 lines print(“X1 is pressed”) on IDE Serial Terminal.
So I think my “ExtInt” codes do not work as UART interrupt.