From aa77a8c5ecd554b55c86be2f3f17d8afc490efd4 Mon Sep 17 00:00:00 2001 From: Inno Park Date: Fri, 18 May 2018 17:07:55 +0900 Subject: nautilus: change the reference value, NOISY_MAGNITUDE_DEVIATION Changed NOISY_MAGNITUDE_DEVIATION from 1 to 1.5. Current value seems to be set too low. So ec could regard lid angle as unreliable even when sensors are at rest. BUG=b:79670788 BRANCH=firmware-poppy-10431.B TEST=Build & flash EC then ectool motionsense Change-Id: I07c3e5c2149e7dade567592a437d36d3a294b7af Signed-off-by: Inno Park Signed-off-by: Aseda Aboagye Reviewed-on: https://chromium-review.googlesource.com/1065954 Tested-by: Aseda Aboagye Tested-by: Ih-Yoo Park Reviewed-by: Ih-Yoo Park Reviewed-by: Philip Chen Commit-Queue: Ih-Yoo Park --- board/nautilus/board.h | 10 +++++++++- common/motion_lid.c | 20 ++++++-------------- include/config.h | 9 +++++++++ 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/board/nautilus/board.h b/board/nautilus/board.h index 74eced7a49..31c48f9b75 100644 --- a/board/nautilus/board.h +++ b/board/nautilus/board.h @@ -126,7 +126,15 @@ #define CONFIG_LID_ANGLE_UPDATE #define CONFIG_LID_ANGLE_TABLET_MODE #define CONFIG_LID_ANGLE_INVALID_CHECK -/* Lower maximal ODR to 100Hz */ +/* + * Workound for b/79670788. + * + * Be more lenient when determining valid lid angles. + */ +#undef CONFIG_NOISY_MAGNITUDE_DEVIATION +#define CONFIG_NOISY_MAGNITUDE_DEVIATION FLOAT_TO_FP(1.5) + +/* Lower maximal ODR to 100Hz. */ #define CONFIG_EC_MAX_SENSOR_FREQ_MILLIHZ 100000 /* FIFO size is in power of 2. */ diff --git a/common/motion_lid.c b/common/motion_lid.c index 38efea172e..a7c9f13f3b 100644 --- a/common/motion_lid.c +++ b/common/motion_lid.c @@ -104,15 +104,6 @@ static int lid_angle_is_reliable; */ #define DEBOUNCE_ANGLE_DELTA FLOAT_TO_FP(45) -/* - * Since the accelerometers are on the same physical device, they should be - * under the same acceleration. This constant, which mirrors - * kNoisyMagnitudeDeviation used in Chromium, is an integer which defines the - * maximum deviation in magnitude between the base and lid vectors. The units - * are in m/s^2. - */ -#define NOISY_MAGNITUDE_DEVIATION 1 - /* * Define the accelerometer orientation matrices based on the standard * reference frame in use (note: accel data is converted to standard ref @@ -280,8 +271,9 @@ static int calculate_lid_angle(const vector_3_t base, const vector_3_t lid, scaled_lid[Z] * scaled_lid[Z]) >> 6; /* - * Check to see if they differ than more than NOISY_MAGNITUDE_DEVIATION. - * If the vectors do, then the measured angle is unreliable. + * Check to see if they differ than more than + * CONFIG_NOISY_MAGNITUDE_DEVIATION. If the vectors do, then the + * measured angle is unreliable. * * Note, that we don't actually have to take the square root to get the * magnitude, but we can work with the magnitudes squared directly as @@ -297,10 +289,10 @@ static int calculate_lid_angle(const vector_3_t base, const vector_3_t lid, * If we assume that the average acceleration should be about 1g, then * we have: * - * (A^2 - B^2) < 2 * 1g * NOISY_MAGNITUDE_DEVIATION + * (A^2 - B^2) < 2 * 1g * CONFIG_NOISY_MAGNITUDE_DEVIATION */ - if (ABS(base_magnitude2 - lid_magnitude2) > - (2 * 10 * NOISY_MAGNITUDE_DEVIATION)) + if (FLOAT_TO_FP(ABS(base_magnitude2 - lid_magnitude2)) > + FLOAT_TO_FP(2 * 10 * CONFIG_NOISY_MAGNITUDE_DEVIATION)) reliable = 0; #ifdef CONFIG_LID_ANGLE_INVALID_CHECK diff --git a/include/config.h b/include/config.h index 5bf4f302bc..c8980a9aaf 100644 --- a/include/config.h +++ b/include/config.h @@ -2126,6 +2126,15 @@ /* Do not try hold I/O pins at frozen level during deep sleep */ #undef CONFIG_NO_PINHOLD +/* + * Since the accelerometers are on the same physical device, they should be + * under the same acceleration. This constant, which mirrors + * kNoisyMagnitudeDeviation used in Chromium, is an integer, 1, which defines + * the maximum deviation in magnitude between the base and lid vectors. The + * units are in m/s^2. + */ +#define CONFIG_NOISY_MAGNITUDE_DEVIATION FLOAT_TO_FP(1) + /* Support one-wire interface */ #undef CONFIG_ONEWIRE -- cgit v1.2.1