Skip to content

Commit f2f0c6e

Browse files
committed
add set led to hid_keyscan example as well
1 parent 1d301d5 commit f2f0c6e

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

libraries/Bluefruit52Lib/examples/Peripheral/hid_keyscan/hid_keyscan.ino

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ void setup()
7373
*/
7474
blehid.begin();
7575

76+
// Set callback for set LED from central
77+
blehid.setKeyboardLedCallback(set_keyboard_led);
78+
7679
/* Set connection interval (min, max) to your perferred value.
7780
* Note: It is already set by BLEHidAdafruit::begin() to 11.25ms - 15ms
7881
* min = 9*1.25=11.25 ms, max = 12*1.25= 15 ms
@@ -168,3 +171,23 @@ void loop()
168171
// Poll interval
169172
delay(10);
170173
}
174+
175+
/**
176+
* Callback invoked when received Set LED from central.
177+
* Must be set previously with setKeyboardLedCallback()
178+
*
179+
* The LED bit map is as follows: (also defined by KEYBOARD_LED_* )
180+
* Kana (4) | Compose (3) | ScrollLock (2) | CapsLock (1) | Numlock (0)
181+
*/
182+
void set_keyboard_led(uint8_t led_bitmap)
183+
{
184+
// light up Red Led if any bits is set
185+
if ( led_bitmap )
186+
{
187+
ledOn( LED_RED );
188+
}
189+
else
190+
{
191+
ledOff( LED_RED );
192+
}
193+
}

0 commit comments

Comments
 (0)