diff options
author | Daniel Friesel <derf@finalrewind.org> | 2021-12-13 21:54:01 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2021-12-13 21:54:01 +0100 |
commit | 2baa0a1d8584b4fff1df548437882fa6c908350e (patch) | |
tree | 5dcdfb026774aeb3707d84443b4d94a617c27fb9 /src/driver | |
parent | 7f2e4f346d446acfd60ac2fc61dcae370f91e159 (diff) |
mpu9250: Implement getMagnet function
TODO: Use ASA[XYZ] for sensitivity adjustment
Diffstat (limited to 'src/driver')
-rw-r--r-- | src/driver/mpu9250.cc | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/driver/mpu9250.cc b/src/driver/mpu9250.cc index de47597..3ad91c7 100644 --- a/src/driver/mpu9250.cc +++ b/src/driver/mpu9250.cc @@ -222,6 +222,21 @@ bool MPU9250::getRawMagnet(int *x, int *y, int *z) } } +bool MPU9250::getMagnet(float *ut_x, float *ut_y, float *ut_z) +{ + int x, y, z; + bool success = getRawMagnet(&x, &y, &z); + + if (!success) { + return false; + } + + *ut_x = x * 0.15; + *ut_y = y * 0.15; + *ut_z = z * 0.15; + return true; +} + // mpu9250.dfa void MPU9250::nineAxis() |