Finally rename flight.c/.h to pid.c/.h. Cleanup some dependencies.
[betaflight.git] / src / main / flight / imu.h
blob9d1c83110ef4dc9104dcb37f2d1daf94389014cd
1 /*
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/>.
18 #pragma once
20 extern int16_t throttleAngleCorrection;
21 extern uint32_t accTimeSum;
22 extern int accSumCount;
23 extern float accVelScale;
25 extern int16_t accSmooth[XYZ_AXIS_COUNT];
26 extern int32_t accSum[XYZ_AXIS_COUNT];
27 extern int16_t gyroData[FLIGHT_DYNAMICS_INDEX_COUNT];
30 typedef struct rollAndPitchInclination_s {
31 // absolute angle inclination in multiple of 0.1 degree 180 deg = 1800
32 int16_t rollDeciDegrees;
33 int16_t pitchDeciDegrees;
34 } rollAndPitchInclination_t_def;
36 typedef union {
37 int16_t raw[ANGLE_INDEX_COUNT];
38 rollAndPitchInclination_t_def values;
39 } rollAndPitchInclination_t;
41 extern rollAndPitchInclination_t inclination;
43 typedef struct accDeadband_s {
44 uint8_t xy; // set the acc deadband for xy-Axis
45 uint8_t z; // set the acc deadband for z-Axis, this ignores small accelerations
46 } accDeadband_t;
48 typedef struct imuRuntimeConfig_s {
49 uint8_t acc_lpf_factor;
50 uint8_t acc_unarmedcal;
51 float gyro_cmpf_factor;
52 float gyro_cmpfm_factor;
53 int8_t small_angle;
54 } imuRuntimeConfig_t;
56 void imuConfigure(
57 imuRuntimeConfig_t *initialImuRuntimeConfig,
58 pidProfile_t *initialPidProfile,
59 accDeadband_t *initialAccDeadband,
60 float accz_lpf_cutoff,
61 uint16_t throttle_correction_angle
64 void calculateEstimatedAltitude(uint32_t currentTime);
65 void imuUpdate(rollAndPitchTrims_t *accelerometerTrims, uint8_t mixerMode);
66 float calculateThrottleAngleScale(uint16_t throttle_correction_angle);
67 int16_t calculateThrottleAngleCorrection(uint8_t throttle_correction_value);
68 float calculateAccZLowPassFilterRCTimeConstant(float accz_lpf_cutoff);
70 int16_t imuCalculateHeading(t_fp_vector *vec);
72 void imuResetAccelerationSum(void);