-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TX power level can now be set either initially using the configuration system eg. bleGamepadConfig.setTXPowerLevel(txPowerLevel); Defaults to 9 if not set Range: -12 to 9 dBm and the only valid values are: -12, -9, -6, -3, 0, 3, 6 and 9 TX power can also be set at any time using bleGamepad.setTXPower(int8_t) You can also get the current TX power level by using bleGamepad.getTXPower(int8_t)
- Loading branch information
1 parent
02c7ece
commit c48ca5d
Showing
7 changed files
with
70 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 42 additions & 26 deletions
68
examples/CharacteristicsConfiguration/CharacteristicsConfiguration.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,57 @@ | ||
/* | ||
* Sets BLE characteristic options | ||
* Use BLE Scanner etc on Android to see them | ||
*/ | ||
Sets BLE characteristic options | ||
Use BLE Scanner etc on Android to see them | ||
Also shows how to set transmit power during initial configuration, | ||
or at any stage whilst running by using bleGamepad.setTXPowerLevel(int8_t) | ||
The only valid values are: -12, -9, -6, -3, 0, 3, 6 and 9 | ||
Values correlate to dbm | ||
You can get the currently set TX power level by calling bleGamepad.setTXPowerLevel() | ||
*/ | ||
|
||
#include <Arduino.h> | ||
#include <BleGamepad.h> | ||
|
||
int8_t txPowerLevel = 3; | ||
|
||
BleGamepad bleGamepad("Custom Contoller Name", "lemmingDev", 100); // Set custom device name, manufacturer and initial battery level | ||
BleGamepadConfiguration bleGamepadConfig; // Create a BleGamepadConfiguration object to store all of the options | ||
|
||
void setup() | ||
{ | ||
Serial.begin(115200); | ||
Serial.println("Starting BLE work!"); | ||
bleGamepadConfig.setAutoReport(false); | ||
bleGamepadConfig.setControllerType(CONTROLLER_TYPE_GAMEPAD); // CONTROLLER_TYPE_JOYSTICK, CONTROLLER_TYPE_GAMEPAD (DEFAULT), CONTROLLER_TYPE_MULTI_AXIS | ||
bleGamepadConfig.setVid(0xe502); | ||
bleGamepadConfig.setPid(0xabcd); | ||
|
||
bleGamepadConfig.setModelNumber("1.0"); | ||
bleGamepadConfig.setSoftwareRevision("Software Rev 1"); | ||
bleGamepadConfig.setSerialNumber("9876543210"); | ||
bleGamepadConfig.setFirmwareRevision("2.0"); | ||
bleGamepadConfig.setHardwareRevision("1.7"); | ||
|
||
// Some non-Windows operating systems and web based gamepad testers don't like min axis set below 0, so 0 is set by default | ||
//bleGamepadConfig.setAxesMin(0x8001); // -32767 --> int16_t - 16 bit signed integer - Can be in decimal or hexadecimal | ||
bleGamepadConfig.setAxesMin(0x0000); // 0 --> int16_t - 16 bit signed integer - Can be in decimal or hexadecimal | ||
bleGamepadConfig.setAxesMax(0x7FFF); // 32767 --> int16_t - 16 bit signed integer - Can be in decimal or hexadecimal | ||
|
||
bleGamepad.begin(&bleGamepadConfig); // Begin gamepad with configuration options | ||
Serial.begin(115200); | ||
Serial.println("Starting BLE work!"); | ||
bleGamepadConfig.setAutoReport(false); | ||
bleGamepadConfig.setControllerType(CONTROLLER_TYPE_GAMEPAD); // CONTROLLER_TYPE_JOYSTICK, CONTROLLER_TYPE_GAMEPAD (DEFAULT), CONTROLLER_TYPE_MULTI_AXIS | ||
bleGamepadConfig.setVid(0xe502); | ||
bleGamepadConfig.setPid(0xabcd); | ||
bleGamepadConfig.setTXPowerLevel(txPowerLevel); // Defaults to 9 if not set. (Range: -12 to 9 dBm) | ||
|
||
bleGamepadConfig.setModelNumber("1.0"); | ||
bleGamepadConfig.setSoftwareRevision("Software Rev 1"); | ||
bleGamepadConfig.setSerialNumber("9876543210"); | ||
bleGamepadConfig.setFirmwareRevision("2.0"); | ||
bleGamepadConfig.setHardwareRevision("1.7"); | ||
|
||
// Some non-Windows operating systems and web based gamepad testers don't like min axis set below 0, so 0 is set by default | ||
//bleGamepadConfig.setAxesMin(0x8001); // -32767 --> int16_t - 16 bit signed integer - Can be in decimal or hexadecimal | ||
bleGamepadConfig.setAxesMin(0x0000); // 0 --> int16_t - 16 bit signed integer - Can be in decimal or hexadecimal | ||
bleGamepadConfig.setAxesMax(0x7FFF); // 32767 --> int16_t - 16 bit signed integer - Can be in decimal or hexadecimal | ||
|
||
bleGamepad.begin(&bleGamepadConfig); // Begin gamepad with configuration options | ||
|
||
// Change power level to 6 | ||
bleGamepad.setTXPowerLevel(6); | ||
|
||
} | ||
|
||
void loop() | ||
{ | ||
if (bleGamepad.isConnected()) | ||
{ | ||
if (bleGamepad.isConnected()) | ||
{ | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters