# Untitled - By: admin - 周四 9月 14 2023
import sensor, image, time,pyb,struct
from pyb import UART
from pyb import Timer
uart = pyb.UART(3)
uart.init(115200, bits=8, parity=None, stop=1,read_buf_len=500)
#a=0
#output_str = 'a'
def sending_data(x,y):
data=struct.pack("<bbhhb",
0xAA,
0x55,
int(x),
int(y),
0xCC)
uart.write(data)
def tick(timer):
# global uart
# global output_str
# uart.write(output_str)
sending_data(x,y)
tim = Timer(2, freq=2) # create a timer object using timer 2 - trigger at 1Hz
tim.callback(tick) # set the callback to our tick function
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)
clock = time.clock()
m=0
n=0
while(True):
clock.tick()
img = sensor.snapshot()
print(clock.fps())
sending_data(m,n)
m=m+1
n=n+1请问这段代码如何改成中断定时发送
https://forum.singtown.com/topic/10462/%E5%A6%82%E4%BD%95%E5%AE%9A%E6%97%B6500%E6%AF%AB%E7%A7%92%E4%B8%B2%E5%8F%A3%E5%8F%91%E9%80%81%E6%95%B0%E6%8D%AE/4