BO.io.MagnetometerHMC5883 Class
Creates an interface to an HMC5883 3-axis magnetometer. Use the magnetometer to obtain a compass heading or rotation in relation to a fixed point. See Breakout/examples/sensors/hmc5883.html for an example application.
Constructor
BO.io.MagnetometerHMC5883
-
board
-
address
-
numSamples
-
outputRate
Parameters:
-
board
IOBoardThe IOBoard instance
-
address
NumberThe i2c address of the compass module
-
numSamples
NumberThe number of samples averaged per measurement output. Options are:
MagnetometerHMC5883.SAMPLES_1
,MagnetometerHMC5883.SAMPLES_2
,MagnetometerHMC5883.SAMPLES_4
MagnetometerHMC5883.SAMPLES_8
(default =MagnetometerHMC5883.SAMPLES_1
) -
outputRate
NumberThe data output rate in Hz (default =
MagnetometerHMC5883.HZ_30
)
Item Index
Methods
Properties
- address
- heading
- I2CBase.I2C_REPLY
- MagnetometerHMC5883.DEVICE_ID static
- MagnetometerHMC5883.HZ_0_75 static
- MagnetometerHMC5883.HZ_15 static
- MagnetometerHMC5883.HZ_1_5 static
- MagnetometerHMC5883.HZ_3 static
- MagnetometerHMC5883.HZ_30 static
- MagnetometerHMC5883.HZ_75 static
- MagnetometerHMC5883.HZ_7_5 static
- MagnetometerHMC5883.SAMPLES_1 static
- MagnetometerHMC5883.SAMPLES_2 static
- MagnetometerHMC5883.SAMPLES_4 static
- MagnetometerHMC5883.SAMPLES_8 static
- 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.
getHeading
()
private
getTiltCompensatedHeading
-
pitch
-
roll
Get a tilt-compensated heading. Pitch and roll values from an accelerometer must be passed to this method.
Note: this method is not working properly. Marking it private until resolved
Parameters:
-
pitch
NumberThe pitch value (supplied by an accelerometer)
-
roll
NumberThe roll value (supplied by an accelerometer)
Returns:
tilt-compensated heading direction
handleI2C
()
private
hasEventListener
-
type
Parameters:
-
type
StringThe event type return {boolean} True is listener exists for this type, false if not.
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
startReading
()
Start continuous reading of the sensor.
stopReading
()
Stop continuous reading of the sensor.
update
()
Sends read request to magnetometer and updates magnetometer values.
Properties
address
Number
[read-only] The address of the i2c device.
heading
Number
[read-only] The heading in degrees.
I2CBase.I2C_REPLY
Unknown
MagnetometerHMC5883.DEVICE_ID
Unknown
static
MagnetometerHMC5883.HZ_0_75
Unknown
static
MagnetometerHMC5883.HZ_15
Unknown
static
MagnetometerHMC5883.HZ_1_5
Unknown
static
MagnetometerHMC5883.HZ_3
Unknown
static
MagnetometerHMC5883.HZ_30
Unknown
static
MagnetometerHMC5883.HZ_75
Unknown
static
MagnetometerHMC5883.HZ_7_5
Unknown
static
MagnetometerHMC5883.SAMPLES_1
Unknown
static
MagnetometerHMC5883.SAMPLES_2
Unknown
static
MagnetometerHMC5883.SAMPLES_4
Unknown
static
MagnetometerHMC5883.SAMPLES_8
Unknown
static
x
Number
[read-only] The x-axis measurement
y
Number
[read-only] The y-axis measurement
z
Number
[read-only] The z-axis measurement
Events
update
BO.io.MagnetometerEvent.UPDATE
The update event is dispatched when the compass heading is updated.
Event Payload:
-
target
BO.io.MagnetometerHMC5883A reference to the MagnetometerHMC5883 object.