compass3d library  v0.85
3D compass distance monitoring library for educational applications
Functions
compass3d.h File Reference

This library provides convenience functions for reading measurements from the Parallax Compass Module 3-Axis HMC5883L.

CONSTRUCTION ZONE: This library is preliminary, major revisions pending. More...

#include "simplei2c.h"
#include "simpletools.h"

Go to the source code of this file.

Functions

void compass_init (i2c *bus)
 Initialize the Compass. More...
 
void compass_read (i2c *bus, int *px, int *py, int *pz)
 Read values from compass. More...
 

Detailed Description

This library provides convenience functions for reading measurements from the Parallax Compass Module 3-Axis HMC5883L.

CONSTRUCTION ZONE: This library is preliminary, major revisions pending.

Author
Andy Lindsay
Version
v0.85

Function Documentation

void compass_init ( i2c *  bus)

Initialize the Compass.

This function initializes the compass, but before calling it, you have to set up an I2C bus. Example: Assuming the your program is using the simpletools library, you can use:

i2c mybus = i2c_init(sclPin, sdaPin)

... where sclPin is the number of the I/O pin connected to the compass module's SCL line and sdaPin is the number of the pin connected to the module's SDA line.

Parameters
I2Cbus pointer. In the example above, the pointer is mybus.
Returns
void, but it will display an error message if the compass module does not respond.
void compass_read ( i2c *  bus,
int *  px,
int *  py,
int *  pz 
)

Read values from compass.

This function finds a compass on the specified bus, reads its x, y, and z values and loads them into variables that are passed by address.

Parameters
*busA pointer to the I2C bus (mybus in the example above).
*pxA pointer to a variable to receive the x-value measurement.
*pyA pointer to a variable to receive the y-value measurement.
*pzA pointer to a variable to receive the z-value measurement.
Returns
void, but it will display an error message if the compass module does not respond.