![](/media/cache/profiles/8ad6635f33710af6a535e8fb8486975e.50x50_q85.jpg)
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.
Sensors/Comp/HMC5883.h@11:9bf69bc6df45, 2012-10-18 (annotated)
- Committer:
- maetugr
- Date:
- Thu Oct 18 20:04:16 2012 +0000
- Revision:
- 11:9bf69bc6df45
- Child:
- 12:67a06c9b69d5
Kompass immernoch nicht gut, vor Kalibrierungsberechnung
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
maetugr | 11:9bf69bc6df45 | 1 | #ifndef HMC5883_H |
maetugr | 11:9bf69bc6df45 | 2 | #define HMC5883_H |
maetugr | 11:9bf69bc6df45 | 3 | |
maetugr | 11:9bf69bc6df45 | 4 | #define HMC5883_CONF_REG_A 0x00 |
maetugr | 11:9bf69bc6df45 | 5 | #define HMC5883_CONF_REG_B 0x01 |
maetugr | 11:9bf69bc6df45 | 6 | #define HMC5883_MODE_REG 0x02 |
maetugr | 11:9bf69bc6df45 | 7 | #define HMC5883_DATA_OUT_X_MSB 0x03 |
maetugr | 11:9bf69bc6df45 | 8 | |
maetugr | 11:9bf69bc6df45 | 9 | // I2C addresses |
maetugr | 11:9bf69bc6df45 | 10 | #define HMC5883_ADDRESS 0x1E |
maetugr | 11:9bf69bc6df45 | 11 | #define I2CADR_W(ADR) (ADR << 1&0xFE) // ADR & 1111 1110 |
maetugr | 11:9bf69bc6df45 | 12 | #define I2CADR_R(ADR) (ADR << 1|0x01) // ADR | 0000 0001 |
maetugr | 11:9bf69bc6df45 | 13 | |
maetugr | 11:9bf69bc6df45 | 14 | class HMC5883 |
maetugr | 11:9bf69bc6df45 | 15 | { |
maetugr | 11:9bf69bc6df45 | 16 | public: |
maetugr | 11:9bf69bc6df45 | 17 | HMC5883(PinName sda, PinName scl); |
maetugr | 11:9bf69bc6df45 | 18 | |
maetugr | 11:9bf69bc6df45 | 19 | //my |
maetugr | 11:9bf69bc6df45 | 20 | float data[3]; |
maetugr | 11:9bf69bc6df45 | 21 | |
maetugr | 11:9bf69bc6df45 | 22 | void read(); |
maetugr | 11:9bf69bc6df45 | 23 | void writeReg(char address, char data); |
maetugr | 11:9bf69bc6df45 | 24 | void readMultiReg(char address, char* output, int size); |
maetugr | 11:9bf69bc6df45 | 25 | |
maetugr | 11:9bf69bc6df45 | 26 | float scale[3]; //privatisieren |
maetugr | 11:9bf69bc6df45 | 27 | |
maetugr | 11:9bf69bc6df45 | 28 | float heading; |
maetugr | 11:9bf69bc6df45 | 29 | |
maetugr | 11:9bf69bc6df45 | 30 | int Min[3]; |
maetugr | 11:9bf69bc6df45 | 31 | int Max[3]; |
maetugr | 11:9bf69bc6df45 | 32 | |
maetugr | 11:9bf69bc6df45 | 33 | float getAngle(float x, float y); //von Götti |
maetugr | 11:9bf69bc6df45 | 34 | |
maetugr | 11:9bf69bc6df45 | 35 | private: |
maetugr | 11:9bf69bc6df45 | 36 | I2C i2c; |
maetugr | 11:9bf69bc6df45 | 37 | |
maetugr | 11:9bf69bc6df45 | 38 | }; |
maetugr | 11:9bf69bc6df45 | 39 | |
maetugr | 11:9bf69bc6df45 | 40 | #endif |