Close

Digikeyboard with LEDs

danjovicdanjovic wrote 03/08/2020 at 20:25 • 1 min read • Like

I have just added support for LED status on Digispark Keyboard library.


Now to get the LED status is just a matter of calling the function

DigiKeyboard.getLEDs()

DigiKeyboard.getLEDs()  

and test for one of the 3 contants:

NUM_LOCK

CAPS_LOCK

SCROLL_LOCK

Just like in the example

// USB Caps Lock Led gizmo - Danjovic 2020
// Use modified version of DigiKeyboard library
// https://github.com/Danjovic/DigistumpArduino/tree/master/digistump-avr/libraries/DigisparkKeyboard
#include "DigiKeyboard.h"

void setup() {
  pinMode(1,OUTPUT);      // Digistump BuiltIn LED as output
}


void loop() {
  // Check the state of Caps Lock and change led accordingly
  if (DigiKeyboard.getLEDs() & CAPS_LOCK)
      digitalWrite(1, HIGH);
  else 
      digitalWrite(1, LOW);
  DigiKeyboard.delay(10);
}

The modified version of the libraries are available at:

https://github.com/Danjovic/DigistumpArduino/tree/master/digistump-avr/libraries/DigisparkKeyboard

It is necessary to get the 3 files below...

The latter file enhances the keystroke definition of the original project and defines full set of HID Keycodes (from 0x00 to 0xE7).


.. and copy the files to the following path

c:\Users\__name_of_your_user___0\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\libraries\DigisparkKeyboard\
Like

Discussions

danjovic wrote 08/28/2020 at 18:01 point

No problem, I am glad that it worked!

  Are you sure? yes | no

danjovic wrote 08/28/2020 at 15:33 point

You welcome!

I will take a look. Have a question:i did it worked on previous version?

  Are you sure? yes | no

Dadwarf wrote 08/28/2020 at 17:07 point

In fact i removed my question because i found my problem : USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH as to be set to 63 in usbconfig.h .. and it works. But thanks agfain that's nice ! 

  Are you sure? yes | no

Dadwarf wrote 08/28/2020 at 17:08 point

(I should had removed only my question not my praised)

  Are you sure? yes | no