com.phidgets
Class AccelerometerPhidget

java.lang.Object
  extended bycom.phidgets.Phidget
      extended bycom.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 or 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.

Author:
Phidgets Inc.

Field Summary
 
Fields inherited from class com.phidgets.Phidget
PHIDCLASS_ACCELEROMETER, PHIDCLASS_ADVANCEDSERVO, PHIDCLASS_ANALOG, PHIDCLASS_BRIDGE, PHIDCLASS_ENCODER, PHIDCLASS_FREQUENCYCOUNTER, PHIDCLASS_GPS, PHIDCLASS_INTERFACEKIT, PHIDCLASS_LED, PHIDCLASS_MOTORCONTROL, PHIDCLASS_NOTHING, PHIDCLASS_PHSENSOR, PHIDCLASS_RFID, PHIDCLASS_SERVO, PHIDCLASS_STEPPER, PHIDCLASS_TEMPERATURESENSOR, PHIDCLASS_TEXTLCD, PHIDCLASS_TEXTLED, PHIDCLASS_WEIGHTSENSOR, PHIDGET_LOG_CRITICAL, PHIDGET_LOG_DEBUG, PHIDGET_LOG_ERROR, PHIDGET_LOG_INFO, PHIDGET_LOG_VERBOSE, PHIDGET_LOG_WARNING, PHIDID_ACCELEROMETER_2AXIS, PHIDID_ACCELEROMETER_3AXIS, PHIDID_ADVANCEDSERVO_1MOTOR, PHIDID_ADVANCEDSERVO_8MOTOR, PHIDID_ANALOG_4OUTPUT, PHIDID_BIPOLAR_STEPPER_1MOTOR, PHIDID_BRIDGE_4INPUT, PHIDID_ENCODER_1ENCODER_1INPUT, PHIDID_ENCODER_HS_1ENCODER, PHIDID_ENCODER_HS_4ENCODER_4INPUT, PHIDID_FREQUENCYCOUNTER_2INPUT, PHIDID_GPS, PHIDID_INTERFACEKIT_0_0_4, PHIDID_INTERFACEKIT_0_0_8, PHIDID_INTERFACEKIT_0_16_16, PHIDID_INTERFACEKIT_0_8_8_w_LCD, PHIDID_INTERFACEKIT_2_2_2, PHIDID_INTERFACEKIT_4_8_8, PHIDID_INTERFACEKIT_8_8_8, PHIDID_INTERFACEKIT_8_8_8_w_LCD, PHIDID_IR, PHIDID_LED_64, PHIDID_LED_64_ADV, PHIDID_LINEAR_TOUCH, PHIDID_MOTORCONTROL_1MOTOR, PHIDID_MOTORCONTROL_HC_2MOTOR, PHIDID_MOTORCONTROL_LV_2MOTOR_4INPUT, PHIDID_NOTHING, PHIDID_PHSENSOR, PHIDID_RFID, PHIDID_RFID_2OUTPUT, PHIDID_RFID_2OUTPUT_READ_WRITE, PHIDID_ROTARY_TOUCH, PHIDID_SERVO_1MOTOR, PHIDID_SERVO_1MOTOR_OLD, PHIDID_SERVO_4MOTOR, PHIDID_SERVO_4MOTOR_OLD, PHIDID_SPATIAL_ACCEL_3AXIS, PHIDID_SPATIAL_ACCEL_GYRO_COMPASS, PHIDID_TEMPERATURESENSOR, PHIDID_TEMPERATURESENSOR_4, PHIDID_TEMPERATURESENSOR_IR, PHIDID_TEXTLCD_2x20, PHIDID_TEXTLCD_2x20_w_0_8_8, PHIDID_TEXTLCD_2x20_w_8_8_8, PHIDID_TEXTLCD_ADAPTER, PHIDID_TEXTLED_1x8, PHIDID_TEXTLED_4x8, PHIDID_UNIPOLAR_STEPPER_4MOTOR, PHIDID_WEIGHTSENSOR
 
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.
 double getAccelerationMax(int index)
          Returns the maximum acceleration value that this axis will report.
 double getAccelerationMin(int index)
          Returns the minimum acceleration value that this axis will report.
 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, addServerConnectListener, addServerDisconnectListener, close, disableLogging, enableLogging, equals, getDeviceClass, getDeviceID, getDeviceLabel, getDeviceName, getDeviceType, getDeviceVersion, getLibraryVersion, getSerialNumber, getServerAddress, getServerID, getServerPort, isAttached, isAttachedToServer, log, open, open, open, open, open, openAny, openAny, openAny, openAny, openAny, openLabel, openLabel, openLabel, openLabel, openLabel, removeAttachListener, removeDetachListener, removeErrorListener, removeServerConnectListener, removeServerDisconnectListener, setDeviceLabel, toString, waitForAttachment, waitForAttachment
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AccelerometerPhidget

public AccelerometerPhidget()
                     throws PhidgetException
Method Detail

getAxisCount

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

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.

This value will always be between getAccelerationMin and getAccelerationMax.

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.

getAccelerationMax

public double getAccelerationMax(int index)
                          throws PhidgetException
Returns the maximum acceleration value that this axis will report. This will be set to just higher then the maximum acceleration that this axis can measure. If the acceleration is equal to this maximum, assume that that axis is saturated beyond what it can measure.

Returns:
maximum acceleration
Throws:
PhidgetException

getAccelerationMin

public double getAccelerationMin(int index)
                          throws PhidgetException
Returns the minimum acceleration value that this axis will report. This will be set to just lower then the minimum acceleration that this axis can measure. If the acceleration is equal to this minimum, assume that that axis is saturated beyond what it can measure.

Returns:
minimum acceleration
Throws:
PhidgetException

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)