summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorphilipchen <philipchen@google.com>2017-03-14 17:40:49 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2017-06-06 18:00:57 +0000
commit71bdb186ee78c476e170889836a477da664c5763 (patch)
tree86a0d828fd5c68ef3ae076a9ca1dd3be08dd9bc1
parent58c5fd55dc3b725fd633582bb321927653863fef (diff)
downloadchrome-ec-71bdb186ee78c476e170889836a477da664c5763.tar.gz
motion_lid: no angle correction when lid close
BUG=b:36107214 BRANCH=gru TEST=manually on kevin: (1) make DUT in tablet mode (2) swiftly close the lid (3) check ec log and confirm DUT can read small angle and turn into clamshell mode when lid is closed. TEST=make runtests Change-Id: I7ebf10d38a8b300960ebf46be717d48522c6fd0b Reviewed-on: https://chromium-review.googlesource.com/455458 Commit-Queue: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> (cherry picked from commit 75ba9147c392367037c21e79899f463c32c1f92f) Reviewed-on: https://chromium-review.googlesource.com/457137 Commit-Ready: Philip Chen <philipchen@chromium.org> (cherry picked from commit 7814f3319e7331ae9f3313d2a04e14b0bc1f1a90) Reviewed-on: https://chromium-review.googlesource.com/525897 Commit-Queue: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Trybot-Ready: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r--common/motion_lid.c7
-rw-r--r--test/motion_lid.c14
2 files changed, 19 insertions, 2 deletions
diff --git a/common/motion_lid.c b/common/motion_lid.c
index 881866d5cc..c1b41e7720 100644
--- a/common/motion_lid.c
+++ b/common/motion_lid.c
@@ -323,11 +323,14 @@ static int calculate_lid_angle(const vector_3_t base, const vector_3_t lid,
/*
* If the angle was last seen as really large and now it's quite
* small, we may be rotating around from 360->0 so correct it to
- * be large.
+ * be large. But in case that the lid switch is closed, we can
+ * prove the small angle we see is correct so we take the angle
+ * as is.
*/
if ((last_lid_angle_fp >=
FLOAT_TO_FP(360) - DEBOUNCE_ANGLE_DELTA) &&
- (lid_to_base_fp <= DEBOUNCE_ANGLE_DELTA))
+ (lid_to_base_fp <= DEBOUNCE_ANGLE_DELTA) &&
+ (lid_is_open()))
last_lid_angle_fp = FLOAT_TO_FP(360) - lid_to_base_fp;
else
last_lid_angle_fp = lid_to_base_fp;
diff --git a/test/motion_lid.c b/test/motion_lid.c
index dfea3ecf91..bed03379ff 100644
--- a/test/motion_lid.c
+++ b/test/motion_lid.c
@@ -316,6 +316,20 @@ static int test_lid_angle(void)
wait_for_valid_sample();
TEST_ASSERT(motion_lid_get_angle() == LID_ANGLE_UNRELIABLE);
+ /*
+ * Open the lid to 350, and then close the lid and set the angle
+ * to 10. The reading of small angle shouldn't be corrected.
+ */
+ gpio_set_level(GPIO_LID_OPEN, 1);
+ msleep(100);
+ gpio_set_level(GPIO_LID_OPEN, 0);
+ msleep(100);
+ lid->xyz[X] = 0;
+ lid->xyz[Y] = 173;
+ lid->xyz[Z] = -984;
+ wait_for_valid_sample();
+ TEST_ASSERT(motion_lid_get_angle() == 10);
+
return EC_SUCCESS;
}