2 * Copyright (C) 2014 Intel Corporation.
5 #ifndef __CALIBRATION_H__
6 #define __CALIBRATION_H__
11 #define COMPASS_CALIBRATION_PATH "/data/compass.conf"
13 #define EPSILON 0.000000001
16 #define MAGNETIC_LOW 960 /* 31 micro tesla squared */
17 #define MAGNETIC_HIGH 3600 /* 60 micro tesla squared */
20 #define RAW_DATA_FULL_PATH "/data/raw_compass_data_full_%d.txt"
21 #define RAW_DATA_SELECTED_PATH "/data/raw_compass_data_selected_%d.txt"
25 #define GYRO_MAX_ERR 0.05f
26 #define GYRO_DS_SIZE 100
27 #define GYRO_CALIBRATION_PATH "/data/gyro.conf"
30 /* hard iron offsets */
33 /* soft iron matrix */
34 double w_invert[3][3];
36 /* geomagnetic strength */
40 float sample[DS_SIZE][3];
41 unsigned int sample_count;
45 float bias_x, bias_y, bias_z;
47 float min_x, min_y, min_z;
48 float max_x, max_y, max_z;
51 typedef double mat_input_t[DS_SIZE][3];
53 void calibrate_compass (struct sensors_event_t* event, struct sensor_info_t* info, int64_t time);
54 void compass_read_data (struct sensor_info_t* info);
55 void compass_store_data (struct sensor_info_t* info);
57 void calibrate_gyro(struct sensors_event_t* event, struct sensor_info_t* info);
58 void gyro_cal_init(struct sensor_info_t* info);
59 void gyro_store_data (struct sensor_info_t* info);