NOT FINISHED YET!!! My first try to get a self built fully working Quadrocopter based on an mbed, a self built frame and some other more or less cheap parts.

Dependencies:   mbed MODI2C

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers HMC5883.h Source File

HMC5883.h

00001 // based on http://mbed.org/users/BlazeX/code/HMC5883/
00002 
00003 #ifndef HMC5883_H
00004 #define HMC5883_H
00005 
00006 #include "mbed.h"
00007 #include "I2C_Sensor.h"
00008 
00009 #define HMC5883_I2C_ADDRESS     0x3C
00010 
00011 #define HMC5883_CONF_REG_A      0x00
00012 #define HMC5883_CONF_REG_B      0x01
00013 #define HMC5883_MODE_REG        0x02
00014 #define HMC5883_DATA_OUT_X_MSB  0x03
00015 
00016 class HMC5883 : public I2C_Sensor
00017 {           
00018     public:
00019         HMC5883(PinName sda, PinName scl);
00020         float data[3];                  // where the measured data is saved
00021         void read();            // read all axis from register to array data
00022         void calibrate(int s);
00023         float get_angle();
00024          
00025     private:
00026         int raw[3];
00027         void readraw();                 // function to get raw data
00028         
00029         float scale[3];                 // calibration parameters
00030         float offset[3];
00031 };
00032 
00033 #endif