定时发送数组的问题!
-
# 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
请问这段代码如何改成中断定时发送
-