The HMC6343 compass sensor.
Manufacturers Datasheet: http://www.ssec.honeywell.com/magnetic/datasheets/HMC6343.pdf
This compass is accessed over I2C at address 0x32 but this address can be changed by sending it the relevant command if you know what you are doing!
The compass returns bearing, roll and pitch.
The refresh rate of the device can be defined in Project Designer and, if necessary, can be changed at runtime with the various 'refresh' functions.
Assuming you have called the device 'myCompass' in Project Designer then here is some example code:
// read the compass values and store the results
// Print out the values in degrees
cout << " Bearing:" << myCompass.getBearing();
cout << " Roll:" << myCompass.getRoll();
cout << " Pitch:" << myCompass.getPitch();
// Or just dump everything in one go
cout << myCompass;
- refresh10Hz - Changes the default refresh rate to ten times per second (ie every 100ms).
- refresh1Hz - Changes the default refresh rate to once per second.
- refresh5Hz - Changes the default refresh rate to five times per second (ie every 200ms).
- dump - Dump the last read sensor values to the standard output device.
- dumpTo - Dump the contents of the sensor to the specified output stream.
- getBearing - Returns the compass bearing, in degrees, at the time of the last read().
- getPitch - Returns the compass pitch, in degrees, at the time of the last read().
- getRoll - Returns the compass roll, in degrees, at the time of the last read().
- getTimeLastRead - Returns the value of the clock at the time when the sensor was last read.
- read - Read the sensor and store its current values. Returns TRUE if the sensor has been read successfully, or FALSE if the sensor is busy in which case the read values are unchanged.