OSDN Git Service

Move module path to vendor
[android-x86/hardware-intel-libsensors.git] / calibration.h
1 /*
2  * Copyright (C) 2014-2015 Intel Corporation.
3  */
4
5 #ifndef __CALIBRATION_H__
6 #define __CALIBRATION_H__
7
8 #include "common.h"
9
10 #define MAGN_DS_SIZE 32
11
12
13 typedef struct {
14     /* hard iron offsets */
15     double offset[3][1];
16
17     /* soft iron matrix */
18     double w_invert[3][3];
19
20     /* geomagnetic strength */
21     double bfield;
22
23     /* selection data */
24     float sample[MAGN_DS_SIZE][3];
25     unsigned int sample_count;
26     float average[3];
27 }
28 compass_cal_t;
29
30
31 typedef struct {
32     float bias_x, bias_y, bias_z;
33     int count;
34     float min_x, min_y, min_z;
35     float max_x, max_y, max_z;
36 }
37 gyro_cal_t;
38
39 /* Accelerometer bias estimation and compensation */
40
41 #define BUCKET_COUNT 3
42 #define BUCKET_TOLERANCE 1      /* Maximum monitoring distance from value of interest, in m/s² */
43 #define SLICES 100                  /* We currently have 3 buckets per axis, and 100 slices per bucket ; then we distribute incoming samples among slices */
44
45 typedef struct
46 {
47     int version;
48     int bucket_count;
49     int slices;
50     float bucket_tolerance;
51
52     uint64_t bucket[3][BUCKET_COUNT][SLICES];   /* How many samples fell in each of the slices, per axis */
53     uint64_t bucket_usage[3][BUCKET_COUNT];     /* How many samples fell in each of the buckets (= sum of the slice counts) */
54
55     /* Estimated bias, according to accumulated data */
56     float accel_bias_x;
57     float accel_bias_y;
58     float accel_bias_z;
59
60     uint64_t last_estimation_ts;
61 }
62 accel_cal_t;
63
64
65 typedef double mat_input_t[MAGN_DS_SIZE][3];
66
67
68 void calibrate_compass  (int s, sensors_event_t* event);
69 void compass_read_data  (int s);
70 void compass_store_data (int s);
71
72 void calibrate_gyro     (int s, sensors_event_t* event);
73 void gyro_cal_init      (int s);
74 void gyro_store_data    (int s);
75
76 void calibrate_accel    (int s, sensors_event_t* event);
77 void accel_cal_init     (int s);
78 void accel_cal_store    (int s);
79
80 #endif