Show:

BO.io.CompassHMC6352 Class

Creates an interface to an HMC6352 Digital Compass module. Use the compass to obtain a heading. You must hold the sensor flat to obtain the most accurate heading value (just like an analog compass). The compass is also useful in obtaining a rotation value in relation to a fixed position. See Breakout/examples/sensors/hmc6352.html and Breakout/examples/processing_js/compass.html for example applications.

Constructor

BO.io.CompassHMC6352

(
  • board
  • address
)

Parameters:

  • board IOBoard

    The IOBoard instance

  • address Number

    The i2c address of the compass module

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.

handleI2C

() private

Inherited from BO.I2CBase but overwritten in src/io/CompassHMC6352.js:62

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

sendI2CRequest

(
  • command
  • data
)
protected

Send an i2c request command to the board

Parameters:

  • command Number
  • data Number

startReading

()

Start continuous reading of the sensor.

stopReading

()

Stop continuous reading of the sensor

update

() protected

To be implemented in subclass

Properties

address

Number

[read-only] The address of the i2c device.

heading

Number

[read-only] The heading in degrees.

I2CBase.I2C_REPLY

Unknown

Events

update

BO.io.CompassEvent.UPDATE

The update event is dispatched when the compass heading is updated.

Event Payload: