logo

定时器调用出现报错,IDE获取的画面停止,模块与电脑断开

2019-04-02 15:31
L
clgd

之前发现这个问题,但是没得到解决


import sensor, image, time
from pyb import Pin, Timer

sensor.reset()                      # Reset and initialize the sensor.
sensor.set_pixformat(sensor.RGB565) # Set pixel format to RGB565 (or GRAYSCALE)
sensor.set_framesize(sensor.QVGA)   # Set frame size to QVGA (320x240)
sensor.skip_frames(time = 2000)     # Wait for settings take effect.

RUN = LED(4)
clock = time.clock()                # Create a clock object to track the FPS.
def tick(timer):            # we will receive the timer object when being called
    RUN.toggle()
    
tim = Timer(4, freq=1)      # create a timer object using timer 4 - trigger at 1Hz
tim.callback(tick)          # set the callback to our tick function


while(True):
    img = sensor.snapshot()         # Take a picture and return the image.
                                    # to the IDE. The FPS should increase once disconnected.
2019-04-03 12:54
I
网红小智智 星瞳科技
65c88b09-4ab1-48d3-91c4-1f29834c7056.png

LED未定义。