2011-12-28 05:31:36 -04:00
|
|
|
/// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
2011-02-14 00:27:07 -04:00
|
|
|
#ifndef AP_Compass_HMC5843_H
|
|
|
|
#define AP_Compass_HMC5843_H
|
|
|
|
|
2011-04-30 23:05:17 -03:00
|
|
|
#include "../AP_Common/AP_Common.h"
|
|
|
|
#include "../AP_Math/AP_Math.h"
|
2011-02-14 00:27:07 -04:00
|
|
|
|
|
|
|
#include "Compass.h"
|
|
|
|
|
|
|
|
// orientations for DIYDrones magnetometer
|
|
|
|
#define AP_COMPASS_COMPONENTS_UP_PINS_FORWARD ROTATION_NONE
|
|
|
|
#define AP_COMPASS_COMPONENTS_UP_PINS_FORWARD_RIGHT ROTATION_YAW_45
|
|
|
|
#define AP_COMPASS_COMPONENTS_UP_PINS_RIGHT ROTATION_YAW_90
|
|
|
|
#define AP_COMPASS_COMPONENTS_UP_PINS_BACK_RIGHT ROTATION_YAW_135
|
|
|
|
#define AP_COMPASS_COMPONENTS_UP_PINS_BACK ROTATION_YAW_180
|
|
|
|
#define AP_COMPASS_COMPONENTS_UP_PINS_BACK_LEFT ROTATION_YAW_225
|
|
|
|
#define AP_COMPASS_COMPONENTS_UP_PINS_LEFT ROTATION_YAW_270
|
|
|
|
#define AP_COMPASS_COMPONENTS_UP_PINS_FORWARD_LEFT ROTATION_YAW_315
|
|
|
|
#define AP_COMPASS_COMPONENTS_DOWN_PINS_FORWARD ROTATION_ROLL_180
|
|
|
|
#define AP_COMPASS_COMPONENTS_DOWN_PINS_FORWARD_RIGHT ROTATION_ROLL_180_YAW_45
|
|
|
|
#define AP_COMPASS_COMPONENTS_DOWN_PINS_RIGHT ROTATION_ROLL_180_YAW_90
|
|
|
|
#define AP_COMPASS_COMPONENTS_DOWN_PINS_BACK_RIGHT ROTATION_ROLL_180_YAW_135
|
|
|
|
#define AP_COMPASS_COMPONENTS_DOWN_PINS_BACK ROTATION_PITCH_180
|
|
|
|
#define AP_COMPASS_COMPONENTS_DOWN_PINS_BACK_LEFT ROTATION_ROLL_180_YAW_225
|
|
|
|
#define AP_COMPASS_COMPONENTS_DOWN_PINS_LEFT ROTATION_ROLL_180_YAW_270
|
|
|
|
#define AP_COMPASS_COMPONENTS_DOWN_PINS_FORWARD_LEFT ROTATION_ROLL_180_YAW_315
|
2011-11-13 18:45:15 -04:00
|
|
|
#define AP_COMPASS_APM2_SHIELD ROTATION_NONE
|
2011-02-14 00:27:07 -04:00
|
|
|
|
|
|
|
// orientations for Sparkfun magnetometer
|
|
|
|
#define AP_COMPASS_SPARKFUN_COMPONENTS_UP_PINS_FORWARD ROTATION_YAW_270
|
|
|
|
#define AP_COMPASS_SPARKFUN_COMPONENTS_UP_PINS_FORWARD_RIGHT ROTATION_YAW_315
|
|
|
|
#define AP_COMPASS_SPARKFUN_COMPONENTS_UP_PINS_RIGHT ROTATION_NONE
|
|
|
|
#define AP_COMPASS_SPARKFUN_COMPONENTS_UP_PINS_BACK_RIGHT ROTATION_YAW_45
|
|
|
|
#define AP_COMPASS_SPARKFUN_COMPONENTS_UP_PINS_BACK ROTATION_YAW_90
|
|
|
|
#define AP_COMPASS_SPARKFUN_COMPONENTS_UP_PINS_BACK_LEFT ROTATION_YAW_135
|
|
|
|
#define AP_COMPASS_SPARKFUN_COMPONENTS_UP_PINS_LEFT ROTATION_YAW_180
|
|
|
|
#define AP_COMPASS_SPARKFUN_COMPONENTS_UP_PINS_FORWARD_LEFT ROTATION_YAW_225
|
|
|
|
#define AP_COMPASS_SPARKFUN_COMPONENTS_DOWN_PINS_FORWARD ROTATION_ROLL_180_YAW_90
|
|
|
|
#define AP_COMPASS_SPARKFUN_COMPONENTS_DOWN_PINS_FORWARD_RIGHT ROTATION_ROLL_180_YAW_135
|
|
|
|
#define AP_COMPASS_SPARKFUN_COMPONENTS_DOWN_PINS_RIGHT ROTATION_PITCH_180
|
|
|
|
#define AP_COMPASS_SPARKFUN_COMPONENTS_DOWN_PINS_BACK_RIGHT ROTATION_ROLL_180_YAW_225
|
|
|
|
#define AP_COMPASS_SPARKFUN_COMPONENTS_DOWN_PINS_BACK ROTATION_ROLL_180_YAW_270
|
|
|
|
#define AP_COMPASS_SPARKFUN_COMPONENTS_DOWN_PINS_BACK_LEFT ROTATION_ROLL_180_YAW_315
|
|
|
|
#define AP_COMPASS_SPARKFUN_COMPONENTS_DOWN_PINS_LEFT ROTATION_ROLL_180
|
|
|
|
#define AP_COMPASS_SPARKFUN_COMPONENTS_DOWN_PINS_FORWARD_LEFT ROTATION_ROLL_180_YAW_45
|
|
|
|
|
|
|
|
class AP_Compass_HMC5843 : public Compass
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
float calibration[3];
|
2012-02-24 23:38:52 -04:00
|
|
|
bool _initialised;
|
2011-12-28 05:31:36 -04:00
|
|
|
virtual bool read_raw(void);
|
|
|
|
uint8_t _base_config;
|
|
|
|
virtual bool re_initialise(void);
|
|
|
|
bool read_register(uint8_t address, uint8_t *value);
|
|
|
|
bool write_register(uint8_t address, byte value);
|
2012-01-04 01:35:47 -04:00
|
|
|
uint32_t _retry_time; // when unhealthy the millis() value to retry at
|
2011-12-28 05:31:36 -04:00
|
|
|
|
2011-02-14 00:27:07 -04:00
|
|
|
public:
|
2012-02-11 07:53:30 -04:00
|
|
|
AP_Compass_HMC5843() : Compass() {}
|
2011-12-28 05:31:36 -04:00
|
|
|
virtual bool init(void);
|
|
|
|
virtual bool read(void);
|
2012-03-09 22:45:35 -04:00
|
|
|
virtual void set_orientation(enum Rotation rotation);
|
2011-06-28 13:30:42 -03:00
|
|
|
|
2011-02-14 00:27:07 -04:00
|
|
|
};
|
|
|
|
#endif
|