Package com.tinkerforge
Class BrickletAccelerometer
- java.lang.Object
-
- com.tinkerforge.DeviceBase
-
- com.tinkerforge.Device
-
- com.tinkerforge.BrickletAccelerometer
-
public class BrickletAccelerometer extends Device
Measures acceleration in three axis
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
BrickletAccelerometer.Acceleration
class
BrickletAccelerometer.AccelerationCallbackThreshold
static interface
BrickletAccelerometer.AccelerationListener
This listener is triggered periodically with the period that is set bysetAccelerationCallbackPeriod(long)
.static interface
BrickletAccelerometer.AccelerationReachedListener
This listener is triggered when the threshold as set bysetAccelerationCallbackThreshold(char, short, short, short, short, short, short)
is reached.class
BrickletAccelerometer.Configuration
-
Nested classes/interfaces inherited from class com.tinkerforge.Device
Device.Identity
-
-
Field Summary
-
Constructor Summary
Constructors Constructor Description BrickletAccelerometer(java.lang.String uid, IPConnection ipcon)
Creates an object with the unique device ID \c uid.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAccelerationListener(BrickletAccelerometer.AccelerationListener listener)
Adds a Acceleration listener.void
addAccelerationReachedListener(BrickletAccelerometer.AccelerationReachedListener listener)
Adds a AccelerationReached listener.BrickletAccelerometer.Acceleration
getAcceleration()
Returns the acceleration in x, y and z direction.long
getAccelerationCallbackPeriod()
Returns the period as set bysetAccelerationCallbackPeriod(long)
.BrickletAccelerometer.AccelerationCallbackThreshold
getAccelerationCallbackThreshold()
Returns the threshold as set bysetAccelerationCallbackThreshold(char, short, short, short, short, short, short)
.BrickletAccelerometer.Configuration
getConfiguration()
Returns the configuration as set bysetConfiguration(short, short, short)
.long
getDebouncePeriod()
Returns the debounce period as set bysetDebouncePeriod(long)
.Device.Identity
getIdentity()
Returns the UID, the UID where the Bricklet is connected to, the position, the hardware and firmware version as well as the device identifier.short
getTemperature()
Returns the temperature of the accelerometer.boolean
isLEDOn()
Returns *true* if the LED is enabled, *false* otherwise.void
ledOff()
Disables the LED on the Bricklet.void
ledOn()
Enables the LED on the Bricklet.void
removeAccelerationListener(BrickletAccelerometer.AccelerationListener listener)
Removes a Acceleration listener.void
removeAccelerationReachedListener(BrickletAccelerometer.AccelerationReachedListener listener)
Removes a AccelerationReached listener.void
setAccelerationCallbackPeriod(long period)
Sets the period with which theBrickletAccelerometer.AccelerationListener
listener is triggered periodically.void
setAccelerationCallbackThreshold(char option, short minX, short maxX, short minY, short maxY, short minZ, short maxZ)
Sets the thresholds for theBrickletAccelerometer.AccelerationReachedListener
listener.void
setConfiguration(short dataRate, short fullScale, short filterBandwidth)
Configures the data rate, full scale range and filter bandwidth.void
setDebouncePeriod(long debounce)
Sets the period with which the threshold listener *BrickletAccelerometer.AccelerationReachedListener
is triggered, if the threshold *setAccelerationCallbackThreshold(char, short, short, short, short, short, short)
keeps being reached.-
Methods inherited from class com.tinkerforge.DeviceBase
getAPIVersion, getResponseExpected, setResponseExpected, setResponseExpectedAll
-
-
-
-
Field Detail
-
DEVICE_IDENTIFIER
public static final int DEVICE_IDENTIFIER
- See Also:
- Constant Field Values
-
DEVICE_DISPLAY_NAME
public static final java.lang.String DEVICE_DISPLAY_NAME
- See Also:
- Constant Field Values
-
FUNCTION_GET_ACCELERATION
public static final byte FUNCTION_GET_ACCELERATION
- See Also:
- Constant Field Values
-
FUNCTION_SET_ACCELERATION_CALLBACK_PERIOD
public static final byte FUNCTION_SET_ACCELERATION_CALLBACK_PERIOD
- See Also:
- Constant Field Values
-
FUNCTION_GET_ACCELERATION_CALLBACK_PERIOD
public static final byte FUNCTION_GET_ACCELERATION_CALLBACK_PERIOD
- See Also:
- Constant Field Values
-
FUNCTION_SET_ACCELERATION_CALLBACK_THRESHOLD
public static final byte FUNCTION_SET_ACCELERATION_CALLBACK_THRESHOLD
- See Also:
- Constant Field Values
-
FUNCTION_GET_ACCELERATION_CALLBACK_THRESHOLD
public static final byte FUNCTION_GET_ACCELERATION_CALLBACK_THRESHOLD
- See Also:
- Constant Field Values
-
FUNCTION_SET_DEBOUNCE_PERIOD
public static final byte FUNCTION_SET_DEBOUNCE_PERIOD
- See Also:
- Constant Field Values
-
FUNCTION_GET_DEBOUNCE_PERIOD
public static final byte FUNCTION_GET_DEBOUNCE_PERIOD
- See Also:
- Constant Field Values
-
FUNCTION_GET_TEMPERATURE
public static final byte FUNCTION_GET_TEMPERATURE
- See Also:
- Constant Field Values
-
FUNCTION_SET_CONFIGURATION
public static final byte FUNCTION_SET_CONFIGURATION
- See Also:
- Constant Field Values
-
FUNCTION_GET_CONFIGURATION
public static final byte FUNCTION_GET_CONFIGURATION
- See Also:
- Constant Field Values
-
FUNCTION_LED_ON
public static final byte FUNCTION_LED_ON
- See Also:
- Constant Field Values
-
FUNCTION_LED_OFF
public static final byte FUNCTION_LED_OFF
- See Also:
- Constant Field Values
-
FUNCTION_IS_LED_ON
public static final byte FUNCTION_IS_LED_ON
- See Also:
- Constant Field Values
-
FUNCTION_GET_IDENTITY
public static final byte FUNCTION_GET_IDENTITY
- See Also:
- Constant Field Values
-
THRESHOLD_OPTION_OFF
public static final char THRESHOLD_OPTION_OFF
- See Also:
- Constant Field Values
-
THRESHOLD_OPTION_OUTSIDE
public static final char THRESHOLD_OPTION_OUTSIDE
- See Also:
- Constant Field Values
-
THRESHOLD_OPTION_INSIDE
public static final char THRESHOLD_OPTION_INSIDE
- See Also:
- Constant Field Values
-
THRESHOLD_OPTION_SMALLER
public static final char THRESHOLD_OPTION_SMALLER
- See Also:
- Constant Field Values
-
THRESHOLD_OPTION_GREATER
public static final char THRESHOLD_OPTION_GREATER
- See Also:
- Constant Field Values
-
DATA_RATE_OFF
public static final short DATA_RATE_OFF
- See Also:
- Constant Field Values
-
DATA_RATE_3HZ
public static final short DATA_RATE_3HZ
- See Also:
- Constant Field Values
-
DATA_RATE_6HZ
public static final short DATA_RATE_6HZ
- See Also:
- Constant Field Values
-
DATA_RATE_12HZ
public static final short DATA_RATE_12HZ
- See Also:
- Constant Field Values
-
DATA_RATE_25HZ
public static final short DATA_RATE_25HZ
- See Also:
- Constant Field Values
-
DATA_RATE_50HZ
public static final short DATA_RATE_50HZ
- See Also:
- Constant Field Values
-
DATA_RATE_100HZ
public static final short DATA_RATE_100HZ
- See Also:
- Constant Field Values
-
DATA_RATE_400HZ
public static final short DATA_RATE_400HZ
- See Also:
- Constant Field Values
-
DATA_RATE_800HZ
public static final short DATA_RATE_800HZ
- See Also:
- Constant Field Values
-
DATA_RATE_1600HZ
public static final short DATA_RATE_1600HZ
- See Also:
- Constant Field Values
-
FULL_SCALE_2G
public static final short FULL_SCALE_2G
- See Also:
- Constant Field Values
-
FULL_SCALE_4G
public static final short FULL_SCALE_4G
- See Also:
- Constant Field Values
-
FULL_SCALE_6G
public static final short FULL_SCALE_6G
- See Also:
- Constant Field Values
-
FULL_SCALE_8G
public static final short FULL_SCALE_8G
- See Also:
- Constant Field Values
-
FULL_SCALE_16G
public static final short FULL_SCALE_16G
- See Also:
- Constant Field Values
-
FILTER_BANDWIDTH_800HZ
public static final short FILTER_BANDWIDTH_800HZ
- See Also:
- Constant Field Values
-
FILTER_BANDWIDTH_400HZ
public static final short FILTER_BANDWIDTH_400HZ
- See Also:
- Constant Field Values
-
FILTER_BANDWIDTH_200HZ
public static final short FILTER_BANDWIDTH_200HZ
- See Also:
- Constant Field Values
-
FILTER_BANDWIDTH_50HZ
public static final short FILTER_BANDWIDTH_50HZ
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BrickletAccelerometer
public BrickletAccelerometer(java.lang.String uid, IPConnection ipcon)
Creates an object with the unique device ID \c uid. and adds it to the IP Connection \c ipcon.
-
-
Method Detail
-
getAcceleration
public BrickletAccelerometer.Acceleration getAcceleration() throws TinkerforgeException
Returns the acceleration in x, y and z direction. The values are given in gₙ/1000 (1gₙ = 9.80665m/s²). The range is configured withsetConfiguration(short, short, short)
. If you want to get the acceleration periodically, it is recommended to use theBrickletAccelerometer.AccelerationListener
listener and set the period withsetAccelerationCallbackPeriod(long)
.- Throws:
TinkerforgeException
-
setAccelerationCallbackPeriod
public void setAccelerationCallbackPeriod(long period) throws TinkerforgeException
Sets the period with which theBrickletAccelerometer.AccelerationListener
listener is triggered periodically. A value of 0 turns the listener off. TheBrickletAccelerometer.AccelerationListener
listener is only triggered if the acceleration has changed since the last triggering.- Throws:
TinkerforgeException
-
getAccelerationCallbackPeriod
public long getAccelerationCallbackPeriod() throws TinkerforgeException
Returns the period as set bysetAccelerationCallbackPeriod(long)
.- Throws:
TinkerforgeException
-
setAccelerationCallbackThreshold
public void setAccelerationCallbackThreshold(char option, short minX, short maxX, short minY, short maxY, short minZ, short maxZ) throws TinkerforgeException
Sets the thresholds for theBrickletAccelerometer.AccelerationReachedListener
listener. The following options are possible: \verbatim "Option", "Description" "'x'", "Listener is turned off" "'o'", "Listener is triggered when the acceleration is *outside* the min and max values" "'i'", "Listener is triggered when the acceleration is *inside* the min and max values" "'<'", "Listener is triggered when the acceleration is smaller than the min value (max is ignored)" "'>'", "Listener is triggered when the acceleration is greater than the min value (max is ignored)" \endverbatim- Throws:
TinkerforgeException
-
getAccelerationCallbackThreshold
public BrickletAccelerometer.AccelerationCallbackThreshold getAccelerationCallbackThreshold() throws TinkerforgeException
Returns the threshold as set bysetAccelerationCallbackThreshold(char, short, short, short, short, short, short)
.- Throws:
TinkerforgeException
-
setDebouncePeriod
public void setDebouncePeriod(long debounce) throws TinkerforgeException
Sets the period with which the threshold listener *BrickletAccelerometer.AccelerationReachedListener
is triggered, if the threshold *setAccelerationCallbackThreshold(char, short, short, short, short, short, short)
keeps being reached.- Throws:
TinkerforgeException
-
getDebouncePeriod
public long getDebouncePeriod() throws TinkerforgeException
Returns the debounce period as set bysetDebouncePeriod(long)
.- Throws:
TinkerforgeException
-
getTemperature
public short getTemperature() throws TinkerforgeException
Returns the temperature of the accelerometer.- Throws:
TinkerforgeException
-
setConfiguration
public void setConfiguration(short dataRate, short fullScale, short filterBandwidth) throws TinkerforgeException
Configures the data rate, full scale range and filter bandwidth. Possible values are: * Data rate of 0Hz to 1600Hz. * Full scale range of ±2gₙ up to ±16gₙ. * Filter bandwidth between 50Hz and 800Hz. Decreasing data rate or full scale range will also decrease the noise on the data.- Throws:
TinkerforgeException
-
getConfiguration
public BrickletAccelerometer.Configuration getConfiguration() throws TinkerforgeException
Returns the configuration as set bysetConfiguration(short, short, short)
.- Throws:
TinkerforgeException
-
ledOn
public void ledOn() throws TinkerforgeException
Enables the LED on the Bricklet.- Throws:
TinkerforgeException
-
ledOff
public void ledOff() throws TinkerforgeException
Disables the LED on the Bricklet.- Throws:
TinkerforgeException
-
isLEDOn
public boolean isLEDOn() throws TinkerforgeException
Returns *true* if the LED is enabled, *false* otherwise.- Throws:
TinkerforgeException
-
getIdentity
public Device.Identity getIdentity() throws TinkerforgeException
Returns the UID, the UID where the Bricklet is connected to, the position, the hardware and firmware version as well as the device identifier. The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port). A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at position 'z'. The device identifier numbers can be found :ref:`here <device_identifier>`. |device_identifier_constant|- Specified by:
getIdentity
in classDevice
- Throws:
TinkerforgeException
-
addAccelerationListener
public void addAccelerationListener(BrickletAccelerometer.AccelerationListener listener)
Adds a Acceleration listener.
-
removeAccelerationListener
public void removeAccelerationListener(BrickletAccelerometer.AccelerationListener listener)
Removes a Acceleration listener.
-
addAccelerationReachedListener
public void addAccelerationReachedListener(BrickletAccelerometer.AccelerationReachedListener listener)
Adds a AccelerationReached listener.
-
removeAccelerationReachedListener
public void removeAccelerationReachedListener(BrickletAccelerometer.AccelerationReachedListener listener)
Removes a AccelerationReached listener.
-
-