Skip to content

Commit 04f6cda

Browse files
updated community fqbn
1 parent 294839b commit 04f6cda

2 files changed

Lines changed: 104 additions & 3 deletions

File tree

.github/workflows/build-example-promicro.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ jobs:
1111
sketch: ['promicro']
1212
fqbn_long: ['rp2040:rp2040:adafruit_kb2040',
1313
'rp2040:rp2040:sparkfun_promicrorp2040',
14-
'community_nrf52:nrf52:bluemicro840',]
14+
'community_nrf52:nrf52:bluemicro_nrf52840',
15+
'community_nrf52:nrf52:nice_nano',
16+
'community_nrf52:nrf52:bluemicro2_1',]
1517

1618
runs-on: ubuntu-latest
1719
outputs:

README.md

Lines changed: 101 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# BlueMicro_HID_Arduino_Library
2-
Universal BLE/USB HID Library
2+
3+
4+
[![Lint Library and Examples](https://github.com/jpconstantineau/BlueMicro_HID_Arduino_Library/actions/workflows/lint.yaml/badge.svg)](https://github.com/jpconstantineau/BlueMicro_HID_Arduino_Library/actions/workflows/lint.yaml) [![Current Version](https://img.shields.io/github/v/tag/jpconstantineau/BlueMicro_HID_Arduino_Library)](https://github.com/jpconstantineau/BlueMicro_HID_Arduino_Library/tags) [![GitHub pull requests](https://img.shields.io/github/issues-pr/jpconstantineau/BlueMicro_HID_Arduino_Library.svg)](https://github.com/jpconstantineau/BlueMicro_HID_Arduino_Library) [![GitHub issues](https://img.shields.io/github/issues/jpconstantineau/BlueMicro_HID_Arduino_Library.svg)](https://github.com/jpconstantineau/BlueMicro_HID_Arduino_Library/issues)
5+
6+
A Universal Library for handling BLE and USB Human Interface Device (HID) with a computer.
37

48
## Supported Processors
59

@@ -15,4 +19,99 @@ Universal BLE/USB HID Library
1519
## Requirements for Support
1620

1721
- Arduino Board Support Package is available
18-
- TinyUSB is used as the USB stack
22+
- TinyUSB is used as the USB stack
23+
24+
# Examples
25+
26+
* `feather` - Simple test for barebones Feather boards
27+
* `feather_neokey2` - Simple test for Feather boards with a NeoKey 2 Featherwing
28+
* `itsybitsy` - Simple test for ItsyBitsy boards
29+
* `promicro` - Simple test for Boards with the form factor of a Pro Micro
30+
* `qtpy` - Simple test for QT Py boards
31+
* `rpipico` - Simple test for Raspberry Pi Pico
32+
33+
## Simple example
34+
35+
``` C++
36+
37+
#include <bluemicro_hid.h>
38+
39+
const int pin = 7; // UserSw
40+
bool activeState = false;
41+
42+
void setup()
43+
{
44+
45+
46+
hid.begin();
47+
48+
// Set up button, pullup opposite to active state
49+
pinMode(pin, activeState ? INPUT_PULLDOWN : INPUT_PULLUP);
50+
51+
Serial.begin(115200);
52+
Serial.println("Adafruit TinyUSB HID Composite example");
53+
}
54+
55+
void loop()
56+
{
57+
// poll gpio once each 10 ms
58+
delay(10);
59+
60+
// Whether button is pressed
61+
bool btn_pressed = (digitalRead(pin) == activeState);
62+
63+
/*------------- Mouse -------------*/
64+
if (btn_pressed )
65+
{
66+
int8_t const delta = 5;
67+
hid.mouseMove(delta, delta); // right + down
68+
}
69+
70+
/*------------- Keyboard -------------*/
71+
// use to send key release report
72+
static bool has_key = false;
73+
74+
if ( btn_pressed )
75+
{
76+
uint8_t keycode[6] = { 0 };
77+
keycode[0] = HID_KEY_A;
78+
79+
hid.keyboardReport(0, keycode);
80+
81+
has_key = true;
82+
}else
83+
{
84+
// send empty key report if previously has key pressed
85+
if (has_key) hid.keyboardRelease();
86+
has_key = false;
87+
}
88+
89+
// Consumer Control is used to control Media playback, Volume, Brightness etc ...
90+
// Consumer report is 2-byte containing the control code of the key
91+
// For list of control check out https://github.com/hathach/tinyusb/blob/master/src/class/hid/hid.h
92+
93+
// use to send consumer release report
94+
static bool has_consumer_key = false;
95+
96+
if ( btn_pressed )
97+
{
98+
// send volume down (0x00EA)
99+
hid.consumerKeyPress(HID_USAGE_CONSUMER_VOLUME_DECREMENT);
100+
has_consumer_key = true;
101+
}else
102+
{
103+
// release the consume key by sending zero (0x0000)
104+
if (has_consumer_key) hid.consumerKeyRelease();
105+
has_consumer_key = false;
106+
}
107+
108+
hid.processQueues(CONNECTION_MODE_AUTO);
109+
}
110+
```
111+
112+
# BlueMicro_HID API
113+
114+
The following API is available if the BlueMicro_HID library in included in a sketch file.
115+
116+
## hid.(...)
117+

0 commit comments

Comments
 (0)