import sensor, image, time, array, pyb, omv
from pyb import LED
from pyb import CAN
sensor.reset()
sensor.set_pixformat(sensor.RGB565) # grayscale is faster
sensor.set_framesize(sensor.QQVGA)
sensor.skip_frames(time = 1000)
clock = time.clock()
can = CAN(2, CAN.NORMAL, baudrate=125_000, sample_point=75)
can.restart()
FLAG_Work = 100
red_led = LED(1)
green_led = LED(2)
blue_led = LED(3)
ir_led = LED(4)
i=0
int_array1 = array.array(‘i’, [1, 2, 3])
int_array2 = array.array(‘i’, [1, 2, 3])
def cb0(bus, reason):
print(‘cb0’)
if reason == 0:
print(‘pending’)
FLAG_Work = 200
if reason == 1:
FLAG_Work = 200
print(‘full’)
if reason == 2:
print(‘overflow’)
FLAG_Work = 200
can.setfilter(0, CAN.RANGE, 0, (10, 30))
can.rxcallback(0, cb0)
while(True):
clock.tick()
img = sensor.snapshot()
print(can.rxcallback(0, fun))
#can.rxcallback(0, cb0)
if FLAG_Work == 100:
for c in img.find_circles(threshold = 3400, x_margin = 5, y_margin = 10, r_margin = 10, r_min = 6, r_max = 15, r_step = 2):
img.draw_circle(c.x(), c.y(), c.r(), color = (255, 0, 0))
if i < len(int_array1):
int_array1[i] = c.x()
int_array2[i] = c.y()
i=i+1
#pyb.delay(500)
else:
i = 0
#print(c)
i = 0
print(“FPS %f” % clock.fps())
My code is here but callback does not work. I think that I do something wrong but i do not know where is mistake… Please, help with this problem…