NicoHood / HID

Bring enhanced HID functions to your Arduino!
http://www.nicohood.de
MIT License
2.37k stars 409 forks source link

LED status beyond 0x07 #402

Open plainlystated opened 1 year ago

plainlystated commented 1 year ago

I'm trying to grab the "microphone muted" LED status from the HID library, but it seems like the library only supports a select few statuses out of the box: https://github.com/NicoHood/HID/issues/151

It seems like 0x21 might be the position of the LED I'm looking for. (FWIW, the laptop keyboard does have an LED for this)

I've tried messing with the three 0x07 values here and changing the signature to uint16_t here, but my c++ isn't strong and it's giving no results at all, so I've broken something...

In my searching, I've seen other people ask about this but haven't found a working example. I've seen some of your comments about it being tricky/non-standard, so not sure if there's a way to pull it off. Any guidance would be appreciated!

Thanks, Patrick

qistoph commented 3 months ago

I'm also curious to get this to work, because it would create a nice way to standardize typical status LEDs on custom keypads. My focus is on a mute toggle switch with indicator.

In my LEDs branch the library is adapted to support 16 bits of LED status. Names have been adopted from the HID Usage Tables 1.5. Also the KeyboardLed example is updated to show all 16 bits of LED information.

Attaching my Arduino Pro Micro with this sketch to my Ubuntu 24.04 laptop shows an additional LED:

# ls -alhd /sys/class/leds/input69\:\:*/
drwxr-xr-x 3 root root 0 Jul  3 21:38 /sys/class/leds/input69::capslock/
drwxr-xr-x 3 root root 0 Jul  3 21:38 /sys/class/leds/input69::compose/
drwxr-xr-x 3 root root 0 Jul  3 21:38 /sys/class/leds/input69::kana/
drwxr-xr-x 3 root root 0 Jul  3 21:38 /sys/class/leds/input69::mute/
drwxr-xr-x 3 root root 0 Jul  3 21:38 /sys/class/leds/input69::numlock/
drwxr-xr-x 3 root root 0 Jul  3 21:38 /sys/class/leds/input69::scrolllock/

Manually toggling the mute LED does trigger and show an update of the status as expected:

Linux:
# echo 1 > /sys/class/leds/input69\:\:mute/brightness 
# echo 0 > /sys/class/leds/input69\:\:mute/brightness 

Arduino:
LEDs: 0000000100000000
LEDs: 0000000000000000

Next steps (suggestions on achieving this are very welcome):