OSDN Git Service

dd67ed339fff9fc925e02069da1771894bf62f88
[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 #define COMPASS_CALIBRATION_PATH "/data/compass.conf"
9 #define DS_SIZE 48
10 #define EPSILON 0.000000001
11
12
13 /* If no cal data is present - first calibration will
14    use a more relaxed set of values to get an initial
15    calibration faster */
16 #define FIRST_MIN_DIFF 0.5f
17 #define FIRST_MAX_SQR_ERR 5.0f
18 #define FIRST_LOOKBACK_COUNT 4
19
20 #define MIN_DIFF 1.0f
21 #define MAX_SQR_ERR 3.5f
22 #define LOOKBACK_COUNT 6
23
24
25 #ifdef DBG_RAW_DATA
26 #define RAW_DATA_FULL_PATH "/data/raw_compass_data_full_%d.txt"
27 #define RAW_DATA_SELECTED_PATH "/data/raw_compass_data_selected_%d.txt"
28 #endif
29
30 typedef struct {
31     /* hard iron offsets */
32     double offset[3][1];
33
34     /* soft iron matrix */
35     double w_invert[3][3];
36
37     /* geomagnetic strength */
38     double bfield;
39
40 } calibration_data;
41
42 typedef double mat_input_t[DS_SIZE][3];
43
44 void calibrate_compass (struct sensors_event_t* event, int64_t time);
45 void compass_read_data (const char* config_path);
46 void compass_store_data (const char* config_path);
47
48 #endif