-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed broken getLEDstate #14
Conversation
The way usbFunctionSetup was implemented did not get the led state correctly.
@asfyra, or @ladyada, or @frank26080115, or someone else, can you please explain to me how/when the LED state is read? In testing, it looks like it may only be read when printing chars to the computer over USB. Is that correct? Also, I'd like to send data from the PC to the mcu to update parameters in the mcu's EEPROM. Is this possible? I think it is, but don't know where to start. I'd like to see that functionality added to this library. I'm pretty sure the HID protocol being used here supports it, it would just need to be implemented in this library. Perhaps to someone experienced in the USB HID protocol it may even be trivial... |
getLEDstate() should be called by mcu at any time your code needs to know the status of the keyboard leds. It returns the status of Caps Lock, Num Lock and Scroll Lock. So if you press caps lock on your PC keyboard and then call getLEDstate() you will get a bit wise value with the specific bit set. Your second question, is not clear for me either. Although i've struggled a lot trying to find a way to send data from PC to mcu, having set mcu as Combo, or Keyboard device, i didn't find a way... So i switched to TrinketFakeUsbSerial where i am able to send and receive data with no problem. Alex |
Alex, thanks for the quick response! When using TrinketFakeUsbSerial is there any way to still be able to emulate a keyboard or mouse to provide inputs into the computer? In other words, my goal is to be able to emulate a keyboard/mouse and still receive inputs to the ATtiny85 from the PC. I'm so interested in this functionality that I even wrote a custom code to literally blink data to the mcu from the PCU using the CapsLock, NumLock, and ScrollLock keys. I wrote a Python script to control their states, and I wrote an interpreter on the mcu to read in the bit-banged data. It did work, but horribly slow, as it turns out a mandatory debounce of 500ms+ exists on PC's Caps, Num, and Scroll lock key states, so I was unable to quickly blink the LED states to send data faster. It was flaky too, so not a practical way of doing things. Also, it looks like "Ray" has made an alternative to TrinketFakeUsbSerial, but I'm not sure it's going to do what I want either. Ray's alternative: https://learn.adafruit.com/trinket-fake-usb-serial/usb-hid-terminal-alternative |
To give you an example of just how slow my technique is, due to the 500ms debounce delay enforced on the LED states by computers, it takes me ~18.77 min to send 512 bytes of data. I used 2 of the LED states as bit states (data lines), and 1 as a clock. 18.77 min is a bit too slow. :) |
The way usbFunctionSetup was implemented did not get the led state correct.