<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <meta http-equiv="X-UA-Compatible" content="IE=9"/> <meta name="generator" content="Doxygen 1.8.4"/> <title>compass3d library: compass3d.h File Reference</title> <link href="html/tabs.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="dynsections.js"></script> <link href="html/doxygen.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="top"><!-- do not remove this div, it is closed by doxygen! --> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">compass3d library  <span id="projectnumber">v0.85</span> </div> <div id="projectbrief">3D compass distance monitoring library for educational applications</div> </td> </tr> </tbody> </table> </div> <!-- end header part --> <!-- Generated by Doxygen 1.8.4 --> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="html/index.html"><span>Main Page</span></a></li> <li class="current"><a href="html/files.html"><span>Files</span></a></li> </ul> </div> <div id="navrow2" class="tabs2"> <ul class="tablist"> <li><a href="html/files.html"><span>File List</span></a></li> <li><a href="html/globals.html"><span>Globals</span></a></li> </ul> </div> </div><!-- top --> <div class="header"> <div class="summary"> <a href="#func-members">Functions</a> </div> <div class="headertitle"> <div class="title">compass3d.h File Reference</div> </div> </div><!--header--> <div class="contents"> <p>This library provides convenience functions for reading measurements from the Parallax Compass Module 3-Axis HMC5883L. <br/> <br/> <b><em>CONSTRUCTION ZONE:</em></b> This library is preliminary, major revisions pending. <a href="#details">More...</a></p> <div class="textblock"><code>#include "simplei2c.h"</code><br/> <code>#include "simpletools.h"</code><br/> </div> <p><a href="html/compass3d_8h_source.html">Go to the source code of this file.</a></p> <table class="memberdecls"> <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a> Functions</h2></td></tr> <tr class="memitem:a4883ddf883e78bb65417ab31f4079066"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="html/compass3d_8h.html#a4883ddf883e78bb65417ab31f4079066">compass_init</a> (i2c *bus)</td></tr> <tr class="memdesc:a4883ddf883e78bb65417ab31f4079066"><td class="mdescLeft"> </td><td class="mdescRight">Initialize the Compass. <a href="#a4883ddf883e78bb65417ab31f4079066">More...</a><br/></td></tr> <tr class="separator:a4883ddf883e78bb65417ab31f4079066"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:ad901bbd8ae291e94dccff94af4216038"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="html/compass3d_8h.html#ad901bbd8ae291e94dccff94af4216038">compass_read</a> (i2c *bus, int *px, int *py, int *pz)</td></tr> <tr class="memdesc:ad901bbd8ae291e94dccff94af4216038"><td class="mdescLeft"> </td><td class="mdescRight">Read values from compass. <a href="#ad901bbd8ae291e94dccff94af4216038">More...</a><br/></td></tr> <tr class="separator:ad901bbd8ae291e94dccff94af4216038"><td class="memSeparator" colspan="2"> </td></tr> </table> <a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2> <div class="textblock"><p>This library provides convenience functions for reading measurements from the Parallax Compass Module 3-Axis HMC5883L. <br/> <br/> <b><em>CONSTRUCTION ZONE:</em></b> This library is preliminary, major revisions pending. </p> <dl class="section author"><dt>Author</dt><dd>Andy Lindsay</dd></dl> <dl class="section version"><dt>Version</dt><dd>v0.85</dd></dl> <dl class="section copyright"><dt>Copyright</dt><dd>Copyright (C) Parallax, Inc. 2013. All Rights MIT Licensed. </dd></dl> </div><h2 class="groupheader">Function Documentation</h2> <a class="anchor" id="a4883ddf883e78bb65417ab31f4079066"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void compass_init </td> <td>(</td> <td class="paramtype">i2c * </td> <td class="paramname"><em>bus</em>)</td><td></td> <td></td> </tr> </table> </div><div class="memdoc"> <p>Initialize the Compass. </p> <p>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:</p> <div class="fragment"><div class="line">i2c mybus = i2c_init(sclPin, sdaPin)</div> </div><!-- fragment --><p>... 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.</p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">I2C</td><td>bus pointer. In the example above, the pointer is mybus.</td></tr> </table> </dd> </dl> <dl class="section return"><dt>Returns</dt><dd>void, but it will display an error message if the compass module does not respond. </dd></dl> </div> </div> <a class="anchor" id="ad901bbd8ae291e94dccff94af4216038"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void compass_read </td> <td>(</td> <td class="paramtype">i2c * </td> <td class="paramname"><em>bus</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int * </td> <td class="paramname"><em>px</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int * </td> <td class="paramname"><em>py</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int * </td> <td class="paramname"><em>pz</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <p>Read values from compass. </p> <p>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.</p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">*bus</td><td>A pointer to the I2C bus (mybus in the example above).</td></tr> <tr><td class="paramname">*px</td><td>A pointer to a variable to receive the x-value measurement.</td></tr> <tr><td class="paramname">*py</td><td>A pointer to a variable to receive the y-value measurement.</td></tr> <tr><td class="paramname">*pz</td><td>A pointer to a variable to receive the z-value measurement.</td></tr> </table> </dd> </dl> <dl class="section return"><dt>Returns</dt><dd>void, but it will display an error message if the compass module does not respond. </dd></dl> </div> </div> </div><!-- contents --> <!-- start footer part --> <hr class="footer"/><address class="footer"><small> Generated on Tue Aug 6 2013 11:07:02 for compass3d library by  <a href="html/http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/> </a> 1.8.4 </small></address> </body> </html>