Rev | Line | |
---|
[175] | 1 | /*
|
---|
| 2 | mag3110.h
|
---|
| 3 | libary for using the I2C mag3110 magnetometer
|
---|
| 4 |
|
---|
| 5 | (c) Written by Jeroen Cappaert for NanoSatisfi, August 2012
|
---|
| 6 |
|
---|
| 7 | - 21 Mar. 2016
|
---|
| 8 | Library modified to work with Arduino Lucky Shield
|
---|
| 9 | by andrea[at]arduino[dot]org
|
---|
| 10 |
|
---|
| 11 | */
|
---|
| 12 |
|
---|
| 13 | #ifndef MAG3110_h
|
---|
| 14 | #define MAG3110_h
|
---|
| 15 |
|
---|
| 16 | #include <Arduino.h>
|
---|
| 17 |
|
---|
| 18 |
|
---|
| 19 | // define magnetometer I2C address (fixed)
|
---|
| 20 |
|
---|
| 21 | #define MAG_ADDR 0x0E // Magnetometer MAG3110
|
---|
| 22 |
|
---|
| 23 |
|
---|
| 24 | class MAG3110
|
---|
| 25 | {
|
---|
| 26 | public:
|
---|
[224] | 27 | //constructor
|
---|
| 28 | //MAG3110();
|
---|
| 29 |
|
---|
| 30 | //public methods
|
---|
[175] | 31 | void begin();
|
---|
[224] | 32 | void read();
|
---|
| 33 | int x(){return mag_x;};
|
---|
| 34 | int y(){return mag_y;};
|
---|
| 35 | int z(){return mag_z;};
|
---|
| 36 |
|
---|
[175] | 37 | private:
|
---|
[224] | 38 | //class-only methods:
|
---|
| 39 | int read16Data(byte MSB, byte LSB);
|
---|
| 40 |
|
---|
| 41 | //global variables
|
---|
| 42 | int mag_x;
|
---|
| 43 | int mag_y;
|
---|
| 44 | int mag_z;
|
---|
| 45 |
|
---|
[175] | 46 | };
|
---|
| 47 |
|
---|
| 48 | extern MAG3110 mag3110;
|
---|
| 49 |
|
---|
| 50 | #endif
|
---|
Note:
See
TracBrowser
for help on using the repository browser.