OSDN Git Service

Fix for broken indexes in compass calibration
[android-x86/hardware-intel-libsensors.git] / calibration.h
index a803beb..6cae977 100644 (file)
 #define COMPASS_CALIBRATION_PATH "/data/compass.conf"
 #define DS_SIZE 32
 #define EPSILON 0.000000001
-#define CAL_STEPS 4
-
-/* We'll have multiple calibration levels
-*  so that we can provide an estimation as fast as possible
-*/
-static const float min_diffs[CAL_STEPS] =  { 0.2, 0.4, 0.6, 1.0 };
-static const float max_sqr_errs[CAL_STEPS] = { 10.0, 8.0, 5.0, 3.5 };
-static const unsigned int lookback_counts[CAL_STEPS] = { 3, 4, 5, 6 };
 
+#define MAGNETIC_LOW 960 /* 31 micro tesla squared */
+#define MAGNETIC_HIGH 3600 /* 60 micro tesla squared */
 
 #ifdef DBG_RAW_DATA
 #define RAW_DATA_FULL_PATH "/data/raw_compass_data_full_%d.txt"
@@ -29,6 +23,7 @@ static const unsigned int lookback_counts[CAL_STEPS] = { 3, 4, 5, 6 };
 /* gyro defines */
 #define GYRO_MAX_ERR 0.05f
 #define GYRO_DS_SIZE 100
+#define GYRO_CALIBRATION_PATH "/data/gyro.conf"
 
 struct compass_cal {
     /* hard iron offsets */
@@ -46,10 +41,10 @@ struct compass_cal {
 };
 
 struct gyro_cal {
-    float bias[3];
-    int start;
+    float bias_x, bias_y, bias_z;
     int count;
-    float sample[GYRO_DS_SIZE][3];
+    float min_x, min_y, min_z;
+    float max_x, max_y, max_z;
 };
 
 typedef double mat_input_t[DS_SIZE][3];
@@ -60,4 +55,5 @@ void compass_store_data (struct sensor_info_t* info);
 
 void calibrate_gyro(struct sensors_event_t* event, struct sensor_info_t* info);
 void gyro_cal_init(struct sensor_info_t* info);
+void gyro_store_data (struct sensor_info_t* info);
 #endif