mirror of
https://github.com/eclipse/upm.git
synced 2025-07-01 01:11:10 +03:00
hmc5883l: C port; FTI; C++ wraps C
Signed-off-by: Jon Trulson <jtrulson@ics.com>
This commit is contained in:
@ -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]
|
||||
|
Reference in New Issue
Block a user