From 7814f3319e7331ae9f3313d2a04e14b0bc1f1a90 Mon Sep 17 00:00:00 2001 From: philipchen Date: Tue, 14 Mar 2017 17:40:49 -0700 Subject: 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 Tested-by: Philip Chen Reviewed-by: Aseda Aboagye (cherry picked from commit 75ba9147c392367037c21e79899f463c32c1f92f) Reviewed-on: https://chromium-review.googlesource.com/457137 Commit-Ready: Philip Chen --- common/motion_lid.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'common/motion_lid.c') diff --git a/common/motion_lid.c b/common/motion_lid.c index 8572db928c..d36ecc5e64 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; -- cgit v1.2.1