lejos.nxt.addon
Class AccelHTSensor

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

public class AccelHTSensor
extends I2CSensor
implements Accelerometer

Class to access the HiTechnic NXT Acceleration / Tilt Sensor (NAC1040). Some sensors seem to be badly calibrated, so 0 is not always level.


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
AccelHTSensor(I2CPort port)
           
AccelHTSensor(I2CPort port, int address)
           
 
Method Summary
 boolean getAllAccel(int[] dst, int off)
          Reads all 3 acceleration values into the given array.
 int getXAccel()
          Acceleration along X axis.
 int getYAccel()
          Acceleration along Y axis.
 int getZAccel()
          Acceleration along Z axis.
 
Methods inherited from class lejos.nxt.I2CSensor
fetchString, getAddress, getData, getData, getPort, 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

AccelHTSensor

public AccelHTSensor(I2CPort port)

AccelHTSensor

public AccelHTSensor(I2CPort port,
                     int address)
Method Detail

getXAccel

public int getXAccel()
Acceleration along X axis. Positive or negative values. A value of 200 is equivalent to 1g.

Specified by:
getXAccel in interface Accelerometer
Returns:
x-axis acceleration or ERROR.

getYAccel

public int getYAccel()
Acceleration along Y axis. Positive or negative values. A value of 200 is equivalent to 1g.

Specified by:
getYAccel in interface Accelerometer
Returns:
y-axis acceleration or ERROR.

getZAccel

public int getZAccel()
Acceleration along Z axis. Positive or negative values. A value of 200 is equivalent to 1g.

Specified by:
getZAccel in interface Accelerometer
Returns:
z-axis acceleration or 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