2010-05-28 11:38:51 -03:00
|
|
|
#ifndef APM_Compass_h
|
|
|
|
#define APM_Compass_h
|
|
|
|
|
2010-10-16 22:34:57 -03:00
|
|
|
#define APM_COMPASS_COMPONENTS_UP_PINS_FORWARD 0
|
|
|
|
#define APM_COMPONENTS_UP_PINS_FORWARD_RIGHT 1
|
|
|
|
#define APM_COMPASS_COMPONENTS_UP_PINS_RIGHT 2
|
|
|
|
#define APM_COMPONENTS_UP_PINS_BACK_RIGHT 3
|
|
|
|
#define APM_COMPASS_COMPONENTS_UP_PINS_BACK 4
|
|
|
|
#define APM_COMPONENTS_UP_PINS_BACK_LEFT 5
|
|
|
|
#define APM_COMPASS_COMPONENTS_UP_PINS_LEFT 6
|
|
|
|
#define APM_COMPONENTS_UP_PINS_FORWARD_LEFT 7
|
|
|
|
#define APM_COMPASS_COMPONENTS_DOWN_PINS_FORWARD 8
|
|
|
|
#define APM_COMPONENTS_DOWN_PINS_FORWARD_RIGHT 9
|
|
|
|
#define APM_COMPASS_COMPONENTS_DOWN_PINS_RIGHT 10
|
|
|
|
#define APM_COMPONENTS_DOWN_PINS_BACK_RIGHT 11
|
|
|
|
#define APM_COMPASS_COMPONENTS_DOWN_PINS_BACK 12
|
|
|
|
#define APM_COMPONENTS_DOWN_PINS_BACK_LEFT 13
|
|
|
|
#define APM_COMPASS_COMPONENTS_DOWN_PINS_LEFT 14
|
|
|
|
#define APM_COMPONENTS_DOWN_PINS_FORWARD_LEFT 15
|
2010-09-26 10:54:24 -03:00
|
|
|
|
2010-05-28 11:38:51 -03:00
|
|
|
class APM_Compass_Class
|
|
|
|
{
|
2010-10-16 22:34:57 -03:00
|
|
|
private:
|
2010-10-09 20:22:46 -03:00
|
|
|
int orientation;
|
|
|
|
float calibration[3];
|
|
|
|
int offset[3];
|
|
|
|
float declination;
|
2010-05-28 11:38:51 -03:00
|
|
|
public:
|
|
|
|
int Mag_X;
|
|
|
|
int Mag_Y;
|
|
|
|
int Mag_Z;
|
|
|
|
float Heading;
|
|
|
|
float Heading_X;
|
|
|
|
float Heading_Y;
|
2010-10-16 22:34:57 -03:00
|
|
|
unsigned long lastUpdate;
|
2010-05-28 11:38:51 -03:00
|
|
|
|
|
|
|
APM_Compass_Class(); // Constructor
|
2010-10-17 18:07:25 -03:00
|
|
|
bool Init();
|
2010-05-28 11:38:51 -03:00
|
|
|
void Read();
|
|
|
|
void Calculate(float roll, float pitch);
|
2010-09-26 10:54:24 -03:00
|
|
|
void SetOrientation(int newOrientation);
|
2010-10-09 20:22:46 -03:00
|
|
|
void SetOffsets(int x, int y, int z);
|
|
|
|
void SetDeclination(float radians);
|
2010-05-28 11:38:51 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
extern APM_Compass_Class APM_Compass;
|
|
|
|
|
2010-09-27 01:05:10 -03:00
|
|
|
#endif
|