summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2016-08-18 15:34:07 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-09-09 12:33:18 -0700
commit2b82ad78004e8ce37272743792acdb347a5a1001 (patch)
treef999255f32ccdff5dcfed9ae2f5e3115e98aed49 /test
parent00a0353a8860ec362d94c2ac3924142426fe06ac (diff)
downloadchrome-ec-2b82ad78004e8ce37272743792acdb347a5a1001.tar.gz
motion_lid: prevent angle 0 <-> 360 transition.
When lid is closed, the lid angle can move to 358, 360, 0, 359 ... Prevent transition 0 from/to 360 by keeping the last calculated value. BRANCH=kevin BUG=chrome-os-partner:55702 TEST=Check transition does not happen anymore. Change-Id: Ifa8415470f425c893e2c3662c84c8fd0156e0524 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/373040 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'test')
-rw-r--r--test/motion_lid.c27
-rw-r--r--test/test_config.h1
2 files changed, 28 insertions, 0 deletions
diff --git a/test/motion_lid.c b/test/motion_lid.c
index 26eff7f1a4..f610250e9c 100644
--- a/test/motion_lid.c
+++ b/test/motion_lid.c
@@ -230,6 +230,33 @@ static int test_lid_angle(void)
wait_for_valid_sample();
TEST_ASSERT(motion_lid_get_angle() == 225);
+ /* Set lid open to 350 */
+ lid->xyz[X] = 0;
+ lid->xyz[Y] = -173;
+ lid->xyz[Z] = -984;
+ wait_for_valid_sample();
+ TEST_ASSERT(motion_lid_get_angle() == 350);
+
+ /* Set lid open to 10, check rotation did not change. */
+ lid->xyz[X] = 0;
+ lid->xyz[Y] = 173;
+ lid->xyz[Z] = -984;
+ wait_for_valid_sample();
+ TEST_ASSERT(motion_lid_get_angle() == 350);
+
+ /* Rotate back to 180 and then 10 */
+ lid->xyz[X] = 0;
+ lid->xyz[Y] = 0;
+ lid->xyz[Z] = 1000;
+ wait_for_valid_sample();
+ TEST_ASSERT(motion_lid_get_angle() == 180);
+
+ lid->xyz[X] = 0;
+ lid->xyz[Y] = 173;
+ lid->xyz[Z] = -984;
+ wait_for_valid_sample();
+ TEST_ASSERT(motion_lid_get_angle() == 10);
+
/*
* Align base with hinge and make sure it returns unreliable for angle.
* In this test it doesn't matter what the lid acceleration vector is.
diff --git a/test/test_config.h b/test/test_config.h
index dacfe04868..ffb8e877f4 100644
--- a/test/test_config.h
+++ b/test/test_config.h
@@ -44,6 +44,7 @@
#ifdef TEST_MOTION_LID
#define CONFIG_LID_ANGLE
+#define CONFIG_LID_ANGLE_INVALID_CHECK
#define CONFIG_LID_ANGLE_SENSOR_BASE 0
#define CONFIG_LID_ANGLE_SENSOR_LID 1
#endif