mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-28 02:35:28 +00:00
driver: accel: Apply offsets after rotation
Offsets are in the axis of the device, not the sensor. Apply the offsets after rotiation BRANCH=cyan TEST=compile, test on cyan BUG=chromium:517675 Change-Id: Iae9282efcbb5889bb0f1f556b7e5ca9fabe31b22 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/294595 Reviewed-by: Sheng-liang Song <ssl@chromium.org>
This commit is contained in:
committed by
ChromeOS Commit Bot
parent
0e01759ced
commit
f7fa6248bf
@@ -417,16 +417,19 @@ static int read(const struct motion_sensor_t *s, vector_3_t v)
|
||||
*
|
||||
* Add calibration offset before returning the data.
|
||||
*/
|
||||
get_range(s, &range);
|
||||
get_resolution(s, &resolution);
|
||||
for (i = X; i <= Z; i++) {
|
||||
v[i] = (((int8_t)acc[i * 2 + 1]) << 4) |
|
||||
(acc[i * 2] >> 4);
|
||||
v[i] <<= (16 - resolution);
|
||||
v[i] += (data->offset[i] << 5) / range;
|
||||
}
|
||||
if (*s->rot_standard_ref != NULL)
|
||||
rotate(v, *s->rot_standard_ref, v);
|
||||
rotate(v, *s->rot_standard_ref, v);
|
||||
|
||||
/* apply offset in the device coordinates */
|
||||
get_range(s, &range);
|
||||
for (i = X; i <= Z; i++)
|
||||
v[i] += (data->offset[i] << 5) / range;
|
||||
|
||||
return EC_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -375,13 +375,15 @@ static int read(const struct motion_sensor_t *s, vector_3_t v)
|
||||
return ret;
|
||||
}
|
||||
|
||||
get_range(s, &range);
|
||||
for (i = X; i <= Z; i++) {
|
||||
for (i = X; i <= Z; i++)
|
||||
v[i] = ((int16_t)((raw[i * 2 + 1] << 8) | raw[i * 2]));
|
||||
|
||||
rotate(v, *s->rot_standard_ref, v);
|
||||
|
||||
/* apply offset in the device coordinates */
|
||||
get_range(s, &range);
|
||||
for (i = X; i <= Z; i++)
|
||||
v[i] += (data->offset[i] << 5) / range;
|
||||
}
|
||||
if (*s->rot_standard_ref != NULL)
|
||||
rotate(v, *s->rot_standard_ref, v);
|
||||
|
||||
return EC_SUCCESS;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user