Mindstorms 3rd Party ROBOTC Drivers RobotC
[Home] [Download] [Submit a bug/suggestion] [ROBOTC Forums] [Blog] [Support this project]
Data Structures | Files | Defines | Functions | Variables

NXTChuck Sensor
[Dexter Industries]

Data Structures

struct  tNunchuck
struct  tClassicCtrl

Files

file  dexterind-nxtchuck.h
 

Dexter Industries NXTChuck Sensor driver.


Defines

#define NXTCHUCK_COM_ERROR   0
#define NXTCHUCK_COM_SUCCESS   1
#define NXTCHUCK_I2C_ADDRESS   0xA4
#define NXTCHUCK_DEVICE_UNKNOWN   1
#define NXTCHUCK_DEVICE_NUNCHUK   2
#define NXTCHUCK_DEVICE_CLASSIC_CONTROLLER   3
#define NXTCHUCK_DEVICE_GH_GUITAR   4
#define NXTCHUCK_DEVICE_GH_DRUMS   5
#define NXTCHUCK_DEVICE_DJH_TURNTABLE   6
#define NXTCHUCK_DEVICE_BALANCE_BOARD   7
#define NXTCHUCK_DEVICE_MOTION_PLUS_ACTIVE   8
#define NXTCHUCK_DEVICE_MOTION_PLUS_ACTIVE_N_PT   9
#define NXTCHUCK_DEVICE_MOTION_PLUS_ACTIVE_CC_PT   10
#define NXTCHUCK_DEVICE_MOTION_PLUS_INACTIVE   11
#define NXTCHUCK_DEVICE_MOTION_PLUS_NL_ACTIVE   12
#define NXTCHUCK_DEVICE_MOTION_PLUS_NL_N_PT   13
#define NXTCHUCK_DEVICE_MOTION_PLUS_NL_CC_PT   14
#define NXTCHUCK_DEVICE_NUNCHUK_BLACK   15
#define NXTCHUCK_N_BTN_Z   0x01
#define NXTCHUCK_N_BTN_C   0x02
#define NXTCHUCK_CC_BTN_RT   0x0002
#define NXTCHUCK_CC_BTN_P   0x0004
#define NXTCHUCK_CC_BTN_H   0x0008
#define NXTCHUCK_CC_BTN_M   0x0010
#define NXTCHUCK_CC_BTN_LT   0x0020
#define NXTCHUCK_CC_BTN_DD   0x0040
#define NXTCHUCK_CC_BTN_DR   0x0080
#define NXTCHUCK_CC_BTN_DU   0x0100
#define NXTCHUCK_CC_BTN_DL   0x0200
#define NXTCHUCK_CC_BTN_ZR   0x0400
#define NXTCHUCK_CC_BTN_X   0x0800
#define NXTCHUCK_CC_BTN_A   0x1000
#define NXTCHUCK_CC_BTN_Y   0x2000
#define NXTCHUCK_CC_BTN_B   0x4000
#define NXTCHUCK_CC_BTN_ZL   0x8000

Functions

bool _NXTChuckInit (tSensors link)
bool __NXTChuckReadRaw (tSensors link, ubyte _reg, tByteArray &data)
bool NXTChuckreadIdent (tSensors link, tNunchuck &nunchuck)
bool NXTChuckreadSensor (tSensors link, tNunchuck &nunchuck)
bool NXTChuckReadClassicController (tSensors link, tClassicCtrl &controller)

Variables

tByteArray NXTCHUCK_I2CRequest
tByteArray NXTCHUCK_I2CReply
bool NXTCHUCKinitialised [] = {false, false, false, false}
ubyte NXTChuckIdentLookup [][]
ubyte _NXTChuckDataInit1 [] = {3, 0xA4, 0xF0, 0x55}
ubyte _NXTChuckDataInit2 [] = {3, 0xA4, 0xFB, 0x00}

Detailed Description

Dexter Industries NXTChuck Sensor driver


Define Documentation

#define NXTCHUCK_CC_BTN_A   0x1000

Definition at line 75 of file dexterind-nxtchuck.h.

#define NXTCHUCK_CC_BTN_B   0x4000

Definition at line 77 of file dexterind-nxtchuck.h.

#define NXTCHUCK_CC_BTN_DD   0x0040

Definition at line 69 of file dexterind-nxtchuck.h.

#define NXTCHUCK_CC_BTN_DL   0x0200

Definition at line 72 of file dexterind-nxtchuck.h.

#define NXTCHUCK_CC_BTN_DR   0x0080

Definition at line 70 of file dexterind-nxtchuck.h.

#define NXTCHUCK_CC_BTN_DU   0x0100

Definition at line 71 of file dexterind-nxtchuck.h.

#define NXTCHUCK_CC_BTN_H   0x0008

Definition at line 66 of file dexterind-nxtchuck.h.

#define NXTCHUCK_CC_BTN_LT   0x0020

Definition at line 68 of file dexterind-nxtchuck.h.

#define NXTCHUCK_CC_BTN_M   0x0010

Definition at line 67 of file dexterind-nxtchuck.h.

#define NXTCHUCK_CC_BTN_P   0x0004

Definition at line 65 of file dexterind-nxtchuck.h.

#define NXTCHUCK_CC_BTN_RT   0x0002

Definition at line 64 of file dexterind-nxtchuck.h.

#define NXTCHUCK_CC_BTN_X   0x0800

Definition at line 74 of file dexterind-nxtchuck.h.

#define NXTCHUCK_CC_BTN_Y   0x2000

Definition at line 76 of file dexterind-nxtchuck.h.

#define NXTCHUCK_CC_BTN_ZL   0x8000

Definition at line 78 of file dexterind-nxtchuck.h.

#define NXTCHUCK_CC_BTN_ZR   0x0400

Definition at line 73 of file dexterind-nxtchuck.h.

#define NXTCHUCK_COM_ERROR   0

Definition at line 40 of file dexterind-nxtchuck.h.

#define NXTCHUCK_COM_SUCCESS   1

Definition at line 41 of file dexterind-nxtchuck.h.

#define NXTCHUCK_DEVICE_BALANCE_BOARD   7

Definition at line 51 of file dexterind-nxtchuck.h.

#define NXTCHUCK_DEVICE_CLASSIC_CONTROLLER   3

Definition at line 47 of file dexterind-nxtchuck.h.

#define NXTCHUCK_DEVICE_DJH_TURNTABLE   6

Definition at line 50 of file dexterind-nxtchuck.h.

#define NXTCHUCK_DEVICE_GH_DRUMS   5

Definition at line 49 of file dexterind-nxtchuck.h.

#define NXTCHUCK_DEVICE_GH_GUITAR   4

Definition at line 48 of file dexterind-nxtchuck.h.

#define NXTCHUCK_DEVICE_MOTION_PLUS_ACTIVE   8

Definition at line 52 of file dexterind-nxtchuck.h.

#define NXTCHUCK_DEVICE_MOTION_PLUS_ACTIVE_CC_PT   10

Definition at line 54 of file dexterind-nxtchuck.h.

#define NXTCHUCK_DEVICE_MOTION_PLUS_ACTIVE_N_PT   9

Definition at line 53 of file dexterind-nxtchuck.h.

#define NXTCHUCK_DEVICE_MOTION_PLUS_INACTIVE   11

Definition at line 55 of file dexterind-nxtchuck.h.

#define NXTCHUCK_DEVICE_MOTION_PLUS_NL_ACTIVE   12

Definition at line 56 of file dexterind-nxtchuck.h.

#define NXTCHUCK_DEVICE_MOTION_PLUS_NL_CC_PT   14

Definition at line 58 of file dexterind-nxtchuck.h.

#define NXTCHUCK_DEVICE_MOTION_PLUS_NL_N_PT   13

Definition at line 57 of file dexterind-nxtchuck.h.

#define NXTCHUCK_DEVICE_NUNCHUK   2

Definition at line 46 of file dexterind-nxtchuck.h.

#define NXTCHUCK_DEVICE_NUNCHUK_BLACK   15

Definition at line 59 of file dexterind-nxtchuck.h.

#define NXTCHUCK_DEVICE_UNKNOWN   1

Definition at line 45 of file dexterind-nxtchuck.h.

#define NXTCHUCK_I2C_ADDRESS   0xA4

Definition at line 43 of file dexterind-nxtchuck.h.

#define NXTCHUCK_N_BTN_C   0x02

Definition at line 62 of file dexterind-nxtchuck.h.

#define NXTCHUCK_N_BTN_Z   0x01

Definition at line 61 of file dexterind-nxtchuck.h.


Function Documentation

bool __NXTChuckReadRaw ( tSensors  link,
ubyte  _reg,
tByteArray data 
)

Read 6 bytes from the nunchuck and return it.

Please note this is an internal function and should not be used directly.

Parameters:
linkthe nunchuck port number
_regthe register to read
datathe tByteArray to hold the returned data
Returns:
true if no error occured, false if it did

Definition at line 172 of file dexterind-nxtchuck.h.

bool _NXTChuckInit ( tSensors  link )

It's a nunchuck, innit? Initialise the nunchuck sensor.

Please note that this is an internal function and should not called directly.

Parameters:
linkthe NXTChuck port number
Returns:
true if no error occured, false if it did

Definition at line 153 of file dexterind-nxtchuck.h.

bool NXTChuckReadClassicController ( tSensors  link,
tClassicCtrl controller 
)

Read the data from the classic controller.

Parameters:
linkthe nunchuck port number
controllerthe tClassicCtrl that holds the Classic Controller related data.
Returns:
true if no error occured, false if it did

Definition at line 274 of file dexterind-nxtchuck.h.

bool NXTChuckreadIdent ( tSensors  link,
tNunchuck nunchuck 
)

Identify the type of nunchuck sensor connected to the NXT.

Parameters:
linkthe nunchuck port number
nunchuckthe tNunchuck that holds the nunchuck related data.
Returns:
true if no error occured, false if it did
Examples:
dexterind-nxtchuck-test1.c.

Definition at line 201 of file dexterind-nxtchuck.h.

bool NXTChuckreadSensor ( tSensors  link,
tNunchuck nunchuck 
)

Read the data from the nunchuck.

Parameters:
linkthe nunchuck port number
nunchuckthe tNunchuck that holds the nunchuck related data.
Returns:
true if no error occured, false if it did
Examples:
dexterind-nxtchuck-test1.c.

Definition at line 248 of file dexterind-nxtchuck.h.


Variable Documentation

ubyte _NXTChuckDataInit1[] = {3, 0xA4, 0xF0, 0x55}

First of two arrays written to the extension to initialize

Definition at line 143 of file dexterind-nxtchuck.h.

ubyte _NXTChuckDataInit2[] = {3, 0xA4, 0xFB, 0x00}

Second of two arrays written to the extension to initialize

Definition at line 144 of file dexterind-nxtchuck.h.

Array to hold I2C reply data

Definition at line 81 of file dexterind-nxtchuck.h.

Array to hold I2C command data

Definition at line 80 of file dexterind-nxtchuck.h.

Initial value:
 {
  {0x00,0x00,0xA4,0x20,0x00,0x00}, 
  {0x00,0x00,0xA4,0x20,0x01,0x01}, 
  {0x00,0x00,0xA4,0x20,0x01,0x03}, 
  {0x01,0x00,0xA4,0x20,0x01,0x03}, 
  {0x03,0x00,0xA4,0x20,0x01,0x03}, 
  {0x00,0x00,0xA4,0x20,0x04,0x02}, 
  {0x00,0x00,0xA4,0x20,0x04,0x05}, 
  {0x00,0x00,0xA4,0x20,0x05,0x05}, 
  {0x00,0x00,0xA4,0x20,0x07,0x05}, 
  {0x00,0x00,0xA6,0x20,0x00,0x05}, 
  {0x00,0x00,0xA6,0x20,0x04,0x05}, 
  {0x00,0x00,0xA6,0x20,0x05,0x05}, 
  {0x00,0x00,0xA6,0x20,0x07,0x05}, 
  {0xFF,0x00,0xA4,0x20,0x00,0x00}  
}

Definition at line 126 of file dexterind-nxtchuck.h.

bool NXTCHUCKinitialised[] = {false, false, false, false}

Has the NXTChuck been initialised yet?

Definition at line 83 of file dexterind-nxtchuck.h.