SunSPOT API V5.0


com.sun.spot.sensorboard.peripheral
Interface IAccelerometer3D

All Known Implementing Classes:
LIS3L02AQAccelerometer

public interface IAccelerometer3D

IAccelerometer3D provides methods that should be meaningful for any 3-axis accelerometer. One set of methods return the current acceleration measured along each axis. Another set of methods return the current acceleration relative to a previously measured acceleration. This allows one to zero out the force of gravity on the SPOT and measure the relative acceleration only. A third set of methods use the acceleration along an axis in order to compute the inclination, or tilt, of that axis.

Author:
Ron Goldman

Field Summary
static boolean ABSOLUTE
           
static int ALL_AXES
           
static boolean RELATIVE
           
static int X_AXIS
           
static int Y_AXIS
           
static int Z_AXIS
           
 
Method Summary
 void addIAccelerometer3DThresholdListener(IAccelerometer3DThresholdListener who)
          Adds the specified accelerometer threshold listener to receive callbacks from this accelerometer.
 boolean areThresholdEventsEnabled(int axis)
          Return whether threshold events are enabled or not.
 void enableThresholdEvents(int axis, boolean enable)
          Enable or disable threshold events.
 double getAccel()
          Compute the current total acceleration.
 double getAccel(int axis)
          Compute the current acceleration for the indicated axis.
 double getAccelX()
          Read the current acceleration along the X axis.
 double getAccelY()
          Read the current acceleration along the Y axis.
 double getAccelZ()
          Read the current acceleration along the Z axis.
 double getHighThreshold(int axis, boolean relative)
          Return the current high threshold value.
 IAccelerometer3DThresholdListener[] getIAccelerometer3DThresholdListeners()
          Returns an array of all the accelerometer threshold listeners registered on this input device.
 double getLowThreshold(int axis, boolean relative)
          Return the current low threshold value.
 double getRelativeAccel()
          Compute the current relative total acceleration.
 double getRelativeAccel(int axis)
          Compute the current relative acceleration for the indicated axis.
 double getRelativeAccelX()
          Read the current relative acceleration along the X axis.
 double getRelativeAccelY()
          Read the current relative acceleration along the Y axis.
 double getRelativeAccelZ()
          Read the current relative acceleration along the Z axis.
 double getTilt(int axis)
          Compute the inclination of the specified SPOT axis.
 double getTiltX()
          Compute the inclination of the SPOT's X axis.
 double getTiltY()
          Compute the inclination of the SPOT's Y axis.
 double getTiltZ()
          Compute the inclination of the SPOT's Z axis.
 void removeIAccelerometer3DThresholdListener(IAccelerometer3DThresholdListener who)
          Removes the specified accelerometer threshold listener so that it no longer receives callbacks from this input device.
 void setRestOffsets()
          Compute the current acceleration along each axis and save it.
 void setThresholds(int axis, double low, double high, boolean relative)
          Set the low and high threshold values for this accelerometer.
 boolean supportsThresholdEvents()
          Returns whether the underlying hardware supports threshold events.
 

Field Detail

X_AXIS

static final int X_AXIS
See Also:
Constant Field Values

Y_AXIS

static final int Y_AXIS
See Also:
Constant Field Values

Z_AXIS

static final int Z_AXIS
See Also:
Constant Field Values

ALL_AXES

static final int ALL_AXES
See Also:
Constant Field Values

RELATIVE

static final boolean RELATIVE
See Also:
Constant Field Values

ABSOLUTE

static final boolean ABSOLUTE
See Also:
Constant Field Values
Method Detail

getAccelX

double getAccelX()
                 throws IOException
Read the current acceleration along the X axis.

Returns:
the current acceleration in G's along the X axis
Throws:
IOException

getAccelY

double getAccelY()
                 throws IOException
Read the current acceleration along the Y axis.

Returns:
the current acceleration in G's along the Y axis
Throws:
IOException

getAccelZ

double getAccelZ()
                 throws IOException
Read the current acceleration along the Z axis.

Returns:
the current acceleration in G's along the Z axis
Throws:
IOException

getAccel

double getAccel()
                throws IOException
Compute the current total acceleration. This is the vector sum of the acceleration along the X, Y & Z axes.

Returns:
the current total acceleration in G's
Throws:
IOException

getAccel

double getAccel(int axis)
                throws IOException
Compute the current acceleration for the indicated axis.

Parameters:
axis - which axis to return (ALL_AXES = total acceleration)
Returns:
the current acceleration in G's
Throws:
IOException

setRestOffsets

void setRestOffsets()
                    throws IOException
Compute the current acceleration along each axis and save it. Use this to later be able to compute the acceleration relative to this value.

Throws:
IOException

getRelativeAccelX

double getRelativeAccelX()
                         throws IOException
Read the current relative acceleration along the X axis. This value is relative to the last call to setRestOffsets().

Returns:
the current relative acceleration in G's along the X axis
Throws:
IOException

getRelativeAccelY

double getRelativeAccelY()
                         throws IOException
Read the current relative acceleration along the Y axis. This value is relative to the last call to setRestOffsets().

Returns:
the current relative acceleration in G's along the Y axis
Throws:
IOException

getRelativeAccelZ

double getRelativeAccelZ()
                         throws IOException
Read the current relative acceleration along the Z axis. This value is relative to the last call to setRestOffsets().

Returns:
the current relative acceleration in G's along the Z axis
Throws:
IOException

getRelativeAccel

double getRelativeAccel()
                        throws IOException
Compute the current relative total acceleration. This is the vector sum of the relative acceleration along the X, Y & Z axes.

Returns:
the current total relative acceleration in G's
Throws:
IOException

getRelativeAccel

double getRelativeAccel(int axis)
                        throws IOException
Compute the current relative acceleration for the indicated axis.

Parameters:
axis - which axis to return (ALL_AXES = total acceleration)
Returns:
the current relative acceleration in G's
Throws:
IOException

getTiltX

double getTiltX()
                throws IOException
Compute the inclination of the SPOT's X axis. This angle is with respect to any acceleration if the SPOT is moving.

Returns:
the current angle of the X axis in radians, in the range of -pi/2 through pi/2.
Throws:
IOException

getTiltY

double getTiltY()
                throws IOException
Compute the inclination of the SPOT's Y axis. This angle is with respect to any acceleration if the SPOT is moving.

Returns:
the current angle of the Y axis in radians, in the range of -pi/2 through pi/2.
Throws:
IOException

getTiltZ

double getTiltZ()
                throws IOException
Compute the inclination of the SPOT's Z axis. This angle is with respect to any acceleration if the SPOT is moving.

Returns:
the current angle of the Z axis in radians, in the range of -pi/2 through pi/2.
Throws:
IOException

getTilt

double getTilt(int axis)
               throws IOException
Compute the inclination of the specified SPOT axis. This angle is with respect to any acceleration if the SPOT is moving.

Parameters:
axis - which axis to return Note: specifying ALL_AXES will throw an IllegalArgumentException.
Returns:
the current angle of the indicated axis in radians, in the range of -pi/2 through pi/2.
Throws:
IOException

supportsThresholdEvents

boolean supportsThresholdEvents()
Returns whether the underlying hardware supports threshold events.

Returns:
true if threshold events are supported

addIAccelerometer3DThresholdListener

void addIAccelerometer3DThresholdListener(IAccelerometer3DThresholdListener who)
Adds the specified accelerometer threshold listener to receive callbacks from this accelerometer. Callbacks occur when the accelerometer reading for any axis falls below or equal to the low threshold value, or when it rises above or equal to the high threshold value.

Parameters:
who - the accelerometer threshold listener to add.

removeIAccelerometer3DThresholdListener

void removeIAccelerometer3DThresholdListener(IAccelerometer3DThresholdListener who)
Removes the specified accelerometer threshold listener so that it no longer receives callbacks from this input device. This method performs no function, nor does it throw an exception, if the listener specified by the argument was not previously added to this input device.

Parameters:
who - the accelerometer threshold listener to remove.

getIAccelerometer3DThresholdListeners

IAccelerometer3DThresholdListener[] getIAccelerometer3DThresholdListeners()
Returns an array of all the accelerometer threshold listeners registered on this input device.

Returns:
all of this accelerometer's IAccelerometer3DThresholdListener or an empty array if no accelerometer threshold listeners are currently registered.

setThresholds

void setThresholds(int axis,
                   double low,
                   double high,
                   boolean relative)
Set the low and high threshold values for this accelerometer. Callbacks occur when the accelerometer reading of the specified axis falls below or equal to the low threshold value, or when it rises above or equal to the high threshold value.

Parameters:
axis - which axis to set threshold values for.
low - the new low threshold value.
high - the new high threshold value.
relative - compute threshold relative to the current rest offset.

getLowThreshold

double getLowThreshold(int axis,
                       boolean relative)
Return the current low threshold value.

Parameters:
axis - which axis to return Note: specifying ALL_AXES will throw an IllegalArgumentException.
relative - if true then threshold is relative to the current rest offset.
Returns:
the current low threshold value.

getHighThreshold

double getHighThreshold(int axis,
                        boolean relative)
Return the current high threshold value.

Parameters:
axis - which axis to return Note: specifying ALL_AXES will throw an IllegalArgumentException.
relative - if true then threshold is relative to the current rest offset.
Returns:
the current high threshold value.

enableThresholdEvents

void enableThresholdEvents(int axis,
                           boolean enable)
Enable or disable threshold events.

Parameters:
axis - which axis to enable
enable - if true then listeners will be notified if the scalar input reading goes above the high threshold or below the low threshold.

areThresholdEventsEnabled

boolean areThresholdEventsEnabled(int axis)
Return whether threshold events are enabled or not.

Parameters:
axis - which axis to return Note: specifying ALL_AXES will return true only if all three axes are enabled.
Returns:
true if listeners will be notified if the scalar input reading goes above the high threshold or below the low threshold.

SunSPOT API V5.0


Copyright � 2006-2008 Sun Microsystems, Inc. All Rights Reserved.