upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
Public Member Functions | Data Fields | Protected Attributes

API for the Wii* Nunchuk controller. More...

Detailed Description

UPM module for the Wii Nunchuk controller. This module was tested with Wii Nunchuck connected to I2C via a Grove Wii Nunchuck adapter.

See http://wiibrew.org/wiki/Wiimote/Extension_Controllers and http://wiibrew.org/wiki/Wiimote/Extension_Controllers/Nunchuck for more details on the controller and its protocol.

A warning for the Grove Wii Nunchuk adapter: it has 2 traces on one side, and 3 traces on the other. Do not match these up with the Nunchuk connector's traces. The connector's 'groove' should be on the same side as the Grove interface socket on the adapter.

// Instantiate a nunchuck controller bus 3
upm::NUNCHUCK nunchuck(3);
while (shouldRun) {
cout << "stickX: " << nunchuck.stickX << ", stickY: " << nunchuck.stickY << endl;
cout << "accelX: " << nunchuck.accelX << ", accelY: " << nunchuck.accelY
<< ", accelZ: " << nunchuck.accelZ << endl;
cout << "button C: " << ((nunchuck.buttonC) ? "pressed" : "not pressed") << endl;
cout << "button Z: " << ((nunchuck.buttonZ) ? "pressed" : "not pressed") << endl;
cout << endl;

Public Member Functions

 NUNCHUCK (int bus)
virtual ~NUNCHUCK ()
void update ()

Data Fields

int stickX
int stickY
int accelX
int accelY
int accelZ
bool buttonC
bool buttonZ

Protected Attributes

nunchuck_context m_nunchuck

Constructor & Destructor Documentation

NUNCHUCK ( int  bus)

NUNCHUCK constructor

busI2C bus to use

NUNCHUCK destructor

Here is the call graph for this function:

Member Function Documentation

void update ( void  )

Reads and updates the current state of the controller.

Here is the call graph for this function:

Field Documentation

int stickX

Current analog stick X position

int stickY

Current analog stick Y position

int accelX

Current accelerometer X value

int accelY

Current accelerometer Y value

int accelZ

Current accelerometer Z value

bool buttonC

Button C pressed?

bool buttonZ

Button Z pressed?

Collaboration diagram for NUNCHUCK:
Collaboration graph

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