Skip to content

Commit 0a82119

Browse files
committed
use PIN_LED as caplock indicator
1 parent a6c1fcf commit 0a82119

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

examples/HID/hid_keyboard/hid_keyboard.ino

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55

66
/* This sketch demonstrates USB HID keyboard.
77
* - PIN A0-A5 is used to send digit '0' to '5' respectively
8-
* - LED will be turned on when one of Caplock/NumLock/ScrollLock/Compose/Kana is set by Host
8+
* - LED will be used as Caplock indicator
99
*/
1010

11-
1211
// HID report descriptor using TinyUSB's template
1312
// Single Report (no ID) decriptor
1413
uint8_t const desc_hid_report[] =
@@ -35,19 +34,14 @@ void setup()
3534
usb_hid.begin();
3635

3736
// led pin
38-
pinMode(PIN_LED, OUTPUT);
39-
digitalWrite(PIN_LED, 0);
37+
pinMode(LED_BUILTIN, OUTPUT);
38+
digitalWrite(LED_BUILTIN, LOW);
4039

4140
// Set up pin as input
4241
for (uint8_t i=0; i<pincount; i++)
4342
{
4443
pinMode(pins[i], INPUT_PULLUP);
4544
}
46-
47-
Serial.begin(115200);
48-
while ( !Serial ) delay(10); // wait for native usb
49-
50-
Serial.println("Adafruit TinyUSB HID Keyboard example");
5145
}
5246

5347

@@ -123,6 +117,6 @@ void hid_report_callback(uint8_t report_id, hid_report_type_t report_type, uint8
123117
// Kana (4) | Compose (3) | ScrollLock (2) | CapsLock (1) | Numlock (0)
124118
uint8_t ledIndicator = buffer[0];
125119

126-
// turn on LED if any indicator is set
127-
digitalWrite(PIN_LED, ledIndicator);
120+
// turn on LED if caplock is set
121+
digitalWrite(LED_BUILTIN, ledIndicator & KEYBOARD_LED_CAPSLOCK);
128122
}

0 commit comments

Comments
 (0)