OSDN Git Service

Merge remote-tracking branch 'origin/abt/topic/gmin/kitkat/sensors' into gmin/kitkat...
[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 typedef struct {
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 } calibration_data;
48
49 struct gyro_cal {
50     float bias[3];
51     int start;
52     int count;
53     float sample[GYRO_DS_SIZE][3];
54 };
55
56 typedef double mat_input_t[DS_SIZE][3];
57
58 void calibrate_compass (struct sensors_event_t* event, int64_t time);
59 void compass_read_data (const char* config_path);
60 void compass_store_data (const char* config_path);
61
62 void calibrate_gyro(struct sensors_event_t* event, struct sensor_info_t* info);
63 void gyro_cal_init(struct sensor_info_t* info);
64 #endif