lejos.nxt.addon
Class AccelMindSensor

java.lang.Object
  extended by lejos.nxt.I2CSensor
      extended by lejos.nxt.addon.AccelMindSensor
All Implemented Interfaces:
SensorConstants, Accelerometer

public class AccelMindSensor
extends I2CSensor
implements Accelerometer

This class works with the Mindsensors acceleration (tilt) sensor ACCL-Nx-v2/v3. TODO there are a lot of features not supported by this class


Field Summary
static int ERROR
           
 
Fields inherited from class lejos.nxt.I2CSensor
address, DEFAULT_I2C_ADDRESS, port, REG_PRODUCT_ID, REG_VENDOR_ID, REG_VERSION
 
Fields inherited from interface lejos.nxt.SensorConstants
BLACK, BLANK_INDEX, BLUE, BLUE_INDEX, GREEN, GREEN_INDEX, MAX_AD_RAW, MAX_TYPE, MIN_TYPE, MODE_ANGLESTEP, MODE_BOOLEAN, MODE_CELSIUS, MODE_FARENHEIT, MODE_PCTFULLSCALE, MODE_PERIODCOUNTER, MODE_RAW, MODE_TRANSITIONCNT, RED, RED_INDEX, TYPE_ANGLE, TYPE_COLORBLUE, TYPE_COLORFULL, TYPE_COLORGREEN, TYPE_COLORNONE, TYPE_COLORRED, TYPE_CUSTOM, TYPE_HISPEED, TYPE_LIGHT_ACTIVE, TYPE_LIGHT_INACTIVE, TYPE_LOWSPEED, TYPE_LOWSPEED_9V, TYPE_NO_SENSOR, TYPE_REFLECTION, TYPE_SOUND_DB, TYPE_SOUND_DBA, TYPE_SWITCH, TYPE_TEMPERATURE, WHITE, YELLOW
 
Constructor Summary
AccelMindSensor(I2CPort port)
           
AccelMindSensor(I2CPort port, int address)
           
 
Method Summary
 boolean getAllAccel(int[] dst, int off)
          Reads all 3 acceleration values into the given array.
 boolean getAllTilt(int[] dst, int off)
          Reads all 3 tilt values into the given array.
 int getXAccel()
          Acceleration along X axis.
 int getXTilt()
          Tilt of sensor along X-axis (see top of Mindsensors.com sensor for diagram of axis).
 int getYAccel()
          Acceleration along Y axis.
 int getYTilt()
          Returns Y tilt value (see top of Mindsensors.com sensor for diagram of axis).
 int getZAccel()
          Acceleration along Z axis.
 int getZTilt()
          Returns Z tilt value (see top of Mindsensors.com sensor for diagram of axis).
 
Methods inherited from class lejos.nxt.I2CSensor
fetchString, getAddress, getData, getData, getData, getId, getProductID, getVendorID, getVersion, sendData, sendData, sendData, setAddress
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ERROR

public static final int ERROR
See Also:
Constant Field Values
Constructor Detail

AccelMindSensor

public AccelMindSensor(I2CPort port)

AccelMindSensor

public AccelMindSensor(I2CPort port,
                       int address)
Method Detail

getXTilt

public int getXTilt()
Tilt of sensor along X-axis (see top of Mindsensors.com sensor for diagram of axis). 0 is level.

Returns:
X tilt value in degrees, or ERROR if call failed

getYTilt

public int getYTilt()
Returns Y tilt value (see top of Mindsensors.com sensor for diagram of axis). 0 is level.

Returns:
Y tilt value in degrees, or ERROR if call failed

getZTilt

public int getZTilt()
Returns Z tilt value (see top of Mindsensors.com sensor for diagram of axis). 0 is level.

Returns:
Z tilt value in degrees, or ERROR if call failed

getXAccel

public int getXAccel()
Acceleration along X axis. Positive or negative values in mg. (g = acceleration due to gravity = 9.81 m/s^2)

Specified by:
getXAccel in interface Accelerometer
Returns:
Acceleration e.g. 9810 mg (falling on earth) or ERROR.

getYAccel

public int getYAccel()
Acceleration along Y axis. Positive or negative values in mg. (g = acceleration due to gravity = 9.81 m/s^2)

Specified by:
getYAccel in interface Accelerometer
Returns:
Acceleration e.g. 9810 mg (falling on earth) or ERROR.

getZAccel

public int getZAccel()
Acceleration along Z axis. Positive or negative values in mg. (g = acceleration due to gravity = 9.81 m/s^2)

Specified by:
getZAccel in interface Accelerometer
Returns:
Acceleration e.g. 9810 mg (falling on earth) or ERROR.

getAllTilt

public boolean getAllTilt(int[] dst,
                          int off)
Reads all 3 tilt values into the given array. Elements off+0, off+1, and off+2 are filled with X, Y, and Z axis.

Parameters:
dst - destination array.
off - offset
Returns:
true on success, false on error

getAllAccel

public boolean getAllAccel(int[] dst,
                           int off)
Reads all 3 acceleration values into the given array. Elements off+0, off+1, and off+2 are filled with X, Y, and Z axis.

Parameters:
dst - destination array.
off - offset
Returns:
true on success, false on error