summaryrefslogtreecommitdiff
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
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>
-rw-r--r--board/cyan/board.c4
-rw-r--r--common/motion_lid.c8
2 files changed, 8 insertions, 4 deletions
diff --git a/board/cyan/board.c b/board/cyan/board.c
index 568c32e765..d77dbeb45c 100644
--- a/board/cyan/board.c
+++ b/board/cyan/board.c
@@ -111,8 +111,8 @@ const matrix_3x3_t base_standard_ref = {
const matrix_3x3_t lid_standard_ref = {
{FLOAT_TO_FP(-1), 0, 0},
- { 0, FLOAT_TO_FP(-1), 0},
- { 0, 0, FLOAT_TO_FP(1)}
+ { 0, FLOAT_TO_FP(1), 0},
+ { 0, 0, FLOAT_TO_FP(-1)}
};
struct motion_sensor_t motion_sensors[] = {
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