NinjaFlight
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
acceleration.h
Go to the documentation of this file.
1 /*
2  * This file is part of Ninjaflight.
3  *
4  * Ninjaflight 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.
8  *
9  * Ninjaflight 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.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with Ninjaflight. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #pragma once
19 
20 #include "../drivers/accgyro.h"
21 #include "../common/axis.h"
22 #include "../config/accelerometer.h"
23 #include "../config/sensors.h"
24 
25 struct ins_acc {
27  uint16_t calibratingA;
28  int32_t a[3];
29  int32_t b[3];
30  //int16_t accZero_saved[3];
31  //rollAndPitchTrims_t angleTrim_saved;
33 
36 };
37 //extern int32_t accADC[XYZ_AXIS_COUNT];
38 
39 void ins_acc_init(struct ins_acc *self, const struct sensor_trims_config *trims, const struct accelerometer_config *config);
40 void ins_acc_process_sample(struct ins_acc *self, int32_t x, int32_t y, int32_t z);
41 void ins_acc_calibrate(struct ins_acc *self);
42 bool ins_acc_is_calibrated(struct ins_acc *self);
43 
44 static inline int32_t ins_acc_get_x(struct ins_acc *self) { return self->accADC[X]; }
45 static inline int32_t ins_acc_get_y(struct ins_acc *self) { return self->accADC[Y]; }
46 static inline int32_t ins_acc_get_z(struct ins_acc *self) { return self->accADC[Z]; }
47 
#define XYZ_AXIS_COUNT
Definition: axis.h:26
struct sensor_trims_config trims
Local trims that we adjust as we calibrate.
Definition: acceleration.h:35
Definition: config.h:81
int32_t accADC[XYZ_AXIS_COUNT]
Definition: acceleration.h:26
const struct accelerometer_config * config
Definition: acceleration.h:32
void ins_acc_init(struct ins_acc *self, const struct sensor_trims_config *trims, const struct accelerometer_config *config)
Definition: acceleration.c:53
Definition: axis.h:23
Definition: acceleration.h:25
int32_t b[3]
Definition: acceleration.h:29
uint16_t calibratingA
Definition: acceleration.h:27
uint8_t z
set the acc deadband for z-Axis, this ignores small accelerations
Definition: accelerometer.h:52
Definition: sensors.h:69
Definition: axis.h:21
rollAndPitchTrims_t trims
accelerometer trim
Definition: accelerometer.h:51
void ins_acc_process_sample(struct ins_acc *self, int32_t x, int32_t y, int32_t z)
Definition: acceleration.c:111
Definition: accelerometer.h:48
int32_t a[3]
Definition: acceleration.h:28
Definition: axis.h:22
bool ins_acc_is_calibrated(struct ins_acc *self)
Definition: acceleration.c:151
void ins_acc_calibrate(struct ins_acc *self)
Definition: acceleration.c:145