mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-01 12:46:12 +00:00
d/psmv: Improve accelerometer adjustment
This commit is contained in:
parent
2e5c8f43a0
commit
2a6e194b2d
|
@ -383,16 +383,24 @@ psmv_read_process_last(struct psmv_device *psmv)
|
||||||
{
|
{
|
||||||
struct xrt_vec3_i32 *raw = &psmv->last.frame[1].accel;
|
struct xrt_vec3_i32 *raw = &psmv->last.frame[1].accel;
|
||||||
|
|
||||||
//! @todo This is clearly wrong.
|
//! @todo Pre-calculate this.
|
||||||
psmv->read.accel.x =
|
double ax = (psmv->accel_max_x.x - psmv->accel_min_x.x) / 2.0;
|
||||||
(float)raw->x / (raw->x < 0 ? (float)psmv->accel_min_x.x
|
double ay = (psmv->accel_max_y.y - psmv->accel_min_y.y) / 2.0;
|
||||||
: -(float)psmv->accel_max_x.x);
|
double az = (psmv->accel_max_z.z - psmv->accel_min_z.z) / 2.0;
|
||||||
psmv->read.accel.y =
|
|
||||||
(float)raw->y / (raw->y < 0 ? (float)psmv->accel_min_y.y
|
double bx = (psmv->accel_min_y.x + psmv->accel_min_y.x +
|
||||||
: -(float)psmv->accel_max_y.y);
|
psmv->accel_min_z.x + psmv->accel_min_z.x) /
|
||||||
psmv->read.accel.z =
|
-4.0;
|
||||||
(float)raw->z / (raw->z < 0 ? (float)psmv->accel_min_z.z
|
double by = (psmv->accel_min_x.y + psmv->accel_min_x.y +
|
||||||
: -(float)psmv->accel_max_z.z);
|
psmv->accel_min_z.y + psmv->accel_min_z.y) /
|
||||||
|
-4.0;
|
||||||
|
double bz = (psmv->accel_min_x.z + psmv->accel_min_x.z +
|
||||||
|
psmv->accel_min_y.z + psmv->accel_min_y.z) /
|
||||||
|
-4.0;
|
||||||
|
|
||||||
|
psmv->read.accel.x = (raw->x + bx) / ax;
|
||||||
|
psmv->read.accel.y = (raw->y + by) / ay;
|
||||||
|
psmv->read.accel.z = (raw->z + bz) / az;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
Loading…
Reference in a new issue