com.phidgets
Class AccelerometerPhidget

java.lang.Object
  extended by com.phidgets.Phidget
      extended by com.phidgets.AccelerometerPhidget

public final class AccelerometerPhidget
extends Phidget

This class represents a Phidget Accelerometer. All methods to read acceleration data from an Accelerometer are implemented in this class.

The Phidget Accelerometer provides 2-3 axes of acceleration data, at anywhere from 2g to 10g sensitivity, depending on the specific revision. See your hardware documetation for more information. They can measure both static (gravity) and dynamic acceleration.


Constructor Summary
AccelerometerPhidget()
           
 
Method Summary
 void addAccelerationChangeListener(AccelerationChangeListener l)
          Adds an acceleration change listener.
 double getAcceleration(int index)
          Returns the acceleration of a particular axis.
 double getAccelerationChangeTrigger(int index)
          Returns the change trigger for an Axis.
 int getAxisCount()
          Returns the number of accelerometer axes.
 void removeAccelerationChangeListener(AccelerationChangeListener l)
           
 void setAccelerationChangeTrigger(int index, double newVal)
          Sets the change trigger for an Axis.
 
Methods inherited from class com.phidgets.Phidget
addAttachListener, addDetachListener, addErrorListener, close, equals, getDeviceName, getDeviceType, getDeviceVersion, getLibraryVersion, getSerialNumber, getTag, isAttached, open, openAny, removeAttachListener, removeDetachListener, removeErrorListener, setTag, toString, waitForAttachment
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AccelerometerPhidget

public AccelerometerPhidget()
                     throws PhidgetException
Throws:
PhidgetException
Method Detail

getAxisCount

public int getAxisCount()
                 throws PhidgetException
Returns the number of accelerometer axes. Currently all accelerometers provide two axes of acceleration - x, and y.

Returns:
number of axes of acceleration
Throws:
PhidgetException

getAcceleration

public double getAcceleration(int index)
                       throws PhidgetException
Returns the acceleration of a particular axis. This value is returned in g's, where one g of acceleration is equal to gravity. This means that at a standstill each axis will measure between -1.0 and 1.0 g's depending on orientation.

Index 0 is the x-axis, 1 is the y-axis, and 2 is the z-axis (where available).

Parameters:
index - index of the axis
Returns:
acceleration of the selected axis
Throws:
PhidgetException - If this Phidget is not opened and attached, or if the index is out of range. See open for information on determining if a device is attached.

setAccelerationChangeTrigger

public void setAccelerationChangeTrigger(int index,
                                         double newVal)
                                  throws PhidgetException
Sets the change trigger for an Axis. This value is in g's and is by default set to 0. This is the difference in acceleration that must appear between succesive calls to the OnAccelerationChange event handler.

Parameters:
index - index of the axis
newVal - the new change trigger for this axis
Throws:
PhidgetException - If this Phidget is not opened and attached, or if the index is out of range. See open for information on determining if a device is attached.

getAccelerationChangeTrigger

public double getAccelerationChangeTrigger(int index)
                                    throws PhidgetException
Returns the change trigger for an Axis. This value is in g's and is by default set to 0.

Parameters:
index - index of the axis
Returns:
change trigger of the selected axis
Throws:
PhidgetException - If this Phidget is not opened and attached, or if the index is out of range. See open for information on determining if a device is attached.

addAccelerationChangeListener

public final void addAccelerationChangeListener(AccelerationChangeListener l)
Adds an acceleration change listener. The acceleration change handler is a method that will be called when the acceleration of an axis has changed by at least the Trigger that has been set for that axis.

There is no limit on the number of acceleration change handlers that can be registered for a particular Phidget.

Parameters:
l - An implemetation of the AccelerationChangeListener interface

removeAccelerationChangeListener

public final void removeAccelerationChangeListener(AccelerationChangeListener l)