Change dcm_kp default to 25000
[betaflight.git] / src / main / flight / lowpass.h
blobf1b57a315e812c17129dc9a209c44212a6d3f410
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
21 #define LOWPASS_NUM_COEF 3
22 #define LPF_ROUND(x) (x < 0 ? (x - 0.5f) : (x + 0.5f))
24 typedef struct lowpass_s {
25 bool init;
26 int16_t freq; // Normalized freq in 1/1000ths
27 float bf[LOWPASS_NUM_COEF];
28 float af[LOWPASS_NUM_COEF];
29 int64_t b[LOWPASS_NUM_COEF];
30 int64_t a[LOWPASS_NUM_COEF];
31 int16_t coeff_shift;
32 int16_t input_shift;
33 int32_t input_bias;
34 float xf[LOWPASS_NUM_COEF];
35 float yf[LOWPASS_NUM_COEF];
36 int32_t x[LOWPASS_NUM_COEF];
37 int32_t y[LOWPASS_NUM_COEF];
38 } lowpass_t;
40 void generateLowpassCoeffs2(int16_t freq, lowpass_t *filter);
41 int32_t lowpassFixed(lowpass_t *filter, int32_t in, int16_t freq);