From b02c3608efd1e842a457046d3a6f0d98db16371b Mon Sep 17 00:00:00 2001 From: Michael Oborne Date: Thu, 13 Oct 2011 22:36:51 +0800 Subject: [PATCH] fix delta time in imu shim --- libraries/AP_IMU/AP_IMU_Shim.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libraries/AP_IMU/AP_IMU_Shim.h b/libraries/AP_IMU/AP_IMU_Shim.h index 57bf298414..4dea37330a 100644 --- a/libraries/AP_IMU/AP_IMU_Shim.h +++ b/libraries/AP_IMU/AP_IMU_Shim.h @@ -19,6 +19,13 @@ public: virtual bool update(void) { bool updated = _updated; _updated = false; + + // return number of microseconds since last call + uint32_t us = micros(); + uint32_t ret = us - last_ch6_micros; + last_ch6_micros = us; + + _sample_time = ret; return updated; } //@} @@ -54,6 +61,7 @@ public: private: /// set true when new data is delivered bool _updated; + uint32_t last_ch6_micros; }; #endif