From 68f3a5913b4050d4e2fc30e42ee5b7e245c4abda Mon Sep 17 00:00:00 2001 From: Devin Lu Date: Tue, 30 Oct 2018 18:39:14 +0800 Subject: meep: fix sensor data and accel orientation This patch fix the lid and base accel orientation for EVT and change range value to 2g. BUG=none BRANCH=none TEST=When device is laying on a table, lid angle at 180, both sensors report gravity along Z axis: ectool motionsense Motion sensing active Sensor 0: 507 606 16748 Sensor 1: 17 -334 16442 Sensor 2: 0 0 0 Sensor 3: 0 0 0 When on the base bottom edge, report gravity along Y axis: ectool motionsense Motion sensing active Sensor 0: 403 16491 655 Sensor 1: 19 16163 1540 Sensor 2: 0 0 0 Sensor 3: 0 0 0 When on its left side, report gravity along X axis: ectool motionsense Motion sensing active Sensor 0: 16172 -374 1738 Sensor 1: 16315 -184 1280 Sensor 2: 0 0 0 Sensor 3: 0 0 0 and check the screen rotation was normally. Change-Id: Ic594c12fa4b03b594151eed4ffb0f0e5b42cad3d Signed-off-by: Devin Lu Reviewed-on: https://chromium-review.googlesource.com/1307282 Reviewed-by: Justin TerAvest --- board/meep/board.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/board/meep/board.c b/board/meep/board.c index 0f7e2f12ff..8b966135ca 100644 --- a/board/meep/board.c +++ b/board/meep/board.c @@ -122,10 +122,16 @@ static struct mutex g_lid_mutex; static struct mutex g_base_mutex; /* Matrix to rotate accelrator into standard reference frame */ +const mat33_fp_t lid_standrd_ref = { + { FLOAT_TO_FP(1), 0, 0}, + { 0, FLOAT_TO_FP(-1), 0}, + { 0, 0, FLOAT_TO_FP(-1)} +}; + const mat33_fp_t base_standard_ref = { + { FLOAT_TO_FP(1), 0, 0}, { 0, FLOAT_TO_FP(-1), 0}, - { FLOAT_TO_FP(1), 0, 0}, - { 0, 0, FLOAT_TO_FP(1)} + { 0, 0, FLOAT_TO_FP(-1)} }; const mat33_fp_t mag_standard_ref = { @@ -153,8 +159,8 @@ struct motion_sensor_t motion_sensors[] = { .drv_data = &g_kx022_data, .port = I2C_PORT_SENSOR, .addr = KX022_ADDR1, - .rot_standard_ref = NULL, /* Identity matrix. */ - .default_range = 4, /* g */ + .rot_standard_ref = &lid_standrd_ref, + .default_range = 2, /* g */ .config = { /* EC use accel for angle detection */ [SENSOR_CONFIG_EC_S0] = { @@ -179,7 +185,7 @@ struct motion_sensor_t motion_sensors[] = { .port = I2C_PORT_SENSOR, .addr = LSM6DSM_ADDR0, .rot_standard_ref = &base_standard_ref, - .default_range = 4, /* g */ + .default_range = 2, /* g */ .min_frequency = LSM6DSM_ODR_MIN_VAL, .max_frequency = LSM6DSM_ODR_MAX_VAL, .config = { -- cgit v1.2.1