5
5
6
6
/* This sketch demonstrates USB HID keyboard.
7
7
* - 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
9
9
*/
10
10
11
-
12
11
// HID report descriptor using TinyUSB's template
13
12
// Single Report (no ID) decriptor
14
13
uint8_t const desc_hid_report[] =
@@ -35,19 +34,14 @@ void setup()
35
34
usb_hid.begin ();
36
35
37
36
// led pin
38
- pinMode (PIN_LED , OUTPUT);
39
- digitalWrite (PIN_LED, 0 );
37
+ pinMode (LED_BUILTIN , OUTPUT);
38
+ digitalWrite (LED_BUILTIN, LOW );
40
39
41
40
// Set up pin as input
42
41
for (uint8_t i=0 ; i<pincount; i++)
43
42
{
44
43
pinMode (pins[i], INPUT_PULLUP);
45
44
}
46
-
47
- Serial.begin (115200 );
48
- while ( !Serial ) delay (10 ); // wait for native usb
49
-
50
- Serial.println (" Adafruit TinyUSB HID Keyboard example" );
51
45
}
52
46
53
47
@@ -123,6 +117,6 @@ void hid_report_callback(uint8_t report_id, hid_report_type_t report_type, uint8
123
117
// Kana (4) | Compose (3) | ScrollLock (2) | CapsLock (1) | Numlock (0)
124
118
uint8_t ledIndicator = buffer[0 ];
125
119
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 );
128
122
}
0 commit comments