diff options
author | Daniel Friesel <derf@finalrewind.org> | 2020-03-08 15:56:36 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2020-03-08 15:56:36 +0100 |
commit | d90a84032348f63f8b45b718939a0e957169b8a8 (patch) | |
tree | 257fa74d5b2a9e25a5bfb730cc734daf55450084 /src/app/mpu9250_motionlog/main.cc | |
parent | abf3d1d93c33267e374c1dd93b2e96a7f72186c4 (diff) |
mpu9250_motionlog: monitor magnetism
Diffstat (limited to 'src/app/mpu9250_motionlog/main.cc')
-rw-r--r-- | src/app/mpu9250_motionlog/main.cc | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/app/mpu9250_motionlog/main.cc b/src/app/mpu9250_motionlog/main.cc index 5165884..18bd895 100644 --- a/src/app/mpu9250_motionlog/main.cc +++ b/src/app/mpu9250_motionlog/main.cc @@ -17,6 +17,9 @@ int main(void) INIT0(ax); INIT0(ay); INIT0(az); + INIT0(mx); + INIT0(my); + INIT0(mz); unsigned short i = 0; arch.setup(); @@ -40,7 +43,8 @@ int main(void) kout << "I2C setup OK" << endl; mpu9250.init(); - mpu9250.accelOnly(); + mpu9250.nineAxis(); + mpu9250.setGyroEnable(false, false, false); while (1) { mpu9250.getRawAccel(&ax, &ay, &az); @@ -52,12 +56,25 @@ int main(void) UPDATE_MAX(max_ay, ay); UPDATE_MAX(max_az, az); + if (mpu9250.getRawMagnet(&mx, &my, &mz)) { + UPDATE_MIN(min_mx, mx); + UPDATE_MIN(min_my, my); + UPDATE_MIN(min_mz, mz); + UPDATE_MAX(max_mx, mx); + UPDATE_MAX(max_my, my); + UPDATE_MAX(max_mz, mz); + } + if (i++ == 2000) { kout << "Min Accel: " << min_ax << " / " << min_ay << " / " << min_az << endl; kout << "Max Accel: " << max_ax << " / " << max_ay << " / " << max_az << endl; + kout << "Min Magnet: " << min_mx << " / " << min_my << " / " << min_mz << endl; + kout << "Max Magnet: " << max_mx << " / " << max_my << " / " << max_mz << endl; kout << "Temp: " << mpu9250.getTemperature() << endl; min_ax = min_ay = min_az = 30000; max_ax = max_ay = max_az = -30000; + min_mx = min_my = min_mz = 30000; + max_mx = max_my = max_mz = -30000; i = 0; if (ADCSRA & _BV(ADIF)) { uint8_t adcr_l = ADCL; |