adafruit / Adafruit_Blinka

Add CircuitPython hardware API and libraries to MicroPython & CPython devices
https://learn.adafruit.com/circuitpython-on-raspberrypi-linux
MIT License
453 stars 340 forks source link

Blinka's usb_hid.py with MicroPython throws ImportErrors #696

Closed evgeni-student closed 1 year ago

evgeni-student commented 1 year ago

Hello! I have the latest MicroPython 1.20.0 installed on Raspberry Pi Pico H and I want to use CircuitPython the usb_hid.py module from Adafruit_Blinka. I have PlatformDetect-3.48.0 and Adafruit Blinka 8.20.0. I have the following directories in the lib folder and a sample MicroPython and CircuitPython mixed code runs as intended. library The issue I have appears when I try to import usb_hid with the intention to use adafruit_hid.keyboard, adafruit_hid.keycode, adafruit_hid.keyboard_layout_us and adafruit_hid.consumer_control. error_msg I already seen these issues #586 and #230. I tried adding try/catch on the inner code but it just results in other errors like these: File "/lib/usb_hid.py", line 19, in ImportError: no module named 'pathlib' and ImportError: no module named 'atexit' After installing typing from Thonny's manage package interface pictured below: typing and running the code again, the following ImportError occurs: sequence_error further still when I change the import to just import typing and then wrapping the from abc import abstractmethod, abstractproperty part in try/catch I again bump into more problems like the one below: atexit_error

Thank you for your help in advance.

ladyada commented 1 year ago

the failures shouldn't be coming up but im also pretty sure the hid library wont run because micropython does not have core HID support for RP2040 - if you want to act like a keyboard you'll need to use circuitpy

evgeni-student commented 1 year ago

the failures shouldn't be coming up but im also pretty sure the hid library wont run because micropython does not have core HID support for RP2040 - if you want to act like a keyboard you'll need to use circuitpy

Thank you for your comment. Yes, when I use CircuitPython only it works, but my intention behind using MicroPython is to utilize hard interrupt handlers rather than polling a CircuitPython while loop.

makermelissa commented 1 year ago

Thank you for your comment. Yes, when I use CircuitPython only it works, but my intention behind using MicroPython is to utilize hard interrupt handlers rather than polling a CircuitPython while loop.

Looking through their documentation, it looks like the only board they added it to was the pyboard, which is also supported by Blinka.

evgeni-student commented 1 year ago

I guess I would just have to wait until MicroPython gets native HID support for RP2040. Thank you for your help.

makermelissa commented 1 year ago

You're welcome. Closing for now.