Show:

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 IOBoard

    The IOBoard instance

  • range Number

    The dynamic range selection in Gs (options RANGE_2G, RANGE_4G, RANGE_8G, RANGE_16G). Default is RANGE_2G.

  • address Number

    The i2c address of the accelerometer (default is 0x53)

Methods

addEventListener

(
  • type
  • listener
)

Parameters:

  • type String

    The event type

  • listener Function

    The function to be called when the event is fired

dispatchEvent

(
  • type
  • optionalParams
)

Parameters:

  • type Event

    The Event object.

  • optionalParams Object

    Optional 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

Inherited from BO.I2CBase but overwritten in src/io/AccelerometerADXL345.js:288

hasEventListener

(
  • type
)

Parameters:

  • type String

    The event type return {boolean} True is listener exists for this type, false if not.

powerOn

() private

readAccel

() private

removeEventListener

(
  • type
  • listener
)

Parameters:

  • type String

    The event type

  • listener Function

    The function to be called when the event is fired

sendI2CRequest

(
  • command
  • data
)
protected

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

()

Inherited from BO.I2CBase but overwritten in src/io/AccelerometerADXL345.js:360

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: