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

Committer:
maetugr
Date:
Sat Nov 03 07:44:07 2012 +0000
Revision:
18:c8c09a3913ba
Parent:
17:e096e85f6c36
Child:
19:40c252b4a792
mit allem in der I2C_Sensors klasse, zwischenspeichern, da nichts funktioniert

Who changed what in which revision?

UserRevisionLine numberNew contents of line
maetugr 17:e096e85f6c36 1 // based on http://mbed.org/users/BlazeX/code/HMC5883/
maetugr 17:e096e85f6c36 2
maetugr 11:9bf69bc6df45 3 #ifndef HMC5883_H
maetugr 11:9bf69bc6df45 4 #define HMC5883_H
maetugr 11:9bf69bc6df45 5
maetugr 17:e096e85f6c36 6 #include "mbed.h"
maetugr 17:e096e85f6c36 7 #include "I2C_Sensor.h"
maetugr 17:e096e85f6c36 8
maetugr 18:c8c09a3913ba 9 #define HMC5883_I2C_ADDRESS 0x1E
maetugr 18:c8c09a3913ba 10
maetugr 11:9bf69bc6df45 11 #define HMC5883_CONF_REG_A 0x00
maetugr 11:9bf69bc6df45 12 #define HMC5883_CONF_REG_B 0x01
maetugr 11:9bf69bc6df45 13 #define HMC5883_MODE_REG 0x02
maetugr 11:9bf69bc6df45 14 #define HMC5883_DATA_OUT_X_MSB 0x03
maetugr 11:9bf69bc6df45 15
maetugr 17:e096e85f6c36 16 class HMC5883 : public I2C_Sensor
maetugr 11:9bf69bc6df45 17 {
maetugr 11:9bf69bc6df45 18 public:
maetugr 11:9bf69bc6df45 19 HMC5883(PinName sda, PinName scl);
maetugr 11:9bf69bc6df45 20
maetugr 18:c8c09a3913ba 21 virtual void read(); // read all axis from register to array data
maetugr 12:67a06c9b69d5 22 void calibrate(int s);
maetugr 12:67a06c9b69d5 23 float get_angle();
maetugr 12:67a06c9b69d5 24
maetugr 12:67a06c9b69d5 25 private:
maetugr 18:c8c09a3913ba 26 void readraw(); // function to get raw data
maetugr 12:67a06c9b69d5 27
maetugr 18:c8c09a3913ba 28 float scale[3]; // calibration parameters
maetugr 14:cf260677ecde 29 float offset[3];
maetugr 11:9bf69bc6df45 30 };
maetugr 11:9bf69bc6df45 31
maetugr 11:9bf69bc6df45 32 #endif