Show:

BO.io.AnalogAccelerometer Class

Creates an interface to an analog 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. This object should interface with most analog accelerometers. See Breakout/examples/sensors/analog_accelerometer.html and Breakout/examples/three_js/accelerometer.html for example applications.

Constructor

BO.io.AnalogAccelerometer

(
  • board
  • xPin
  • yPin
  • zPin
  • dynamicRange
  • enableSmoothing
)

Parameters:

  • board IOBoard

    A reference to the IOBoard instance

  • xPin Pin

    A reference to the Pin connected to the x axis of the accelerometer

  • yPin Pin

    A reference to the Pin connected to the y axis of the accelerometer

  • zPin Pin

    A reference to the Pin connected to the z axis of the accelerometer

  • dynamicRange Number

    The range of the acceleromter in Gs (typically 2 or 3 for an analog accelerometer). See the datasheet for the acceleromter to get the exact value.

  • enableSmoothing Boolean

    True to enable smoothing, false to disable. Default is false.

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.

getCalibratedRange

(
  • minVoltage
  • maxVoltage
  • supplyVoltage
)
Object

Use this method to get the minimum and maximum range values for an axis. Create a new object to store the return value and then pass obj.min and obj.max along with the respective axis identifier to the setRangeFor method.

Parameters:

  • minVoltage Number

    The minimum value reported on the axis

  • maxVoltage Number

    The maximum value reported on the axis

  • supplyVoltage Number

    The supply voltage of the Acceleromter (enter as 3.3, 3.0, 5.0, etc).

Returns:

Object:

An object containing the min and max range values to be passed to the setRangeFor method.

hasEventListener

(
  • type
)

Parameters:

  • type String

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

removeEventListener

(
  • type
  • listener
)

Parameters:

  • type String

    The event type

  • listener Function

    The function to be called when the event is fired

setRangeFor

(
  • axis
  • minimum
  • maximum
)

Scale the range for the specified axis (from 0 to 1) to (minimum to maximum).

Parameters:

  • axis Object

    the axis to set new range (AnalogAccelerometer.X_AXIS, AnalogAccelerometer.Y_AXIS or AnalogAccelerometer.Z_AXIS).

  • minimum Number

    The new minimum value

  • maximum Number

    The new maximum value

xAxisChanged

() private

yAxisChanged

() private

zAxisChanged

() private

Properties

AnalogAccelerometer.X_AXIS

Unknown static

AnalogAccelerometer.Y_AXIS

Unknown static

AnalogAccelerometer.Z_AXIS

Unknown static

dynamicRange

Number

[read-only] the accelerometer dynamic range in Gs (either 2G, 4G, 8G, or 16G for this sensor)..

pitch

Number

[read-only] The pitch value in degrees

roll

Number

[read-only] The roll value in degrees

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: