Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
PS3BT Class Reference
This BluetoothService class implements support for all the official PS3 Controllers: Dualshock 3, Navigation or a Motion controller via Bluetooth. More...
#include <PS3BT.h>
Inherits BluetoothService.
Public Member Functions | |
| PS3BT (BTD *pBtd, uint8_t btadr5=0, uint8_t btadr4=0, uint8_t btadr3=0, uint8_t btadr2=0, uint8_t btadr1=0, uint8_t btadr0=0) | |
| Constructor for the PS3BT class. | |
| void | attachOnInit (void(*funcOnInit)(void)) |
| Used to call your own function when the device is successfully initialized. | |
PS3 Controller functions | |
| bool | getButtonPress (ButtonEnum b) |
| getButtonPress(ButtonEnum b) will return true as long as the button is held down. | |
| bool | getButtonClick (ButtonEnum b) |
| uint8_t | getAnalogButton (ButtonEnum a) |
| Used to get the analog value from button presses. | |
| uint8_t | getAnalogHat (AnalogHatEnum a) |
| Used to read the analog joystick. | |
| int16_t | getSensor (SensorEnum a) |
| Used to read the sensors inside the Dualshock 3 and Move controller. | |
| float | getAngle (AngleEnum a) |
| Use this to get Pitch and Roll calculated using the accelerometer. | |
| float | get9DOFValues (SensorEnum a) |
| Read the sensors inside the Move controller. | |
| bool | getStatus (StatusEnum c) |
| Get the status from the controller. | |
| void | printStatusString () |
| Read all the available statuses from the controller and prints it as a nice formated string. | |
| String | getTemperature () |
| Read the temperature from the Move controller. | |
| void | setAllOff () |
| Used to set all LEDs and rumble off. | |
| void | setRumbleOff () |
| Turn off rumble. | |
| void | setRumbleOn (RumbleEnum mode) |
| Turn on rumble. | |
| void | setRumbleOn (uint8_t rightDuration, uint8_t rightPower, uint8_t leftDuration, uint8_t leftPower) |
| Turn on rumble using custom duration and power. | |
| void | setLedRaw (uint8_t value) |
| Set LED value without using LEDEnum. | |
| void | setLedOff () |
| Turn all LEDs off. | |
| void | setLedOff (LEDEnum a) |
| Turn the specific LED off. | |
| void | setLedOn (LEDEnum a) |
| Turn the specific LED on. | |
| void | setLedToggle (LEDEnum a) |
| Toggle the specific LED. | |
| void | moveSetBulb (uint8_t r, uint8_t g, uint8_t b) |
| Use this to set the Color using RGB values. | |
| void | moveSetBulb (ColorsEnum color) |
| Use this to set the color using the predefined colors in ColorsEnum. | |
| void | moveSetRumble (uint8_t rumble) |
| Set the rumble value inside the Move controller. | |
| uint32_t | getLastMessageTime () |
| Used to get the millis() of the last message. | |
Data Fields | |
| bool | PS3Connected |
| Variable used to indicate if the normal Playstation controller is successfully connected. | |
| bool | PS3MoveConnected |
| Variable used to indicate if the Move controller is successfully connected. | |
| bool | PS3NavigationConnected |
| Variable used to indicate if the Navigation controller is successfully connected. | |
Protected Member Functions | |
| bool | checkHciHandle (uint8_t *buf, uint16_t handle) |
| Used to check if the incoming L2CAP data matches the HCI Handle. | |
Protected Attributes | |
| void(* | pFuncOnInit )(void) |
| Pointer to function called in onInit(). | |
| BTD * | pBtd |
| Pointer to BTD instance. | |
| uint16_t | hci_handle |
| The HCI Handle for the connection. | |
| uint32_t | l2cap_event_flag |
| L2CAP flags of received Bluetooth events. | |
| uint8_t | identifier |
| Identifier for L2CAP commands. | |
BluetoothService implementation | |
| void | disconnect () |
| Used this to disconnect any of the controllers. | |
| void | ACLData (uint8_t *ACLData) |
| Used to pass acldata to the services. | |
| void | Run () |
| Used to run part of the state machine. | |
| void | Reset () |
| Use this to reset the service. | |
| void | onInit () |
| Called when the controller is successfully initialized. | |
Detailed Description
This BluetoothService class implements support for all the official PS3 Controllers: Dualshock 3, Navigation or a Motion controller via Bluetooth.
Information about the protocol can be found at the wiki: https://github.com/felis/USB_Host_Shield_2.0/wiki/PS3-Information.
Definition at line 32 of file PS3BT.h.
Constructor & Destructor Documentation
| PS3BT | ( | BTD * | pBtd, |
| uint8_t | btadr5 = 0, |
||
| uint8_t | btadr4 = 0, |
||
| uint8_t | btadr3 = 0, |
||
| uint8_t | btadr2 = 0, |
||
| uint8_t | btadr1 = 0, |
||
| uint8_t | btadr0 = 0 |
||
| ) |
Constructor for the PS3BT class.
- Parameters:
-
pBtd Pointer to BTD class instance. btadr5,btadr4,btadr3,btadr2,btadr1,btadr0 Pass your dongles Bluetooth address into the constructor, This will set BTD::my_bdaddr, so you don't have to plug in the dongle before pairing with your controller.
Member Function Documentation
| void ACLData | ( | uint8_t * | ACLData ) | [protected, virtual] |
Used to pass acldata to the services.
- Parameters:
-
ACLData Incoming acldata.
Implements BluetoothService.
| void attachOnInit | ( | void(*)(void) | funcOnInit ) | [inherited] |
| bool checkHciHandle | ( | uint8_t * | buf, |
| uint16_t | handle | ||
| ) | [protected, inherited] |
| void disconnect | ( | ) | [virtual] |
Used this to disconnect any of the controllers.
Implements BluetoothService.
| float get9DOFValues | ( | SensorEnum | a ) |
| uint8_t getAnalogButton | ( | ButtonEnum | a ) |
| uint8_t getAnalogHat | ( | AnalogHatEnum | a ) |
| float getAngle | ( | AngleEnum | a ) |
| bool getButtonPress | ( | ButtonEnum | b ) |
getButtonPress(ButtonEnum b) will return true as long as the button is held down.
While getButtonClick(ButtonEnum b) will only return it once.
So you instance if you need to increase a variable once you would use getButtonClick(ButtonEnum b), but if you need to drive a robot forward you would use getButtonPress(ButtonEnum b).
- Parameters:
-
b ButtonEnum to read.
- Returns:
- getButtonPress(ButtonEnum b) will return a true as long as a button is held down, while getButtonClick(ButtonEnum b) will return true once for each button press.
| uint32_t getLastMessageTime | ( | ) |
| int16_t getSensor | ( | SensorEnum | a ) |
Used to read the sensors inside the Dualshock 3 and Move controller.
- Parameters:
-
a The Dualshock 3 has a 3-axis accelerometer and a 1-axis gyro inside. The Move controller has a 3-axis accelerometer, a 3-axis gyro, a 3-axis magnetometer and a temperature sensor inside.
- Returns:
- Return the raw sensor value.
| bool getStatus | ( | StatusEnum | c ) |
| String getTemperature | ( | ) |
| void moveSetBulb | ( | uint8_t | r, |
| uint8_t | g, | ||
| uint8_t | b | ||
| ) |
| void moveSetBulb | ( | ColorsEnum | color ) |
| void moveSetRumble | ( | uint8_t | rumble ) |
| void onInit | ( | ) | [protected, virtual] |
Called when the controller is successfully initialized.
Use attachOnInit(void (*funcOnInit)(void)) to call your own function. This is useful for instance if you want to set the LEDs in a specific way.
Implements BluetoothService.
| void printStatusString | ( | ) |
| void Reset | ( | ) | [protected, virtual] |
Use this to reset the service.
Implements BluetoothService.
| void Run | ( | ) | [protected, virtual] |
Used to run part of the state machine.
Implements BluetoothService.
| void setLedOff | ( | LEDEnum | a ) |
| void setLedOn | ( | LEDEnum | a ) |
| void setLedRaw | ( | uint8_t | value ) |
| void setLedToggle | ( | LEDEnum | a ) |
| void setRumbleOn | ( | RumbleEnum | mode ) |
| void setRumbleOn | ( | uint8_t | rightDuration, |
| uint8_t | rightPower, | ||
| uint8_t | leftDuration, | ||
| uint8_t | leftPower | ||
| ) |
Turn on rumble using custom duration and power.
- Parameters:
-
rightDuration The duration of the right/low rumble effect. rightPower The intensity of the right/low rumble effect. leftDuration The duration of the left/high rumble effect. leftPower The intensity of the left/high rumble effect.
Field Documentation
uint16_t hci_handle [protected, inherited] |
uint8_t identifier [protected, inherited] |
uint32_t l2cap_event_flag [protected, inherited] |
void(* pFuncOnInit)(void) [protected, inherited] |
| bool PS3Connected |
| bool PS3MoveConnected |
Generated on Thu Jul 14 2022 08:33:41 by
1.7.2