#include <HMC5883Llib.h>
Represents a HMC5883L bassed Magnetometer sensor. You must call begin before calling any other methods.
int8_t Magnetometer::begin |
( |
| ) |
|
Attenpts to connect to the device. You must call begin before calling any other method.
- Returns
- Returns 0 if it successfully connects to the Gyroscope sensor. Returns any other non-zero number if it fails. Check HMC5883Llib.h for the various ERROR definitions.
int8_t Magnetometer::i2cReadBytes |
( |
uint8_t |
reg, |
|
|
uint8_t * |
data, |
|
|
uint8_t |
len |
|
) |
| |
|
protected |
I2C interface function for reading bytes. Uses the Arduino Wire library.
- Parameters
-
reg | The first register to read from. |
data | The array where the data will be read into. |
len | The number of bytes to read. |
- Returns
- Returns 0 on success. Returns any other non-zero number if it fails. Check HMC5883Llib.h for the various ERROR definitions.
int8_t Magnetometer::i2cWriteByte |
( |
uint8_t |
reg, |
|
|
uint8_t |
data |
|
) |
| |
|
protected |
I2C interface function for writing a single byte. Uses the Arduino Wire library.
- Parameters
-
reg | The register address to write to. |
data | The byte to write. |
- Returns
- Returns 0 on success. Returns any other non-zero number if it fails. Check HMC5883Llib.h for the various ERROR definitions.
int8_t Magnetometer::readGauss |
( |
double * |
x, |
|
|
double * |
y, |
|
|
double * |
z |
|
) |
| |
Reads the Gauss experienced by the Magnetometer.
- Parameters
-
x | A pointer to the variable that will get the x data recorded to (in Ga). |
y | A pointer to the variable that will get the y data recorded to (in Ga). |
z | A pointer to the variable that will get the z data recorded to (in Ga). |
- Returns
- Returns 0 on success. Returns any other non-zero number if it fails. Check HMC5883Llib.h for the various ERROR definitions.
int8_t Magnetometer::readHeadingDeg |
( |
double * |
heading | ) |
|
Compass function. Reads the heading in degrees (0-360). Uses the X and Y axes readings to calculate the heading. The sensor must be as level as possible for accurate results.
- Parameters
-
heading | A pointer to the variable that will get the heading recorded to (in degrees). |
- Returns
- Returns 0 on success. Returns any other non-zero number if it fails. Check HMC5883Llib.h for the various ERROR definitions.
int8_t Magnetometer::readRaw |
( |
int16_t * |
x, |
|
|
int16_t * |
y, |
|
|
int16_t * |
z |
|
) |
| |
Reads the RAW data from the magnetometer as a signed 16 bit integer. This integer does not represent Gauss. You'll probably want to use readGauss instead.
- Parameters
-
x | A pointer to the variable that will get the x raw data recorded to. |
y | A pointer to the variable that will get the y raw data recorded to. |
z | A pointer to the variable that will get the z raw data recorded to. |
- Returns
- Returns 0 on success. Returns any other non-zero number if it fails. Check HMC5883Llib.h for the various ERROR definitions.
int8_t Magnetometer::setGain |
( |
uint8_t |
gain | ) |
|
The HMC5883L has an adjustable gain to help you fine tune the sensitivity.
- Parameters
-
gain | The gain definition. Check HMC5883Llib.h for possible arugments. Defaults range is +-1.3Ga. |
- Returns
- Returns 0 on success. Returns any other non-zero number if it fails. Check HMC5883Llib.h for the various ERROR definitions.
uint8_t Magnetometer::gain_ |
|
protected |
The gain definition enum of the device.
uint8_t Magnetometer::i2cAddr_ |
|
protected |
The I2C address of the device.
The documentation for this class was generated from the following files: