OSDN Git Service

Don't setup an upper limit for the magnetometer sanity_norm
[android-x86/hardware-intel-libsensors.git] / calibration.h
1 /*
2  * Copyright (C) 2014 Intel Corporation.
3  */
4
5 #ifndef __CALIBRATION_H__
6 #define __CALIBRATION_H__
7
8 #include "common.h"
9
10 /* compass defines */
11 #define COMPASS_CALIBRATION_PATH "/data/compass.conf"
12 #define DS_SIZE 32
13 #define EPSILON 0.000000001
14
15 #define MAGNETIC_LOW 960 /* 31 micro tesla squared */
16
17 #ifdef DBG_RAW_DATA
18 #define RAW_DATA_FULL_PATH "/data/raw_compass_data_full_%d.txt"
19 #define RAW_DATA_SELECTED_PATH "/data/raw_compass_data_selected_%d.txt"
20 #endif
21
22 /* gyro defines */
23 #define GYRO_MAX_ERR 0.05f
24 #define GYRO_DS_SIZE 100
25 #define GYRO_CALIBRATION_PATH "/data/gyro.conf"
26
27 struct compass_cal {
28     /* hard iron offsets */
29     double offset[3][1];
30
31     /* soft iron matrix */
32     double w_invert[3][3];
33
34     /* geomagnetic strength */
35     double bfield;
36
37     /* selection data */
38     float sample[DS_SIZE][3];
39     unsigned int sample_count;
40 };
41
42 struct gyro_cal {
43     float bias_x, bias_y, bias_z;
44     int count;
45     float min_x, min_y, min_z;
46     float max_x, max_y, max_z;
47 };
48
49 typedef double mat_input_t[DS_SIZE][3];
50
51 void calibrate_compass (struct sensors_event_t* event, struct sensor_info_t* info);
52 void compass_read_data (struct sensor_info_t* info);
53 void compass_store_data (struct sensor_info_t* info);
54
55 void calibrate_gyro(struct sensors_event_t* event, struct sensor_info_t* info);
56 void gyro_cal_init(struct sensor_info_t* info);
57 void gyro_store_data (struct sensor_info_t* info);
58 #endif