BO.io.AccelerometerADXL345 Class
Creates an interface to an ADXL345 3-axis accelerometer. Use the accelerometer to read the acceleration along the x, y, and z axis of an object it is attached to. You can also obtain the pitch and roll. See the example in Breakout/examples/sensors/adxl345.html.
Constructor
BO.io.AccelerometerADXL345
-
board
-
range
-
address
Parameters:
-
board
IOBoardThe IOBoard instance
-
range
NumberThe dynamic range selection in Gs (options
RANGE_2G
,RANGE_4G
,RANGE_8G
,RANGE_16G
). Default isRANGE_2G
. -
address
NumberThe i2c address of the accelerometer (default is 0x53)
Item Index
Methods
Properties
- AccelerometerADXL345.DEFAULT_SENSITIVITY static
- AccelerometerADXL345.DEVICE_ID static
- AccelerometerADXL345.RANGE_16G static
- AccelerometerADXL345.RANGE_2G static
- AccelerometerADXL345.RANGE_4G static
- AccelerometerADXL345.RANGE_8G static
- address
- dynamicRange
- I2CBase.I2C_REPLY
- isRunning
- pitch
- rawX
- rawY
- rawZ
- roll
- sensitivityX
- sensitivityY
- sensitivityZ
- x
- y
- z
Events
Methods
addEventListener
-
type
-
listener
Parameters:
-
type
StringThe event type
-
listener
FunctionThe function to be called when the event is fired
dispatchEvent
-
type
-
optionalParams
Parameters:
-
type
EventThe Event object.
-
optionalParams
ObjectOptional parameters passed as an object. return {boolean} True if dispatch is successful, false if not.
getAxisOffset
()
Get the value of the x, y, and z axis offset.
handleI2C
()
private
hasEventListener
-
type
Parameters:
-
type
StringThe event type return {boolean} True is listener exists for this type, false if not.
powerOn
()
private
readAccel
()
private
removeEventListener
-
type
-
listener
Parameters:
-
type
StringThe event type
-
listener
FunctionThe function to be called when the event is fired
sendI2CRequest
-
command
-
data
Send an i2c request command to the board
Parameters:
-
command
Number -
data
Number
setAxisOffset
()
Offset the x, y, or z axis output by the respective input value.
setRangeAndFullRes
()
private
setRegisterBit
()
private
startReading
()
Start continuous reading of the sensor.
stopReading
()
Stop continuous reading of the sensor.
update
()
Sends read request to accelerometer and updates accelerometer values.
Properties
AccelerometerADXL345.DEFAULT_SENSITIVITY
Unknown
static
AccelerometerADXL345.DEVICE_ID
Unknown
static
AccelerometerADXL345.RANGE_16G
Unknown
static
AccelerometerADXL345.RANGE_2G
Unknown
static
AccelerometerADXL345.RANGE_4G
Unknown
static
AccelerometerADXL345.RANGE_8G
Unknown
static
address
Number
[read-only] The address of the i2c device.
dynamicRange
Number
[read-only] the accelerometer dynamic range in Gs (either 2G, 4G, 8G, or 16G for this sensor)..
I2CBase.I2C_REPLY
Unknown
isRunning
Boolean
[read-only] The state of continuous read mode. True if continuous read mode is enabled, false if it is disabled.
pitch
Number
[read-only] The pitch value in degrees
rawX
Number
[read-only] The raw value of the x axis
rawY
Number
[read-only] The raw value of the y axis
rawZ
Number
[read-only] The raw value of the z axis
roll
Number
[read-only] The roll value in degrees
sensitivityX
Number
The sensitivity value for the x axis (default value = 0.0390625).
sensitivityY
Number
The sensitivity value for the y axis (default value = 0.0390625).
sensitivityZ
Number
The sensitivity value for the z axis (default value = 0.0390625).
x
Number
[read-only] The acceleration value in Gs (9.8m/sec^2) along the x-axis.
y
Number
[read-only] The acceleration value in Gs (9.8m/sec^2) along the y-axis.
z
Number
[read-only] The acceleration value in Gs (9.8m/sec^2) along the z-axis.
Events
update
BO.io.AccelerometerEvent.UPDATE
The update event is dispatched when the accelerometer values are updated.
Event Payload:
-
target
BO.io.AccelerometerADXL345A reference to the AccelerometerADXL345 object.