Basic USB HID test failing...

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Basic USB HID test failing...

Post by pythoncoder » Thu Sep 22, 2016 6:09 am

I'm a big supporter of user wikis. Alas much the content of ours is out of date and has been superseded by official documentation - it does look sad and unloved. I still think it's a good place to post links to user contributed code - easier to find than trawling the forum. I once offered to tidy it up but was discouraged - I think the plan is eventually to move it to another platform.
Peter Hinch
Index to my micropython libraries.

fpp
Posts: 64
Joined: Wed Jul 20, 2016 12:08 pm

Re: Basic USB HID test failing...

Post by fpp » Thu Sep 22, 2016 7:24 am

Thanks for the confirmation, it wasn't just a false impression then :-)

I think I'll still put up in there a summary of what I have working, thanks to the contributions of everybody in this thread, and then see if someone is willing to port it to the official docs (next to the HID mouse example seems like the logical place).

fpp
Posts: 64
Joined: Wed Jul 20, 2016 12:08 pm

Re: Basic USB HID test failing...

Post by fpp » Sat Oct 08, 2016 11:57 am

I finally got to spend some time on documenting our adventures here on the Wiki :

http://wiki.micropython.org/USB-HID-Key ... ord-dongle

Feedback is always welcome.
If anyone feels like moving this inside the official documentation (alongside the HID mouse example maybe), feel free :-)

Thanks to all,
fp

d0mbee
Posts: 2
Joined: Fri Jun 16, 2017 1:16 pm

Re: Basic USB HID test failing...

Post by d0mbee » Fri Jun 16, 2017 1:18 pm

def sendchr(char) :
if not char in kbfr.keys() : # print warning to REPL if active
print("\nUnknow char\n") ; return
# key down with modifiers
buf[2], buf[0] = kbfr[char]
kb.send(buf)
pyb.delay(10)
# key up
buf[2], buf[0] = 0x00, 0x00
kb.send(buf)
pyb.delay(10)

hello, first of all let me thank you for all your work and research on the subject, i have just one question:
why do i get a error that says that kbfr is not defined...did you define it in the kb_map.py file?
Cheers,

fpp
Posts: 64
Joined: Wed Jul 20, 2016 12:08 pm

Re: Basic USB HID test failing...

Post by fpp » Fri Jun 16, 2017 5:30 pm

Ah, well spotted, sorry for the confusion !

Yes, that dict used in sendchr is the one defined in kb_map.py, so the same name should be used.

What happened is that I use an AZERTY layout, so in the original code it was called kbdfr everywhere...

For the Wiki entry I changed it to kbmap to make it more generic... and of course I managed to miss that one occurrence :-)

d0mbee
Posts: 2
Joined: Fri Jun 16, 2017 1:16 pm

Re: Basic USB HID test failing...

Post by d0mbee » Sat Jun 17, 2017 7:32 am

[quote="fpp"]Ah, well spotted, sorry for the confusion !

Yes, that dict used in [b]sendchr[/b] is the one defined in [b]kb_map.py[/b], so the same name should be used.

What happened is that I use an AZERTY layout, so in the original code it was called [b]kbdfr[/b] everywhere...

For the Wiki entry I changed it to [b]kbmap [/b]to make it more generic... and of course I managed to miss that one occurrence :-)[/quote]

oh, ok, made the adjustments. Thanks

xiaowuyi
Posts: 5
Joined: Sat Jun 11, 2016 9:58 am

Re: Basic USB HID test failing...

Post by xiaowuyi » Mon Jul 10, 2017 3:13 pm


Post Reply