OSDN Git Service

GMIN-3015: Refine a little bit the magnetometer accuracy indicator
authorPatrick Porlan <patrick.porlan@intel.com>
Wed, 27 Aug 2014 16:36:43 +0000 (18:36 +0200)
committerAdriana Reus <adriana.reus@intel.com>
Mon, 8 Sep 2014 07:46:36 +0000 (10:46 +0300)
We now start at the default (unreliable) level then increase as we
go through calibration stages.

Issue: GMIN-3015

Change-Id: I3432feaad3426748b991da94bc41983d0b97943d
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
compass-calibration.c

index 2909ccd..0cec055 100644 (file)
@@ -454,12 +454,33 @@ static int compass_ready (struct sensor_info_t* info)
 void calibrate_compass (struct sensors_event_t* event, struct sensor_info_t* info, int64_t current_time)
 {
     long current_time_ms = current_time / 1000000;
+    int cal_level;
+
+    /* Calibration is continuous */
     compass_collect (event, info, current_time_ms);
-    if (compass_ready(info)) {
-        compass_compute_cal (event, info);
-        event->magnetic.status = SENSOR_STATUS_ACCURACY_HIGH;
-    } else {
-        event->magnetic.status = SENSOR_STATUS_ACCURACY_LOW;
+
+    cal_level = compass_ready(info);
+
+    switch (cal_level) {
+
+        case 0:
+            event->magnetic.status = SENSOR_STATUS_UNRELIABLE;
+            break;
+
+        case 1:
+            compass_compute_cal (event, info);
+            event->magnetic.status = SENSOR_STATUS_ACCURACY_LOW;
+            break;
+
+        case 2:
+            compass_compute_cal (event, info);
+            event->magnetic.status = SENSOR_STATUS_ACCURACY_MEDIUM;
+            break;
+
+        default:
+            compass_compute_cal (event, info);
+            event->magnetic.status = SENSOR_STATUS_ACCURACY_HIGH;
+            break;
     }
 }