You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,6 +11,8 @@ It would be great however if any improvements are fed back into this version.
11
11
-[x] Button release (128 buttons)
12
12
-[x] Axes movement (6 axes (configurable resolution up to 16 bit) (x, y, z, rX, rY, rZ) --> In Windows usually (Left Thumb X, Left Thumb Y, Right Thumb X, Left Trigger, Right Trigger, Right Thumb Y))
13
13
-[x] Gyroscope and Accelerometer
14
+
-[x] Set battery percentage
15
+
-[x] Set battery power state information using UUID 0x2A1A. Use nRF Connect on Android for example to see this information
14
16
-[x] 2 Sliders (configurable resolution up to 16 bit) (Slider 1 and Slider 2)
15
17
-[x] 4 point of view hats (ie. d-pad plus 3 other hat switches)
@@ -44,7 +46,7 @@ This was due to the fact that non-Windows operating systems and some online web-
44
46
45
47
This version endeavors to be compatible with the latest released version of NimBLE-Arduino through the Arduino Library Manager; currently version 2.2.1 at the time of this writing; --> https://github.com/h2zero/NimBLE-Arduino/releases/tag/2.2.1
46
48
47
-
setAxes accepts them in the order (x, y, z, rx, ry, rz)
49
+
setAxes accepts axes in the order (x, y, z, rx, ry, rz)
48
50
setHIDAxes accepts them in the order (x, y, z, rz, rx, ry)
This example builds on the SetBatteryLevel example by also showing how to set the battery power state information to be reported to the host OS
3
+
Use nRF Connect on Android for example to see the set information
4
+
5
+
You can set:
6
+
7
+
- Whether there is a battery installed or not
8
+
- Whether the device is discharging or not
9
+
- Whether the device is charging or not
10
+
- Whether the power level is good or critically low
11
+
12
+
Each of the above also supports unknown or not supported states
13
+
14
+
You can use the definitions as shown below, or direct values
15
+
16
+
#define POWER_STATE_UNKNOWN 0 // B00
17
+
#define POWER_STATE_NOT_SUPPORTED 1 // B01
18
+
#define POWER_STATE_NOT_PRESENT 2 // B10
19
+
#define POWER_STATE_NOT_DISCHARGING 2 // B10
20
+
#define POWER_STATE_NOT_CHARGING 2 // B10
21
+
#define POWER_STATE_GOOD 2 // B10
22
+
#define POWER_STATE_PRESENT 3 // B11
23
+
#define POWER_STATE_DISCHARGING 3 // B11
24
+
#define POWER_STATE_CHARGING 3 // B11
25
+
#define POWER_STATE_CRITICAL 3 // B11
26
+
27
+
*/
28
+
29
+
#include<Arduino.h>
30
+
#include<BleGamepad.h>
31
+
32
+
BleGamepad bleGamepad;
33
+
34
+
int batteryLevel = 100;
35
+
36
+
voidsetup()
37
+
{
38
+
Serial.begin(115200);
39
+
Serial.println("Starting BLE work!");
40
+
bleGamepad.begin();
41
+
}
42
+
43
+
voidloop()
44
+
{
45
+
if (bleGamepad.isConnected())
46
+
{
47
+
// bleGamepad.setPowerStateAll(POWER_STATE_PRESENT, POWER_STATE_NOT_DISCHARGING, POWER_STATE_CHARGING, POWER_STATE_GOOD); // Can set all values together or separate as below
48
+
bleGamepad.setBatteryPowerInformation(POWER_STATE_PRESENT); // POWER_STATE_UNKNOWN or POWER_STATE_NOT_SUPPORTED or POWER_STATE_NOT_PRESENT or POWER_STATE_PRESENT
49
+
bleGamepad.setDischargingState(POWER_STATE_NOT_DISCHARGING); // POWER_STATE_UNKNOWN or POWER_STATE_NOT_SUPPORTED or POWER_STATE_NOT_DISCHARGING or POWER_STATE_DISCHARGING
50
+
bleGamepad.setChargingState(POWER_STATE_CHARGING); // POWER_STATE_UNKNOWN or POWER_STATE_NOT_SUPPORTED or POWER_STATE_NOT_CHARGING or POWER_STATE_CHARGING
51
+
bleGamepad.setPowerLevel(POWER_STATE_GOOD); // POWER_STATE_UNKNOWN or POWER_STATE_NOT_SUPPORTED or POWER_STATE_GOOD or POWER_STATE_CRITICAL
0 commit comments