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

PSP-Nx V4
[Mindsensors]

Data Structures

struct  tPSP

Files

file  mindsensors-ps2ctrl-v4.h
 

Playstation 2 Controller Sensor.


Defines

#define PSPV4_I2C_ADDR   0x02
#define PSPV4_REG_CMD   0x41
#define PSPV4_CMD_INITIALISE   0x49
#define PSPV4_REG_BTN_SET_1   0x42
#define PSPV4_REG_BTN_SET_2   0x43
#define PSPV4_REG_JLEFT   0x44
#define PSPV4_REG_JRIGHT   0x46
#define PSPV4_REG_PRES_JPAD_UP   0x4A
#define PSPV4_REG_PRES_JPAD_RIGHT   0x4B
#define PSPV4_REG_PRES_JPAD_DOWN   0x4C
#define PSPV4_REG_PRES_JPAD_LEFT   0x4D
#define PSPV4_REG_PRES_BTN_L2   0x4E
#define PSPV4_REG_PRES_BTN_R2   0x4F
#define PSPV4_REG_PRES_BTN_L1   0x50
#define PSPV4_REG_PRES_BTN_R1   0x51
#define PSPV4_REG_PRES_BTN_TRIANGLE   0x52
#define PSPV4_REG_PRES_BTN_SQUARE   0x53
#define PSPV4_REG_PRES_BTN_CIRCLE   0x54
#define PSPV4_REG_PRES_BTN_CROSS   0x55
#define PSPV4_REG_REF_SIGNAL_CODE   0x56
#define PSPV4_REG_REF_TX_TYPE   0x57
#define PSPV4_REG_REF_SIGNAL_RAW   0x58
#define PSPV4_REG_REF_SIGNAL_COUNT   0x5C
#define PSPV4_SIGNAL_FAST_REWIND   0x32
#define PSPV4_SIGNAL_FAST_FORWARD   0x34
#define PSPV4_SIGNAL_PLAY   0x35
#define PSPV4_SIGNAL_STOP   0x36

Functions

bool _PSPV4init (tSensors link, ubyte address=PSPV4_I2C_ADDR)
ubyte _PSPV4readByte (tSensors link, ubyte reg, ubyte address=PSPV4_I2C_ADDR)
bool PSPV4readButtons (tSensors link, tPSP &controllerState, ubyte address=PSPV4_I2C_ADDR)
bool PSPV4readButtonPressure (tSensors link, tPSP &controllerState, ubyte address=PSPV4_I2C_ADDR)
byte PSPV4readRefSignal (tSensors link, ubyte address=PSPV4_I2C_ADDR)
byte PSPV4readRefSignalCount (tSensors link, ubyte address=PSPV4_I2C_ADDR)
byte PSPV4readRefTXType (tSensors link, ubyte address=PSPV4_I2C_ADDR)
long PSPV4readRawRefTXValue (tSensors link, ubyte address=PSPV4_I2C_ADDR)

Variables

tByteArray PSPV4_I2CRequest
tByteArray PSPV4_I2CReply
bool PSPV4initalised [4] = {false, false, false, false}
tPSP pspController

Detailed Description

Playstation 2 Controller Sensor


Define Documentation

#define PSPV4_CMD_INITIALISE   0x49

Initialisation command

Definition at line 47 of file mindsensors-ps2ctrl-v4.h.

#define PSPV4_I2C_ADDR   0x02

PSP-Nx V4 I2C device address

Definition at line 43 of file mindsensors-ps2ctrl-v4.h.

#define PSPV4_REG_BTN_SET_1   0x42

First button set register

Definition at line 49 of file mindsensors-ps2ctrl-v4.h.

#define PSPV4_REG_BTN_SET_2   0x43

Second button set register

Definition at line 50 of file mindsensors-ps2ctrl-v4.h.

#define PSPV4_REG_CMD   0x41

Command register

Definition at line 45 of file mindsensors-ps2ctrl-v4.h.

#define PSPV4_REG_JLEFT   0x44

Left joystick register

Definition at line 51 of file mindsensors-ps2ctrl-v4.h.

#define PSPV4_REG_JRIGHT   0x46

Right joystick register

Definition at line 52 of file mindsensors-ps2ctrl-v4.h.

#define PSPV4_REG_PRES_BTN_CIRCLE   0x54

Circle button register

Definition at line 64 of file mindsensors-ps2ctrl-v4.h.

#define PSPV4_REG_PRES_BTN_CROSS   0x55

Cross button register

Definition at line 65 of file mindsensors-ps2ctrl-v4.h.

#define PSPV4_REG_PRES_BTN_L1   0x50

L1 button register

Definition at line 60 of file mindsensors-ps2ctrl-v4.h.

#define PSPV4_REG_PRES_BTN_L2   0x4E

L2 button register

Definition at line 58 of file mindsensors-ps2ctrl-v4.h.

#define PSPV4_REG_PRES_BTN_R1   0x51

R1 button register

Definition at line 61 of file mindsensors-ps2ctrl-v4.h.

#define PSPV4_REG_PRES_BTN_R2   0x4F

R2 button register

Definition at line 59 of file mindsensors-ps2ctrl-v4.h.

#define PSPV4_REG_PRES_BTN_SQUARE   0x53

Square button register

Definition at line 63 of file mindsensors-ps2ctrl-v4.h.

#define PSPV4_REG_PRES_BTN_TRIANGLE   0x52

Triangle button button register

Definition at line 62 of file mindsensors-ps2ctrl-v4.h.

#define PSPV4_REG_PRES_JPAD_DOWN   0x4C

Joypad down button register

Definition at line 56 of file mindsensors-ps2ctrl-v4.h.

#define PSPV4_REG_PRES_JPAD_LEFT   0x4D

Joypad left button register

Definition at line 57 of file mindsensors-ps2ctrl-v4.h.

#define PSPV4_REG_PRES_JPAD_RIGHT   0x4B

Joypad right button register

Definition at line 55 of file mindsensors-ps2ctrl-v4.h.

#define PSPV4_REG_PRES_JPAD_UP   0x4A

Joypad up button register

Definition at line 54 of file mindsensors-ps2ctrl-v4.h.

#define PSPV4_REG_REF_SIGNAL_CODE   0x56

Referee Signal Code register

Definition at line 67 of file mindsensors-ps2ctrl-v4.h.

#define PSPV4_REG_REF_SIGNAL_COUNT   0x5C

Referee Signal Count register

Definition at line 70 of file mindsensors-ps2ctrl-v4.h.

#define PSPV4_REG_REF_SIGNAL_RAW   0x58

Referee Signal Raw Value register

Definition at line 69 of file mindsensors-ps2ctrl-v4.h.

#define PSPV4_REG_REF_TX_TYPE   0x57

Referee Transmitter Type register

Definition at line 68 of file mindsensors-ps2ctrl-v4.h.

#define PSPV4_SIGNAL_FAST_FORWARD   0x34

Referee Signal 'fast forward'

Examples:
mindsensors-ps2ctrl-v4-test2.c.

Definition at line 73 of file mindsensors-ps2ctrl-v4.h.

#define PSPV4_SIGNAL_FAST_REWIND   0x32

Referee Signal 'fast rewind'

Examples:
mindsensors-ps2ctrl-v4-test2.c.

Definition at line 72 of file mindsensors-ps2ctrl-v4.h.

#define PSPV4_SIGNAL_PLAY   0x35

Referee Signal 'play'

Examples:
mindsensors-ps2ctrl-v4-test2.c.

Definition at line 74 of file mindsensors-ps2ctrl-v4.h.

#define PSPV4_SIGNAL_STOP   0x36

Referee Signal 'stop'

Examples:
mindsensors-ps2ctrl-v4-test2.c.

Definition at line 75 of file mindsensors-ps2ctrl-v4.h.


Function Documentation

bool _PSPV4init ( tSensors  link,
ubyte  address = PSPV4_I2C_ADDR 
)

Initialise the sensor.

Note: This is an internal function and should not be used directly.

Parameters:
linkthe PSP sensor port
addressI2C address, optional, defaults to PSPV4_I2C_ADDR
Returns:
true if no error occured, false if it did

Definition at line 118 of file mindsensors-ps2ctrl-v4.h.

ubyte _PSPV4readByte ( tSensors  link,
ubyte  reg,
ubyte  address = PSPV4_I2C_ADDR 
)

Read a byte from the sensor

Note: This is an internal function and should not be used directly.

Parameters:
linkthe PSP sensor port
regthe register to read
addressI2C address, optional, defaults to PSPV4_I2C_ADDR
Returns:
the ubyte value or 0 if an error occured

Definition at line 146 of file mindsensors-ps2ctrl-v4.h.

bool PSPV4readButtonPressure ( tSensors  link,
tPSP controllerState,
ubyte  address = PSPV4_I2C_ADDR 
)

Read the button states with additional pressure values. Use PSPV4readButtons() if you don't care about how hard someone is pressing a button.

Parameters:
linkthe PSP sensor port
controllerStatestruct to hold all the button and joystick states and values
addressI2C address, optional, defaults to PSPV4_I2C_ADDR
Returns:
true if no error occured, false if it did

Definition at line 234 of file mindsensors-ps2ctrl-v4.h.

bool PSPV4readButtons ( tSensors  link,
tPSP controllerState,
ubyte  address = PSPV4_I2C_ADDR 
)

Read the button states. Use PSPV4readButtonPressure() if you want additional pressure values as well.

Parameters:
linkthe PSP sensor port
controllerStatestruct to hold all the button and joystick states and values
addressI2C address, optional, defaults to PSPV4_I2C_ADDR
Returns:
true if no error occured, false if it did
Examples:
mindsensors-ps2ctrl-v4-test1.c.

Definition at line 175 of file mindsensors-ps2ctrl-v4.h.

long PSPV4readRawRefTXValue ( tSensors  link,
ubyte  address = PSPV4_I2C_ADDR 
)

Get the raw data from the receiver. This is useful if custom commands are to be implemented. Simply map the returned value to a new command.

Parameters:
linkthe PSP sensor port
addressI2C address, optional, defaults to PSPV4_I2C_ADDR
Returns:
the raw value from the sensor
Examples:
mindsensors-ps2ctrl-v4-test2.c.

Definition at line 322 of file mindsensors-ps2ctrl-v4.h.

byte PSPV4readRefSignal ( tSensors  link,
ubyte  address = PSPV4_I2C_ADDR 
)

Read the last command sent by the referee.
Values can be:

  • PSPV4_SIGNAL_FAST_REWIND
  • PSPV4_SIGNAL_FAST_FORWARD
  • PSPV4_SIGNAL_PLAY
  • PSPV4_SIGNAL_STOP
    Parameters:
    linkthe PSP sensor port
    addressI2C address, optional, defaults to PSPV4_I2C_ADDR
    Returns:
    true if no error occured, false if it did
Examples:
mindsensors-ps2ctrl-v4-test2.c.

Definition at line 283 of file mindsensors-ps2ctrl-v4.h.

byte PSPV4readRefSignalCount ( tSensors  link,
ubyte  address = PSPV4_I2C_ADDR 
)

Signal Count - increments each time the sensor receives a signal from the Referee (rolls over to 0 after 255)

Parameters:
linkthe PSP sensor port
addressI2C address, optional, defaults to PSPV4_I2C_ADDR
Returns:
true if no error occured, false if it did
Examples:
mindsensors-ps2ctrl-v4-test2.c.

Definition at line 296 of file mindsensors-ps2ctrl-v4.h.

byte PSPV4readRefTXType ( tSensors  link,
ubyte  address = PSPV4_I2C_ADDR 
)

Fetch the transmitter type. Can be used to differentiate between various transmitter type (TV remote vs Referee Transmitter)

Parameters:
linkthe PSP sensor port
addressI2C address, optional, defaults to PSPV4_I2C_ADDR
Returns:
true if no error occured, false if it did
Examples:
mindsensors-ps2ctrl-v4-test2.c.

Definition at line 309 of file mindsensors-ps2ctrl-v4.h.


Variable Documentation

Definition at line 107 of file mindsensors-ps2ctrl-v4.h.

Array to hold I2C reply data

Definition at line 78 of file mindsensors-ps2ctrl-v4.h.

Array to hold I2C command data

Definition at line 77 of file mindsensors-ps2ctrl-v4.h.

bool PSPV4initalised[4] = {false, false, false, false}

Definition at line 80 of file mindsensors-ps2ctrl-v4.h.