Show:
Extends webduino.Module

The ADXL345 class.

ADXL345 is a small, thin, ultralow power, 3-axis accelerometer.

Constructor

webduino.module.ADXL345
(
  • board
)

Parameters:

  • board webduino.Board

    The board that the ADXL345 accelerometer is attached to.

Methods

addListener
(
  • type
  • listener
)

Add a listener for a certain type of event.

Parameters:

  • type String

    Event type.

  • listener Function

    Event listener.

detect
(
  • callback
)

Start detection.

Parameters:

  • [callback] Function optional

    Detection callback.

emit
(
  • type
  • object,...
)

Emit an event of certain type.

Parameters:

  • type String

    Event type.

  • [object,...] Object optional

    Event object(s).

listeners
(
  • type
)

Return the listener list bound to certain type of event.

Parameters:

  • type String

    Evnet type.

off ()

Stop detection.

on
(
  • callback
)
deprecated

Inherited from webduino.EventEmitter but overwritten in src/module/ADXL345.js:149

Deprecated: `on()` is deprecated, use `detect()` instead.

Start detection.

Parameters:

  • [callback] Function optional

    Detection callback.

once
(
  • type
  • listener
)

Add a one-time listener for a certain type of event.

Parameters:

  • type String

    Event type.

  • listener Function

    Event listener.

refresh ()

Reset detection value.

removeAllListeners
(
  • type
)

Remove all listeners of certain type.

Parameters:

  • type String

    Event type.

removeListener
(
  • type
  • listener
)

Remove a listener for certain type of event.

Parameters:

  • type String

    Event type.

  • listener Function

    Event listener.

setBaseAxis
(
  • axis
)

Set the base axis for calculation.

Parameters:

  • axis String

    Axis to be set to, either x, y, or z.

setDetectTime
(
  • detectTime
)

Set detecting time period.

Parameters:

  • detectTime Number

    The time period for detecting, in ms.

setMaxListeners
(
  • n
)

Set maximum number of listeners that is allow to bind on an emitter.

Parameters:

  • n Number

    Number of listeners.

setSensitivity
(
  • sensitivity
)

Set detection sensitivity.

Parameters:

  • sensitivity Number

    Detection sensitivity.

Attributes

state

String on or off

The state indicating whether the accelerometer is detecting.

type

String readonly

Type of the module.

Events

ADXL234Event.MESSAGE

Fires when the accelerometer senses a value change.