OSDN Git Service

Filter invalid points for compass calibration.
authorAdriana Reus <adriana.reus@intel.com>
Fri, 8 Aug 2014 09:34:50 +0000 (12:34 +0300)
committerbuildslave <buildslave@buildbot.tl.intel.com>
Fri, 8 Aug 2014 15:20:22 +0000 (15:20 +0000)
Apparently the magnetometer on ECS sends an invalid first event
[x,y,z]=[0,0,0]. This is confusing the calibration and makes the entire
data invalid. Therefore the first calibration attempt always fails thus
wasting a lot of time.

Change-Id: Ibad68b2d4b4740ab7da6f5400426ffee5c29d6c5
Signed-off-by: Adriana Reus <adriana.reus@intel.com>
compass-calibration.c

index d194cdf..a03508d 100644 (file)
@@ -331,6 +331,10 @@ static int compass_collect (struct sensors_event_t* event, struct sensor_info_t*
     if (cal_data == NULL)
         return -1;
 
+    /* Discard the point if not valid */
+    if (data[0] == 0 && data[1] == 0 && data[2] == 0)
+        return -1;
+
 #ifdef DBG_RAW_DATA
     if (raw_data && raw_data_count < MAX_RAW_DATA_COUNT) {
         fprintf(raw_data, "%f %f %f\n", (double)data[0], (double)data[1],