forked from sqrtmo/GY-85-arduino
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGY_85.h
53 lines (41 loc) · 1.54 KB
/
GY_85.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "Arduino.h"
#include <Wire.h>
#ifndef GY_85_h
#define GY_85_h
//----------addresses----------//
#define ADXL345 (0x53) // Device address as specified in data sheet //ADXL345 accelerometer
#define DATAX0 (0x32) //X-Axis Data 0
//#define DATAX1 0x33 //X-Axis Data 1
//#define DATAY0 0x34 //Y-Axis Data 0
//#define DATAY1 0x35 //Y-Axis Data 1
//#define DATAZ0 0x36 //Z-Axis Data 0
//#define DATAZ1 0x37 //Z-Axis Data 1
#define HMC5883 (0x1E) //gyro
#define ITG3200 (0x68) //compass
class GY_85
{
private:
void GyroCalibrate();
void SetGyro();
void SetCompass();
void SetAccelerometer();
public:
void init();
int* readFromAccelerometer();
int* readFromCompass();
float* readGyro();
//callback functions
inline int accelerometer_x( int* a ){ return *( a ); }
inline int accelerometer_y( int* a ){ return *( 1+a ); }
inline int accelerometer_z( int* a ){ return *( 2+a ); }
//-----------------------------------
inline int compass_x( int* a ){ return *( a ); }
inline int compass_y( int* a ){ return *( 1+a ); }
inline int compass_z( int* a ){ return *( 2+a ); }
//-----------------------------------
inline float gyro_x( float* a ){ return *( a ) / 14.375; }
inline float gyro_y( float* a ){ return *( 1+a ) / 14.375; }
inline float gyro_z( float* a ){ return *( 2+a ) / 14.375; }
inline float temp ( float* a ){ return 35+( *( 3+a )+13200 ) / 280; }
};
#endif