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 /* If no cal data is present - first calibration will
17 use a more relaxed set of values to get an initial
19 #define FIRST_MIN_DIFF 0.5f
20 #define FIRST_MAX_SQR_ERR 5.0f
21 #define FIRST_LOOKBACK_COUNT 4
24 #define MAX_SQR_ERR 3.5f
25 #define LOOKBACK_COUNT 6
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"
34 #define GYRO_MAX_ERR 0.05f
35 #define GYRO_DS_SIZE 8
38 /* hard iron offsets */
41 /* soft iron matrix */
42 double w_invert[3][3];
44 /* geomagnetic strength */
48 float sample[DS_SIZE][3];
49 unsigned int sample_count;
56 float sample[GYRO_DS_SIZE][3];
59 typedef double mat_input_t[DS_SIZE][3];
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);
65 void calibrate_gyro(struct sensors_event_t* event, struct sensor_info_t* info);
66 void gyro_cal_init(struct sensor_info_t* info);