USB Host Shield 2.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Member Functions | Public Attributes | List of all members
PS3BT Class Reference

#include <PS3BT.h>

Inheritance diagram for PS3BT:
Inheritance graph
[legend]
Collaboration diagram for PS3BT:
Collaboration graph
[legend]

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)
 
BluetoothService implementation
virtual void ACLData (uint8_t *ACLData)
 
virtual void Run ()
 
virtual void Reset ()
 
virtual void disconnect ()
 
PS3 Controller functions
bool getButtonPress (Button b)
 
bool getButtonClick (Button b)
 
uint8_t getAnalogButton (Button a)
 
uint8_t getAnalogHat (AnalogHat a)
 
int16_t getSensor (Sensor a)
 
double getAngle (Angle a)
 
double get9DOFValues (Sensor a)
 
bool getStatus (Status c)
 
String getStatusString ()
 
String getTemperature ()
 
void setAllOff ()
 
void setRumbleOff ()
 
void setRumbleOn (Rumble mode)
 
void setRumbleOn (uint8_t rightDuration, uint8_t rightPower, uint8_t leftDuration, uint8_t leftPower)
 
void setLedRaw (uint8_t value)
 
void setLedOff (LED a)
 
void setLedOn (LED a)
 
void setLedToggle (LED a)
 
void moveSetBulb (uint8_t r, uint8_t g, uint8_t b)
 
void moveSetBulb (Colors color)
 
void moveSetRumble (uint8_t rumble)
 

Public Attributes

bool PS3Connected
 
bool PS3MoveConnected
 
bool PS3NavigationConnected
 

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 66 of file PS3BT.h.

Constructor & Destructor Documentation

PS3BT::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
pBtdPointer to BTD class instance.
btadr5,btadr4,btadr3,btadr2,btadr1,btadr0Pass 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.

Definition at line 35 of file PS3BT.cpp.

Member Function Documentation

void PS3BT::ACLData ( uint8_t *  ACLData)
virtual

Used to pass acldata to the services.

Parameters
ACLDataIncoming acldata.

Reimplemented from BluetoothService.

Definition at line 257 of file PS3BT.cpp.

void PS3BT::Run ( )
virtual

Used to run part of the state maschine.

Reimplemented from BluetoothService.

Definition at line 508 of file PS3BT.cpp.

void PS3BT::Reset ( )
virtual

Use this to reset the service.

Reimplemented from BluetoothService.

Definition at line 237 of file PS3BT.cpp.

void PS3BT::disconnect ( )
virtual

Used this to disconnect any of the controllers.

Reimplemented from BluetoothService.

Definition at line 250 of file PS3BT.cpp.

bool PS3BT::getButtonPress ( Button  b)

getButtonPress(Button b) will return true as long as the button is held down.

While getButtonClick(Button b) will only return it once.

So you instance if you need to increase a variable once you would use getButtonClick(Button b), but if you need to drive a robot forward you would use getButtonPress(Button b).

Definition at line 64 of file PS3BT.cpp.

bool PS3BT::getButtonClick ( Button  b)

getButtonPress(Button b) will return true as long as the button is held down.

While getButtonClick(Button b) will only return it once.

So you instance if you need to increase a variable once you would use getButtonClick(Button b), but if you need to drive a robot forward you would use getButtonPress(Button b).

Definition at line 68 of file PS3BT.cpp.

uint8_t PS3BT::getAnalogButton ( Button  a)

Used to get the analog value from button presses.

Parameters
aThe Button to read. The supported buttons are: UP, RIGHT, DOWN, LEFT, L1, L2, R1, R2, TRIANGLE, CIRCLE, CROSS, SQUARE, and T.
Returns
Analog value in the range of 0-255.

Definition at line 75 of file PS3BT.cpp.

uint8_t PS3BT::getAnalogHat ( AnalogHat  a)

Used to read the analog joystick.

Parameters
aLeftHatX, LeftHatY, RightHatX, and RightHatY.
Returns
Return the analog value in the range of 0-255.

Definition at line 81 of file PS3BT.cpp.

int16_t PS3BT::getSensor ( Sensor  a)

Used to read the sensors inside the Dualshock 3 and Move controller.

Parameters
aThe 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.

Definition at line 87 of file PS3BT.cpp.

double PS3BT::getAngle ( Angle  a)

Use this to get Pitch and Roll calculated using the accelerometer.

Parameters
aEither Pitch or Roll.
Returns
Return the angle in the range of 0-360.

Definition at line 106 of file PS3BT.cpp.

double PS3BT::get9DOFValues ( Sensor  a)

Read the sensors inside the Move controller.

Parameters
aaXmove, aYmove, aZmove, gXmove, gYmove, gZmove, mXmove, mYmove, and mXmove.
Returns
The value in SI units.

Definition at line 137 of file PS3BT.cpp.

bool PS3BT::getStatus ( Status  c)

Get the Status from the controller.

Parameters
cThe Status you want to read.
Returns
True if correct and false if not.

Definition at line 180 of file PS3BT.cpp.

String PS3BT::getStatusString ( )

Read all the available Status from the controller.

Returns
One large string with all the information.

Definition at line 188 of file PS3BT.cpp.

String PS3BT::getTemperature ( )

Read the temperature from the Move controller.

Returns
The temperature in degrees celsius.

Definition at line 166 of file PS3BT.cpp.

void PS3BT::setAllOff ( )

Used to set all LEDs and Rumble off.

Definition at line 575 of file PS3BT.cpp.

void PS3BT::setRumbleOff ( )

Turn off Rumble.

Definition at line 582 of file PS3BT.cpp.

void PS3BT::setRumbleOn ( Rumble  mode)

Turn on Rumble.

Parameters
modeEither RumbleHigh or RumbleLow.

Definition at line 591 of file PS3BT.cpp.

void PS3BT::setRumbleOn ( uint8_t  rightDuration,
uint8_t  rightPower,
uint8_t  leftDuration,
uint8_t  leftPower 
)

Turn on Rumble using custom duration and power.

Parameters
rightDurationThe duration of the right/low rumble effect.
rightPowerThe intensity of the right/low rumble effect.
leftDurationThe duration of the left/high rumble effect.
leftPowerThe intensity of the left/high rumble effect.

Definition at line 600 of file PS3BT.cpp.

void PS3BT::setLedRaw ( uint8_t  value)

Set LED value without using the LED enum.

Parameters
valueSee: LED enum.

Definition at line 608 of file PS3BT.cpp.

void PS3BT::setLedOff ( LED  a)

Turn the specific LED off.

Parameters
aThe LED to turn off.

Definition at line 612 of file PS3BT.cpp.

void PS3BT::setLedOn ( LED  a)

Turn the specific LED on.

Parameters
aThe LED to turn on.

Definition at line 617 of file PS3BT.cpp.

void PS3BT::setLedToggle ( LED  a)

Toggle the specific LED.

Parameters
aThe LED to toggle.

Definition at line 622 of file PS3BT.cpp.

void PS3BT::moveSetBulb ( uint8_t  r,
uint8_t  g,
uint8_t  b 
)

Use this to set the Color using RGB values.

Parameters
r,g,bRGB value.

Definition at line 648 of file PS3BT.cpp.

void PS3BT::moveSetBulb ( Colors  color)

Use this to set the color using the predefined colors in Colors.

Parameters
colorThe desired color.

Definition at line 657 of file PS3BT.cpp.

void PS3BT::moveSetRumble ( uint8_t  rumble)

Set the rumble value inside the Move controller.

Parameters
rumbleThe desired value in the range from 64-255.

Definition at line 661 of file PS3BT.cpp.

Member Data Documentation

bool PS3BT::PS3Connected

Variable used to indicate if the normal playstation controller is successfully connected.

Definition at line 214 of file PS3BT.h.

bool PS3BT::PS3MoveConnected

Variable used to indicate if the move controller is successfully connected.

Definition at line 216 of file PS3BT.h.

bool PS3BT::PS3NavigationConnected

Variable used to indicate if the navigation controller is successfully connected.

Definition at line 218 of file PS3BT.h.


The documentation for this class was generated from the following files: