From 40a635051d4e2137a10a35a96325062604596ee2 Mon Sep 17 00:00:00 2001 From: Adriana Reus Date: Mon, 3 Nov 2014 16:04:30 +0200 Subject: [PATCH] Magneto calibration tweaks Tracked-On: https://jira01.devtools.intel.com/browse/GMINL-3514 Change-Id: I7c1f61310218551ce84fd0a497f57b850490d4a9 Signed-off-by: Adriana Reus --- calibration.h | 1 - compass-calibration.c | 10 ++++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/calibration.h b/calibration.h index 4e2b05e..6cae977 100644 --- a/calibration.h +++ b/calibration.h @@ -11,7 +11,6 @@ #define COMPASS_CALIBRATION_PATH "/data/compass.conf" #define DS_SIZE 32 #define EPSILON 0.000000001 -#define CAL_STEPS 4 #define MAGNETIC_LOW 960 /* 31 micro tesla squared */ #define MAGNETIC_HIGH 3600 /* 60 micro tesla squared */ diff --git a/compass-calibration.c b/compass-calibration.c index 724ae43..2202dc3 100644 --- a/compass-calibration.c +++ b/compass-calibration.c @@ -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 -- 2.11.0