compass3d library
v0.85
3D compass distance monitoring library for educational applications
|
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... | |
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.
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:
... 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.
I2C | bus pointer. In the example above, the pointer is mybus. |
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.
*bus | A pointer to the I2C bus (mybus in the example above). |
*px | A pointer to a variable to receive the x-value measurement. |
*py | A pointer to a variable to receive the y-value measurement. |
*pz | A pointer to a variable to receive the z-value measurement. |