Modified MAG3110 with individual X, Y, and Z sampling

Dependents:   test

Fork of MAG3110 by Andrew Lindsay

Embed: (wiki syntax)

« Back to documentation index

MAG3110 Class Reference

MAG3110 Class Reference

MAG3110 Class to read X/Y/Z data from the magentometer. More...

#include <MAG3110.h>

Public Member Functions

 MAG3110 (PinName sda, PinName scl)
 Main constructor.
 MAG3110 (PinName sda, PinName scl, Serial *pc)
 Debug version of constructor.
void begin ()
 Setup the Magnetometer.
int readReg (char regAddr)
 Read a register, return its value as int.
int readVal (char regAddr)
 Read a value from a pair of registers, return as int.
float getHeading ()
 Calculate the heading.
int getXVal ()
 Perform a read on the X, Y and Z values.
int getYVal ()
 Reads and returns X value using readVal.
int getZVal ()
 Reads and returns Y value using readVal.
void getValues (int *xVal, int *yVal, int *zVal)
 Reads and returns Z value using readVal.
void setCalibration (int minX, int maxX, int minY, int maxY)
 Set the calibration parameters if required.

Detailed Description

MAG3110 Class to read X/Y/Z data from the magentometer.

Definition at line 80 of file MAG3110.h.


Constructor & Destructor Documentation

MAG3110 ( PinName  sda,
PinName  scl 
)

Main constructor.

Parameters:
sdaSDA pin
sdlSCL pin
addraddr of the I2C peripheral

Definition at line 8 of file MAG3110.cpp.

MAG3110 ( PinName  sda,
PinName  scl,
Serial *  pc 
)

Debug version of constructor.

Parameters:
sdaSDA pin
sdlSCL pin
addrAddress of the I2C peripheral
pcSerial object to output debug messages

Definition at line 14 of file MAG3110.cpp.


Member Function Documentation

void begin (  )

Setup the Magnetometer.

Definition at line 20 of file MAG3110.cpp.

float getHeading (  )

Calculate the heading.

Returns:
heading in degrees

Definition at line 67 of file MAG3110.cpp.

void getValues ( int *  xVal,
int *  yVal,
int *  zVal 
)

Reads and returns Z value using readVal.

Definition at line 89 of file MAG3110.cpp.

int getXVal (  )

Perform a read on the X, Y and Z values.

Parameters:
xValPointer to X value
yValPointer to Y value
zValPointer to Z value

Definition at line 74 of file MAG3110.cpp.

int getYVal (  )

Reads and returns X value using readVal.

Definition at line 79 of file MAG3110.cpp.

int getZVal (  )

Reads and returns Y value using readVal.

Definition at line 84 of file MAG3110.cpp.

int readReg ( char  regAddr )

Read a register, return its value as int.

Parameters:
regAddrThe address to read
Returns:
value in register

Definition at line 38 of file MAG3110.cpp.

int readVal ( char  regAddr )

Read a value from a pair of registers, return as int.

Parameters:
regAddrThe address to read
Returns:
Value from 2 consecutive registers

Definition at line 53 of file MAG3110.cpp.

void setCalibration ( int  minX,
int  maxX,
int  minY,
int  maxY 
)

Set the calibration parameters if required.

Parameters:
minXMinimum value for X range
maxXMaximum value for X range
minYMinimum value for Y range
maxYmaximum value for Y range

Definition at line 96 of file MAG3110.cpp.