History

Fix for gyros' freaking out when disconnected.

Andrzej Kapolka committed 13 years ago

Commit f171b761 parent 7a24a563 files · +49 −23Browse files

Showing the changes to interface/src/SerialInterface.cpp (1 of 3 files). Show all

Unified · Split

interface/src/SerialInterface.cpp+4−1
@@ -225,7 +225,10 @@ void SerialInterface::readData(float deltaTime) { · 224 unmodified lines
225225
226226 // ask the invensense for raw gyro data
227227 short accelData[3];
228− mpu_get_accel_reg(accelData, 0);
228+ if (mpu_get_accel_reg(accelData, 0)) {
229+ _active = false;
230+ return; // disconnected
231+ }
229232
230233 const float LSB_TO_METERS_PER_SECOND2 = 1.f / 16384.f * GRAVITY_EARTH;
231234 // From MPU-9150 register map, with setting on