OSDN Git Service

Add the ordering flag to the quirks array
[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 48
13 #define EPSILON 0.000000001
14
15
16 /* If no cal data is present - first calibration will
17    use a more relaxed set of values to get an initial
18    calibration faster */
19 #define FIRST_MIN_DIFF 0.5f
20 #define FIRST_MAX_SQR_ERR 5.0f
21 #define FIRST_LOOKBACK_COUNT 4
22
23 #define MIN_DIFF 1.0f
24 #define MAX_SQR_ERR 3.5f
25 #define LOOKBACK_COUNT 6
26
27
28 #ifdef DBG_RAW_DATA
29 #define RAW_DATA_FULL_PATH "/data/raw_compass_data_full_%d.txt"
30 #define RAW_DATA_SELECTED_PATH "/data/raw_compass_data_selected_%d.txt"
31 #endif
32
33 /* gyro defines */
34 #define GYRO_MAX_ERR 0.05f
35 #define GYRO_DS_SIZE 8
36
37 struct compass_cal {
38     /* hard iron offsets */
39     double offset[3][1];
40
41     /* soft iron matrix */
42     double w_invert[3][3];
43
44     /* geomagnetic strength */
45     double bfield;
46
47     /* selection data */
48     float sample[DS_SIZE][3];
49     unsigned int sample_count;
50 };
51
52 struct gyro_cal {
53     float bias[3];
54     int start;
55     int count;
56     float sample[GYRO_DS_SIZE][3];
57 };
58
59 typedef double mat_input_t[DS_SIZE][3];
60
61 void calibrate_compass (struct sensors_event_t* event, struct sensor_info_t* info, int64_t time);
62 void compass_read_data (struct sensor_info_t* info);
63 void compass_store_data (struct sensor_info_t* info);
64
65 void calibrate_gyro(struct sensors_event_t* event, struct sensor_info_t* info);
66 void gyro_cal_init(struct sensor_info_t* info);
67 #endif