首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我找不到这个图书馆的usb_hid

我找不到这个图书馆的usb_hid
EN

Stack Overflow用户
提问于 2021-11-30 04:27:58
回答 3查看 1.4K关注 0票数 0

我正在做一个学校项目,其中包括制作一个程序,在Rasbperry野餐和一些按钮的帮助下,制作一个鼠标。但是显然我需要usb_hid库来承载我的usb,但是我找不到它。

我找了好几天这个库来安装pip,但是我哪儿都找不到

代码语言:javascript
复制
from machine import Pin 
import usb_hid  <----
import time as t 
from adafruit_hid.mouse import Mouse

pulsador_uno = Pin(3, Pin.IN, Pin.PULL_UP) #declaramos la ubicacion del pin del pulsador uno pulsador_dos = Pin(7, Pin.IN, Pin.PULL_UP)
#declaramos la ubicacion del pin del pulsador dos pulsador_tres = Pin(11, Pin.IN, Pin.PULL_UP) #declaramos la ubicacion del pin del pulsador tres

LEFT_BUTTON= 1 m = Mouse(usb_hid.devices) #creamos un objeto de mouse, para luego utilizarlo en el main() 

def main():
    if not pulsador_uno.value() or not pulsador_dos.value() or not pulsador_tres.value():
        print('Button pressed!')
        m.click(Mouse.LEFT_BUTTON)
    else: 
        print('Button not pressed!')
        t.sleep(3)

while True:
    main()

结果:

ImportError:没有名为“usb_hid”

的模块

EN

回答 3

Stack Overflow用户

发布于 2021-11-30 04:38:12

您可以尝试这个库,usb_hid是它的核心模块:https://circuitpython.readthedocs.io/en/latest/shared-bindings/usb_hid/index.html#

票数 0
EN

Stack Overflow用户

发布于 2021-12-06 11:00:38

您没有指定的精确微控制器,所以我假设您有泛型 ESP32。

上没有本地 USB支持ESP32 DEV工具包。您可以检查其他解决方案以使设备充当输入:https://github.com/Heerkog/MicroPythonBLEHID

ESP32-S2家族需要硬件,但我不确定Micropython方面的情况。

票数 0
EN

Stack Overflow用户

发布于 2022-01-11 23:00:43

您需要安装电路-python才能使用hid库。你可以在这里下载https://circuitpython.org/board/raspberry_pi_pico/,一旦你下载了uf2文件,当你把它插到你的电脑上时,按住pico上的"bootsel“按钮。它应该是一个大容量的存储设备。然后,只需将uf2文件拖到pico上,就可以将其弹出。在不按“引导程序”按钮的情况下,再拔下你的pico,并在文件资源管理器中寻找一个名为"CIRCUITPY“的设备。在这个文件中有另一个名为"lib“的文件。你必须把你的库文件放在这里。您可以在这里下载adafruit_hid库,https://github.com/adafruit/Adafruit_CircuitPython_HID将"adafruit_hid“库复制到"lib”,然后再次尝试运行代码。如果您的代码在micropython下被命名为"main.py“(所以我会自动启动),那么如果您不想手动执行python脚本,就必须将文件重命名为code.py。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70164310

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档