aboutsummaryrefslogtreecommitdiff
path: root/src/drivers/mpu6000/mpu6000.cpp
diff options
context:
space:
mode:
authorLorenz Meier <lm@inf.ethz.ch>2015-03-25 21:53:03 -0700
committerLorenz Meier <lm@inf.ethz.ch>2015-03-25 21:53:03 -0700
commit1bbfe571fa4fb911e11f17aff4c2e2ff0d065566 (patch)
treef04ed9b41ff0075c1165a2824cf7c7bc2cf41608 /src/drivers/mpu6000/mpu6000.cpp
parent4318a26b64330bbc50a3df6846efe81eaa83aa38 (diff)
parent9442fc13e4a93ba43300aa4648e9c9033075a70e (diff)
downloadpx4-firmware-1bbfe571fa4fb911e11f17aff4c2e2ff0d065566.tar.gz
px4-firmware-1bbfe571fa4fb911e11f17aff4c2e2ff0d065566.tar.bz2
px4-firmware-1bbfe571fa4fb911e11f17aff4c2e2ff0d065566.zip
Merge branch 'pullrequest-imu-temperature' of git://github.com/tridge/Firmware
Diffstat (limited to 'src/drivers/mpu6000/mpu6000.cpp')
-rw-r--r--src/drivers/mpu6000/mpu6000.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/drivers/mpu6000/mpu6000.cpp b/src/drivers/mpu6000/mpu6000.cpp
index eaf25a9f3..727132a64 100644
--- a/src/drivers/mpu6000/mpu6000.cpp
+++ b/src/drivers/mpu6000/mpu6000.cpp
@@ -284,6 +284,9 @@ private:
// self test
volatile bool _in_factory_test;
+ // last temperature reading for print_info()
+ float _last_temperature;
+
/**
* Start automatic measurement.
*/
@@ -518,7 +521,8 @@ MPU6000::MPU6000(int bus, const char *path_accel, const char *path_gyro, spi_dev
_gyro_filter_z(MPU6000_GYRO_DEFAULT_RATE, MPU6000_GYRO_DEFAULT_DRIVER_FILTER_FREQ),
_rotation(rotation),
_checked_next(0),
- _in_factory_test(false)
+ _in_factory_test(false),
+ _last_temperature(0)
{
// disable debug() calls
_debug_enabled = false;
@@ -1729,8 +1733,10 @@ MPU6000::measure()
arb.scaling = _accel_range_scale;
arb.range_m_s2 = _accel_range_m_s2;
+ _last_temperature = (report.temp) / 361.0f + 35.0f;
+
arb.temperature_raw = report.temp;
- arb.temperature = (report.temp) / 361.0f + 35.0f;
+ arb.temperature = _last_temperature;
grb.x_raw = report.gyro_x;
grb.y_raw = report.gyro_y;
@@ -1755,7 +1761,7 @@ MPU6000::measure()
grb.range_rad_s = _gyro_range_rad_s;
grb.temperature_raw = report.temp;
- grb.temperature = (report.temp) / 361.0f + 35.0f;
+ grb.temperature = _last_temperature;
_accel_reports->force(&arb);
_gyro_reports->force(&grb);
@@ -1803,6 +1809,7 @@ MPU6000::print_info()
(unsigned)_checked_values[i]);
}
}
+ ::printf("temperature: %.1f\n", _last_temperature);
}
void