OSDN Git Service

Magneto calibration tweaks
[android-x86/hardware-intel-libsensors.git] / compass-calibration.c
index 724ae43..2202dc3 100644 (file)
@@ -21,12 +21,14 @@ static int raw_data_count = 0;
 int file_no = 0;
 #endif
 
+#define CAL_STEPS 5
+
 /* 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 };
+static const float min_diffs[CAL_STEPS] =  {0.15,  0.2, 0.4, 0.6, 1.0 };
+static const float max_sqr_errs[CAL_STEPS] = {10.0, 10.0, 8.0, 5.0, 3.5 };
+static const unsigned int lookback_counts[CAL_STEPS] = {2, 3, 4, 5, 6 };
 
 /* reset calibration algorithm */
 static void reset_sample (struct compass_cal* data)
@@ -338,7 +340,7 @@ static int compass_collect (struct sensors_event_t* event, struct sensor_info_t*
         return -1;
 
     /* Discard the point if not valid */
-    if (data[0] == 0 && data[1] == 0 && data[2] == 0)
+    if (data[0] == 0 || data[1] == 0 || data[2] == 0)
         return -1;
 
 #ifdef DBG_RAW_DATA