# ecrobot::PSPNx Class Reference

Mindsensor PSPNx (http://www.mindsensors.com/index.php?module=pagemaster&PAGE_user_op=view_page&PAGE_id=61) class. More...

`#include <PSPNx.h>`

List of all members.

## Public Types
enum | eButtons { SELECT = 1, LJ = 2, RJ = 4, START = 8, UP = 16, RIGHT = 32, DOWN = 64, LEFT = 128, L2 = 256, R2 = 512, L1 = 1024, R1 = 2048, TRIANGLE = 4096, CIRCLE = 8192, CROSS = 16384, SQUARE = 32768 }
| PSPNx buttons status mask. More...
## Public Member Functions
| PSPNx (ePortS port, U8 address=PSPNx_DEFAULT_ADDRESS)
| Constructor (activate I2C).
void | setAnalog (void)
| Set the analog pad mode (analog/digital is mutually exclusive).
void | setDigital (void)
| Set the digital pad mode (analog/digital is mutually exclusive).
void | setEnergize (bool enable)
| Set the energize mode.
void | setADPA (bool enable)
| Set the ADPA mode.
void | update (void)
| Call regularly to poll the status of the PSPNx.
bool | pressed (eButtons mask) const
| Check the buttons pressed .
bool | held (eButtons mask) const
| Check the buttons held.
bool | released (eButtons mask) const
| Check the buttons released.
VectorT< S8 > | getLeftStick (void) const
| Get the left stick inputs.
VectorT< S8 > | getRightStick (void) const
| Get the reft stick inputs.
void | get (U8 data[DATA_BUFFER_BYTE_SIZE]) const
| Get raw I2C data from PSPNx.
## Static Public Attributes
static const U8 | PSPNx_DEFAULT_ADDRESS = 0x02
| PSPNx default address.
static const U8 | DATA_BUFFER_BYTE_SIZE = 6
| Size of raw I2C data.

## Detailed Description

Mindsensor PSPNx (http://www.mindsensors.com/index.php?module=pagemaster&PAGE_user_op=view_page&PAGE_id=61) class.

[ How to use with TOPPERS/ATK1(OSEK) ]
I2C (derived/compositted) class and Clock class internally use RTOS features. Thus, user needs to implement a C function and RTOS provided events.
+ Invoke SleeperMonitor function in user_1msec_isr_type2 hook.
void user_1ms_isr_type2(void)
{
SleeperMonitor(); // needed for I2C devices and Clock class
}
+ Define EventSleepI2C and EventSleep Events in user oil file.
EVENT EventSleepI2C
{
MASK = AUTO;
};
EVENT EventSleep
{
MASK = AUTO;
};
TASK TaskMain
{
AUTOSTART = TRUE
{
APPMODE = appmode1;
};
PRIORITY = 1;
ACTIVATION = 1;
SCHEDULE = FULL;
STACKSIZE = 512;
EVENT = EventSleepI2C; <- Here it is
EVENT = EventSleep; <- Here it is
};
[ How to use with TOPPERS/JSP(ITRON) ]
In case of using this class with TOPPERS/JSP(ITRON), RTOS specific definitions for the class are not needed.

## Member Enumeration Documentation

enum ecrobot::PSPNx::eButtons

PSPNx buttons status mask.

Enumerator:

  SELECT | SELECT button.
  LJ | LJ button.
  RJ | RJ button.
  START | START button.
  UP | UP button.
  RIGHT | RIGHT button.
  DOWN | DOWN button.
  LEFT | LEFT button.
  L2 | L2 button.
  R2 | R2 button.
  L1 | L1 button.
  R1 | R1 button.
  TRIANGLE | TRIANGLE button.
  CIRCLE | CIRCLE button.
  CROSS | CROSS button.
  SQUARE | SQUARE button.

## Constructor & Destructor Documentation

ecrobot::PSPNx::PSPNx | ( | ePortS | port,
|  | U8 | address = `PSPNx_DEFAULT_ADDRESS` |
| ) |  |  | `[explicit]`

Constructor (activate I2C).

Note:
This class must be constructed as a global object. Otherwise, a device assertion will be displayed
in the LCD when the object is constructed as a non global object.
When the object is destructed while the system is shut down, the device is de-activated automatically.

Parameters:

  | port | PSPNx connected port
  | address | PSPNx address(currently not used)

Returns:
  -

## Member Function Documentation

void ecrobot::PSPNx::get | ( | U8 | data[DATA_BUFFER_BYTE_SIZE] | ) | const

Get raw I2C data from PSPNx.

Parameters:

  | data |

VectorT<S8> ecrobot::PSPNx::getLeftStick | ( | void |  | ) | const

Get the left stick inputs.

Parameters:

  | - |

Returns:
  Left stick inputs
  VectorT.mX: Left stick input in X axis
  VectorT.mY: Left stick input in Y axis

VectorT<S8> ecrobot::PSPNx::getRightStick | ( | void |  | ) | const

Get the reft stick inputs.

Parameters:

  | - |

Returns:
  Right stick inputs
  VectorT.mX: Right stick input in X axis
  VectorT.mY: Right stick input in Y axis

bool ecrobot::PSPNx::held | ( | eButtons | mask | ) | const

Check the buttons held.

Parameters:

  | mask | PSPNx buttons status mask

Returns:
  true:held/false:not held

bool ecrobot::PSPNx::pressed | ( | eButtons | mask | ) | const

Check the buttons pressed
.

Parameters:

  | mask | PSPNx buttons status mask

Returns:
  true:pressed/false:not pressed

bool ecrobot::PSPNx::released | ( | eButtons | mask | ) | const

Check the buttons released.

Parameters:

  | mask | PSPNx buttons status mask

Returns:
  true:released/false:not released

void ecrobot::PSPNx::setADPA | ( | bool | enable | ) |

Set the ADPA mode.

Parameters:

  | enable | true:enable/false:disable ADPA mode

Returns:
  -

void ecrobot::PSPNx::setAnalog | ( | void |  | ) |

Set the analog pad mode (analog/digital is mutually exclusive).

Parameters:

  | - |

Returns:
  -

void ecrobot::PSPNx::setDigital | ( | void |  | ) |

Set the digital pad mode (analog/digital is mutually exclusive).

Parameters:

  | - |

Returns:
  -

void ecrobot::PSPNx::setEnergize | ( | bool | enable | ) |

Set the energize mode.

Parameters:

  | enable | true:enable/false:disable energize mode

Returns:
  -

void ecrobot::PSPNx::update | ( | void |  | ) |

Call regularly to poll the status of the PSPNx.

Parameters:

  | - |

Returns:
  -

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

- device/PSPNx.h