adafruit / Adafruit_CircuitPython_HID

USB Human Interface Device drivers.
MIT License
373 stars 105 forks source link

CAPSLOCK LED wont work #68

Closed Jens1985 closed 3 years ago

Jens1985 commented 3 years ago

My Code:

import usb_hid
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS
from adafruit_hid.keycode import Keycode

keyboard = Keyboard(usb_hid.devices)
keyboard_layout = KeyboardLayoutUS(keyboard)  # We're in the US :)

print(keyboard.led_on(0x02))

The Ouput:

Traceback (most recent call last):
  File "code.py", line 14, in <module>
AttributeError: 'Keyboard' object has no attribute 'led_on'

I think Keyboard has an attribute for led_on.

dhalbert commented 3 years ago

If you get that error, you're probably using an older version of the library. led_on()was added in 4.2.0. Update to the latest version.

Jens1985 commented 3 years ago

I am using adafruit-circuitpython-hid-6.x-mpy-5.0.0.zip on Adafruit CircuitPython 6.2.0 on 2021-04-05; Adafruit NeoPixel Trinkey M0 with samd21e18

dhalbert commented 3 years ago

Ah. The NeoPixel Trinkey has HID frozen in, but the version frozen in is older and does not have led_on(). This will be fixed in 6.3.0, but for now, you can put the latest adafruit_hid in / instead of /lib, and it will override using the frozen library.

>>> import sys
>>> sys.path
['', '/', '.frozen', '/lib']

.frozen comes before /lib, but after /.

Jens1985 commented 3 years ago

Thank you. It work now :)