USB_HID.recv Function

Hi
Need To receive live location of mouse using USB HID in boot with Mouse mode

i successfully implemented USB HID in OpenMV3 R2.
but in mouse mode when i run function of receiver as print(Mouse.recv(2)) (Ref = class USB_HID – USB Human Interface Device (HID) — MicroPython 1.15 documentation)
I’m Getting in output as b’’ every time with delay of 5 second
can anyone please help me to get live location of mouser using recv function :exclamation: :exclamation:

My Boot File is

import pyb 
pyb.usb_mode('VCP+HID')

And Main File is

import sensor, image, time, pyb
Mouse = pyb.USB_HID()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)
clock = time.clock()

while(True):
    clock.tick()
    img = sensor.snapshot()
    print(Mouse.recv(2))

The camera is really not designed to do this at all. But, I’ll ask Ibrahim if it is possibly able to work.

That’s not how you use HID, you send the events to simulate a keyboard or a mouse, for example:

import pyb, time

hid = pyb.USB_HID()

while(True):
    # x, y and scroll
    # move 10 pixels to the right
    hid.send((0, 10, 0, 0))
    time.sleep(500)
1 Like

Hi Ibrahim,
I have the OpenMV H7 plus board, and I was trying to implement this code on it.

Every time I run it, it crashes and disconnects.
is there a way I can stop it from doing this?

Looking into the device manager, the PC doesn’t Identify the board as an HID-compliant mouse.

My eventual implementation of this is to run the absolute-translation code and modify it so it moves the mouse as the camera moves.

It’s not crashing, it’s just that you cannot do that and use the IDE.

Oh ok, that makes sense.
So, do you know if there is a way to test it (Like having the board act as a mouse HID)?

Dunno, it’s just a feature MicroPython provides. But, we didn’t design our system around it.

1 Like