summaryrefslogtreecommitdiff
path: root/common/motion_lid.c
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2015-08-20 11:33:10 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-08-22 01:37:55 +0000
commitf59ab4c5f3381d6ed838168dd03e1c93e189129d (patch)
tree719d3774c8cbfd650b0b389073b3149f4550b813 /common/motion_lid.c
parent9312676ab37de0be031d79629177c5590e83cc65 (diff)
downloadchrome-ec-f59ab4c5f3381d6ed838168dd03e1c93e189129d.tar.gz
cyan: fix sensors matrices
Matches definitons set in chromium/chromeos/accelerometer/accelerometer_types.h. Using that standard, the coordinate frames of the lid and base DO NOT line up perfectly when the lid is fully closed or fully open. Therefore, rotate the lid vector 180 along the X axis before calculating the lid angle. BRANCH=cyan BUG=chrome-os-partner:40177 TEST=When the device is open 180 degrees, check the sensors agree with each other: Flat on the back (Z pointing to the sky): localhost devices # cat */*raw -1008 [keyboard : X] -112 [keyboard : Y] 16544 [kyeboard : Z] -256 [lid : X ] 2000 [lid : Y ] 16336 [lid : Z ] On the right side (X pointing to the ground) localhost devices # cat */*raw -16928 -48 -1040 -16176 432 80 On the bottom edge (Y pointing to the sky) localhost devices # cat */*raw -192 15872 1648 496 15936 752 Check the angle as calculated by the EC is correct using accelinfo. Change-Id: Ib8ee42da8cf818213f892b1f024253f37a4da488 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/294716 Reviewed-by: Jonathan Ross <jonross@chromium.org> Reviewed-by: Eric Caruso <ejcaruso@chromium.org>
Diffstat (limited to 'common/motion_lid.c')
-rw-r--r--common/motion_lid.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/common/motion_lid.c b/common/motion_lid.c
index eca904f900..32fea49e18 100644
--- a/common/motion_lid.c
+++ b/common/motion_lid.c
@@ -147,10 +147,14 @@ int motion_lid_get_angle(void)
*/
void motion_lid_calc(void)
{
+ /* rotate lid vector by 180 degre to be in the right coordinate frame */
+ vector_3_t lid = { accel_lid->xyz[X],
+ accel_lid->xyz[Y] * -1,
+ accel_lid->xyz[Z] * -1};
+
/* Calculate angle of lid accel. */
lid_angle_is_reliable = calculate_lid_angle(
- accel_base->xyz,
- accel_lid->xyz,
+ accel_base->xyz, lid,
&lid_angle_deg);
#ifdef CONFIG_LID_ANGLE_UPDATE