15
15
/*
16
16
* This sketch uses the HID Consumer Key API to send the Volume Down
17
17
* key when PIN_SHUTTER is grounded. This will cause your mobile device
18
- * to capture a photo when you are in Camera App
18
+ * to capture a photo when you are in the camera app
19
19
*/
20
20
#include < bluefruit.h>
21
21
@@ -24,10 +24,10 @@ BLEHidAdafruit blehid;
24
24
25
25
#define PIN_SHUTTER 27
26
26
27
- void setup ()
27
+ void setup ()
28
28
{
29
29
pinMode (PIN_SHUTTER, INPUT_PULLUP);
30
-
30
+
31
31
Serial.begin (115200 );
32
32
33
33
Serial.println (" Bluefruit52 HID Camera Shutter Example" );
@@ -44,24 +44,24 @@ void setup()
44
44
Bluefruit.begin ();
45
45
Bluefruit.setName (" Bluefruit52" );
46
46
47
- // Configure and Start Device Information Service
47
+ // Configure and start DIS ( Device Information Service)
48
48
bledis.setManufacturer (" Adafruit Industries" );
49
49
bledis.setModel (" Bluefruit Feather 52" );
50
50
bledis.begin ();
51
51
52
52
/* Start BLE HID
53
53
* Note: Apple requires BLE devices to have a min connection interval >= 20m
54
54
* (The smaller the connection interval the faster we can send data).
55
- * However for HID and MIDI device, Apple will accept a min connection interval
56
- * as low as 11.25 ms. Therefore BLEHidAdafruit::begin() will try to set
57
- * the min and max connection interval to 11.25 ms and 15 ms respectively
55
+ * However, for HID and MIDI device Apple will accept a min connection
56
+ * interval as low as 11.25 ms. Therefore BLEHidAdafruit::begin() will try to
57
+ * set the min and max connection interval to 11.25 ms and 15 ms respectively
58
58
* for the best performance.
59
59
*/
60
60
blehid.begin ();
61
61
62
62
/* Set connection interval (min, max) to your perferred value.
63
63
* Note: It is already set by BLEHidAdafruit::begin() to 11.25ms - 15ms
64
- * min = 9*1.25=11.25 ms, max = 12*1.25= 15 ms
64
+ * min = 9*1.25=11.25 ms, max = 12*1.25= 15 ms
65
65
*/
66
66
/* Bluefruit.setConnInterval(9, 12); */
67
67
@@ -73,20 +73,20 @@ void setup()
73
73
}
74
74
75
75
void setupAdv (void )
76
- {
76
+ {
77
77
Bluefruit.Advertising .addFlags (BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE);
78
78
Bluefruit.Advertising .addTxPower ();
79
79
80
80
Bluefruit.Advertising .addAppearance (BLE_APPEARANCE_HID_KEYBOARD);
81
-
81
+
82
82
// Include BLE HID service
83
83
Bluefruit.Advertising .addService (blehid);
84
84
85
85
// There is enough room for the dev name in the advertising packet
86
86
Bluefruit.Advertising .addName ();
87
87
}
88
88
89
- void loop ()
89
+ void loop ()
90
90
{
91
91
// Make sure you are connected and bonded/paired
92
92
if ( Bluefruit.connected () && Bluefruit.connPaired () )
@@ -96,14 +96,14 @@ void loop()
96
96
{
97
97
// Turn on red LED when we start sending data
98
98
digitalWrite (LED_RED, 1 );
99
-
99
+
100
100
// Send the 'volume down' key press
101
101
// Check BLEHidGerneric.h for list of defined consumer usage codes
102
102
blehid.consumerKeyPress (HID_USAGE_CONSUMER_VOLUME_DECREMENT);
103
103
104
104
// Delay a bit between reports
105
105
delay (10 );
106
-
106
+
107
107
// Send key release
108
108
blehid.consumerKeyRelease ();
109
109
0 commit comments