hmc5883l: C port; FTI; C++ wraps C

Signed-off-by: Jon Trulson <jtrulson@ics.com>
This commit is contained in:
Jon Trulson
2017-01-25 17:37:29 -07:00
parent 806b00c2b7
commit 0a91eb0b46
11 changed files with 711 additions and 199 deletions

View File

@ -32,16 +32,17 @@ main(int argc, char **argv)
//! [Interesting]
// Instantiate on I2C
upm::Hmc5883l* compass = new upm::Hmc5883l(0);
int16_t *pos;
compass->set_declination(0.2749); // Set your declination from true north in radians
compass->set_declination(0.2749); // Set your declination from
// true north in radians
// Print out the coordinates, heading, and direction every second
while(true){
compass->update(); // Update the coordinates
pos = compass->coordinates();
const int16_t *pos = compass->coordinates();
fprintf(stdout, "coor: %5d %5d %5d ", pos[0], pos[1], pos[2]);
fprintf(stdout, "heading: %5.2f direction: %3.2f\n", compass->heading(), compass->direction());
fprintf(stdout, "heading: %5.2f direction: %3.2f\n",
compass->heading(), compass->direction());
sleep(1);
}
//! [Interesting]