From: Patrick Porlan Date: Wed, 27 Aug 2014 16:36:43 +0000 (+0200) Subject: GMIN-3015: Refine a little bit the magnetometer accuracy indicator X-Git-Tag: android-x86-7.1-r1~57^2~4 X-Git-Url: http://git.osdn.net/view?p=android-x86%2Fhardware-intel-libsensors.git;a=commitdiff_plain;h=25e58ad35313cfa048d49295e37aef25e1170d4c GMIN-3015: Refine a little bit the magnetometer accuracy indicator 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 --- diff --git a/compass-calibration.c b/compass-calibration.c index 2909ccd..0cec055 100644 --- a/compass-calibration.c +++ b/compass-calibration.c @@ -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; } }