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

#include <Wii.h>

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

Public Member Functions

 WII (BTD *p, bool pair=false)
 
BluetoothService implementation
virtual void ACLData (uint8_t *ACLData)
 
virtual void Run ()
 
virtual void Reset ()
 
virtual void disconnect ()
 
Wii Controller functions
bool getButtonPress (Button b)
 
bool getButtonClick (Button b)
 
void pair (void)
 
uint8_t getAnalogHat (Hat a)
 
uint16_t getAnalogHat (AnalogHat a)
 
double getPitch ()
 
double getRoll ()
 
double getYaw ()
 
void setAllOff ()
 
void setRumbleOff ()
 
void setRumbleOn ()
 
void setRumbleToggle ()
 
void setLedRaw (uint8_t value)
 
void setLedOff (LED a)
 
void setLedOn (LED a)
 
void setLedToggle (LED a)
 
void setLedStatus ()
 
uint8_t getBatteryLevel ()
 
uint8_t getWiiState ()
 
void attachOnInit (void(*funcOnInit)(void))
 
double getWiimotePitch ()
 
double getWiimoteRoll ()
 
double getNunchuckPitch ()
 
double getNunchuckRoll ()
 
Wiimote IR camera functions

You will have to uncomment WIICAMERA in Wii.h to use the IR camera.

void IRinitialize ()
 
uint16_t getIRx1 ()
 
uint16_t getIRy1 ()
 
uint8_t getIRs1 ()
 
uint16_t getIRx2 ()
 
uint16_t getIRy2 ()
 
uint8_t getIRs2 ()
 
uint16_t getIRx3 ()
 
uint16_t getIRy3 ()
 
uint8_t getIRs3 ()
 
uint16_t getIRx4 ()
 
uint16_t getIRy4 ()
 
uint8_t getIRs4 ()
 
bool isIRCameraEnabled ()
 

Public Attributes

double gyroPitch
 
double gyroRoll
 
double gyroYaw
 
bool wiimoteConnected
 
bool nunchuckConnected
 
bool motionPlusConnected
 
bool wiiUProControllerConnected
 
int16_t accXwiimote
 
int16_t accYwiimote
 
int16_t accZwiimote
 
int16_t accXnunchuck
 
int16_t accYnunchuck
 
int16_t accZnunchuck
 
double pitchGyroSpeed
 
double rollGyroSpeed
 
double yawGyroSpeed
 
uint16_t pitchGyroScale
 
uint16_t rollGyroScale
 
uint16_t yawGyroScale
 
int16_t gyroYawRaw
 
int16_t gyroRollRaw
 
int16_t gyroPitchRaw
 
int16_t gyroYawZero
 
int16_t gyroRollZero
 
int16_t gyroPitchZero
 

Detailed Description

This BluetoothService class implements support for the Wiimote including the Nunchuck and Motion Plus extension.

It also support the Wii U Pro Controller.

Definition at line 94 of file Wii.h.

Constructor & Destructor Documentation

WII::WII ( BTD p,
bool  pair = false 
)

Constructor for the WII class.

Parameters
pPointer to BTD class instance.
pairSet this to true in order to pair with the Wiimote. If the argument is omitted then it won't pair with it. One can use PAIR to set it to true.

Definition at line 84 of file Wii.cpp.

Member Function Documentation

void WII::ACLData ( uint8_t *  ACLData)
virtual

Used to pass acldata to the services.

Parameters
ACLDataIncoming acldata.

Reimplemented from BluetoothService.

Definition at line 134 of file Wii.cpp.

void WII::Run ( )
virtual

Used to run part of the state maschine.

Reimplemented from BluetoothService.

Definition at line 682 of file Wii.cpp.

void WII::Reset ( )
virtual

Use this to reset the service.

Reimplemented from BluetoothService.

Definition at line 103 of file Wii.cpp.

void WII::disconnect ( )
virtual

Used this to disconnect any of the controllers.

Reimplemented from BluetoothService.

Definition at line 117 of file Wii.cpp.

bool WII::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 1034 of file Wii.cpp.

bool WII::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 1041 of file Wii.cpp.

void WII::pair ( void  )
inline

Call this to start the paring sequence with a controller

Definition at line 133 of file Wii.h.

uint8_t WII::getAnalogHat ( Hat  a)

Used to read the joystick of the Nunchuck.

Parameters
aEither HatX or HatY.
Returns
Return the analog value in the range from approximately 25-230.

Definition at line 1052 of file Wii.cpp.

uint16_t WII::getAnalogHat ( AnalogHat  a)

Used to read the joystick of the Wii U Pro Controller.

Parameters
aEither LeftHatX, LeftHatY, RightHatX or RightHatY.
Returns
Return the analog value in the range from approximately 800-3200.

Definition at line 1064 of file Wii.cpp.

double WII::getPitch ( )
inline

Pitch calculated from the Wiimote. A complimentary filter is used if the Motion Plus is connected.

Returns
Pitch in the range from 0-360.

Definition at line 154 of file Wii.h.

double WII::getRoll ( )
inline

Roll calculated from the Wiimote. A complimentary filter is used if the Motion Plus is connected.

Returns
Roll in the range from 0-360.

Definition at line 164 of file Wii.h.

double WII::getYaw ( )
inline

This is the yaw calculated by the gyro.

NOTE: This angle will drift a lot and is only available if the Motion Plus extension is connected.

Returns
The angle calculated using the gyro.

Definition at line 176 of file Wii.h.

void WII::setAllOff ( )

Used to set all LEDs and rumble off.

Definition at line 852 of file Wii.cpp.

void WII::setRumbleOff ( )

Turn off rumble.

Definition at line 858 of file Wii.cpp.

void WII::setRumbleOn ( )

Turn on rumble.

Definition at line 864 of file Wii.cpp.

void WII::setRumbleToggle ( )

Toggle rumble.

Definition at line 870 of file Wii.cpp.

void WII::setLedRaw ( uint8_t  value)

Set LED value without using the LED enum.

Parameters
valueSee: LED enum.

Definition at line 876 of file Wii.cpp.

void WII::setLedOff ( LED  a)

Turn the specific LED off.

Parameters
aThe LED to turn off.

Definition at line 881 of file Wii.cpp.

void WII::setLedOn ( LED  a)

Turn the specific LED on.

Parameters
aThe LED to turn on.

Definition at line 887 of file Wii.cpp.

void WII::setLedToggle ( LED  a)

Toggle the specific LED.

Parameters
aThe LED to toggle.

Definition at line 893 of file Wii.cpp.

void WII::setLedStatus ( )

This will set the LEDs, so the user can see which connections are active.

The first LED indicate that the Wiimote is connected,

the second LED indicate indicate that a Motion Plus is also connected

the third LED will indicate that a Nunchuck controller is also connected.

Definition at line 899 of file Wii.cpp.

uint8_t WII::getBatteryLevel ( )

Return the battery level of the Wiimote.

Returns
The battery level in the range 0-255.

Definition at line 912 of file Wii.cpp.

uint8_t WII::getWiiState ( )
inline

Return the Wiimote state.

Returns
See: http://wiibrew.org/wiki/Wiimote#0x20:_Status.

Definition at line 229 of file Wii.h.

void WII::attachOnInit ( void(*)(void)  funcOnInit)
inline

Used to call your own function when the controller is successfully initialized.

Parameters
funcOnInitFunction to call.

Definition at line 237 of file Wii.h.

double WII::getWiimotePitch ( )
inline

Pitch and roll calculated from the accelerometer inside the Wiimote.

Definition at line 257 of file Wii.h.

double WII::getWiimoteRoll ( )
inline

Pitch and roll calculated from the accelerometer inside the Wiimote.

Definition at line 260 of file Wii.h.

double WII::getNunchuckPitch ( )
inline

Pitch and roll calculated from the accelerometer inside the Nunchuck.

Definition at line 267 of file Wii.h.

double WII::getNunchuckRoll ( )
inline

Pitch and roll calculated from the accelerometer inside the Nunchuck.

Definition at line 270 of file Wii.h.

void WII::IRinitialize ( )

Initialises the camera as per the steps from: http://wiibrew.org/wiki/Wiimote#IR_Camera

Definition at line 1089 of file Wii.cpp.

uint16_t WII::getIRx1 ( )
inline

IR object 1 x-position read from the Wii IR camera.

Returns
The x-position of the object in the range 0-1023.

Definition at line 328 of file Wii.h.

uint16_t WII::getIRy1 ( )
inline

IR object 1 y-position read from the Wii IR camera.

Returns
The y-position of the object in the range 0-767.

Definition at line 336 of file Wii.h.

uint8_t WII::getIRs1 ( )
inline

IR object 1 size read from the Wii IR camera.

Returns
The size of the object in the range 0-15.

Definition at line 344 of file Wii.h.

uint16_t WII::getIRx2 ( )
inline

IR object 2 x-position read from the Wii IR camera.

Returns
The x-position of the object in the range 0-1023.

Definition at line 352 of file Wii.h.

uint16_t WII::getIRy2 ( )
inline

IR object 2 y-position read from the Wii IR camera.

Returns
The y-position of the object in the range 0-767.

Definition at line 360 of file Wii.h.

uint8_t WII::getIRs2 ( )
inline

IR object 2 size read from the Wii IR camera.

Returns
The size of the object in the range 0-15.

Definition at line 368 of file Wii.h.

uint16_t WII::getIRx3 ( )
inline

IR object 3 x-position read from the Wii IR camera.

Returns
The x-position of the object in the range 0-1023.

Definition at line 376 of file Wii.h.

uint16_t WII::getIRy3 ( )
inline

IR object 3 y-position read from the Wii IR camera.

Returns
The y-position of the object in the range 0-767.

Definition at line 384 of file Wii.h.

uint8_t WII::getIRs3 ( )
inline

IR object 3 size read from the Wii IR camera.

Returns
The size of the object in the range 0-15.

Definition at line 392 of file Wii.h.

uint16_t WII::getIRx4 ( )
inline

IR object 4 x-position read from the Wii IR camera.

Returns
The x-position of the object in the range 0-1023.

Definition at line 400 of file Wii.h.

uint16_t WII::getIRy4 ( )
inline

IR object 4 y-position read from the Wii IR camera.

Returns
The y-position of the object in the range 0-767.

Definition at line 408 of file Wii.h.

uint8_t WII::getIRs4 ( )
inline

IR object 4 size read from the Wii IR camera.

Returns
The size of the object in the range 0-15.

Definition at line 416 of file Wii.h.

bool WII::isIRCameraEnabled ( )
inline

Use this to check if the camera is enabled or not. If not call WII::IRinitialize to initialize the IR camera.

Returns
True if it's enabled, false if not.

Definition at line 425 of file Wii.h.

Member Data Documentation

bool WII::wiimoteConnected

Variable used to indicate if a Wiimote is connected.

Definition at line 239 of file Wii.h.

bool WII::nunchuckConnected

Variable used to indicate if a Nunchuck controller is connected.

Definition at line 246 of file Wii.h.

bool WII::motionPlusConnected

Variable used to indicate if a Nunchuck controller is connected.

Definition at line 248 of file Wii.h.

bool WII::wiiUProControllerConnected

Variable used to indicate if a Wii U Pro controller is connected.

Definition at line 250 of file Wii.h.

int16_t WII::accXwiimote

Accelerometer values used to calculate pitch and roll.

Definition at line 272 of file Wii.h.

int16_t WII::accYwiimote

Accelerometer values used to calculate pitch and roll.

Definition at line 272 of file Wii.h.

int16_t WII::accZwiimote

Accelerometer values used to calculate pitch and roll.

Definition at line 272 of file Wii.h.

int16_t WII::accXnunchuck

Accelerometer values used to calculate pitch and roll.

Definition at line 278 of file Wii.h.

int16_t WII::accYnunchuck

Accelerometer values used to calculate pitch and roll.

Definition at line 278 of file Wii.h.

int16_t WII::accZnunchuck

Accelerometer values used to calculate pitch and roll.

Definition at line 278 of file Wii.h.

double WII::gyroPitch

This is the pitch calculated by the gyro - use this to tune WII::pitchGyroScale.

Definition at line 283 of file Wii.h.

double WII::gyroRoll

This is the roll calculated by the gyro - use this to tune WII::rollGyroScale.

Definition at line 285 of file Wii.h.

double WII::gyroYaw

This is the yaw calculated by the gyro - use this to tune WII::yawGyroScale.

Definition at line 287 of file Wii.h.

double WII::pitchGyroSpeed

The speed in deg/s from the gyro.

Definition at line 291 of file Wii.h.

double WII::rollGyroSpeed

The speed in deg/s from the gyro.

Definition at line 292 of file Wii.h.

double WII::yawGyroSpeed

The speed in deg/s from the gyro.

Definition at line 293 of file Wii.h.

uint16_t WII::pitchGyroScale

You might need to fine-tune these values.

Definition at line 298 of file Wii.h.

uint16_t WII::rollGyroScale

You might need to fine-tune these values.

Definition at line 299 of file Wii.h.

uint16_t WII::yawGyroScale

You might need to fine-tune these values.

Definition at line 300 of file Wii.h.

int16_t WII::gyroYawRaw

Raw value read directly from the Motion Plus.

Definition at line 305 of file Wii.h.

int16_t WII::gyroRollRaw

Raw value read directly from the Motion Plus.

Definition at line 306 of file Wii.h.

int16_t WII::gyroPitchRaw

Raw value read directly from the Motion Plus.

Definition at line 307 of file Wii.h.

int16_t WII::gyroYawZero

These values are set when the controller is first initialized.

Definition at line 312 of file Wii.h.

int16_t WII::gyroRollZero

These values are set when the controller is first initialized.

Definition at line 313 of file Wii.h.

int16_t WII::gyroPitchZero

These values are set when the controller is first initialized.

Definition at line 314 of file Wii.h.


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