2 * This file is part of Cleanflight.
4 * Cleanflight is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * Cleanflight is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
20 #include "common/axis.h"
21 #include "common/time.h"
23 #include "config/parameter_group.h"
25 #include "drivers/compass/compass.h"
27 #include "sensors/sensors.h"
29 // Type of magnetometer used/detected
50 typedef struct mag_s
{
52 float magADC
[XYZ_AXIS_COUNT
];
59 typedef struct compassConfig_s
{
60 int16_t mag_declination
; // Get your magnetic declination from here : http://magnetic-declination.com/
61 // For example, -6deg 37min, = -637 Japan, format is [sign]dddmm (degreesminutes) default is zero.
62 sensor_align_e mag_align
; // on-board mag alignment. Ignored if externally aligned via *DeciDegrees.
63 uint8_t mag_hardware
; // Which mag hardware to use on boards with more than one device
64 flightDynamicsTrims_t magZero
;
65 int16_t magGain
[XYZ_AXIS_COUNT
];
69 uint8_t magCalibrationTimeLimit
; // Time for compass calibration (seconds)
70 int16_t rollDeciDegrees
; // Alignment for external mag on the roll (X) axis (0.1deg)
71 int16_t pitchDeciDegrees
; // Alignment for external mag on the pitch (Y) axis (0.1deg)
72 int16_t yawDeciDegrees
; // Alignment for external mag on the yaw (Z) axis (0.1deg)
75 PG_DECLARE(compassConfig_t
, compassConfig
);
77 bool compassDetect(magDev_t
*dev
, magSensor_e magHardwareToUse
);
78 bool compassInit(void);
79 void compassUpdate(timeUs_t currentTimeUs
);
80 bool compassIsReady(void);
81 bool compassIsHealthy(void);
82 bool compassIsCalibrationComplete(void);