Skip to content

Commit

Permalink
[rotorcraft] only calc mag dt if actually using mag
Browse files Browse the repository at this point in the history
  • Loading branch information
flixr committed Sep 8, 2014
1 parent 8f41c6f commit efce663
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions sw/airborne/firmwares/rotorcraft/main.c
Expand Up @@ -378,6 +378,9 @@ static inline void on_gps_event(void) {
}

static inline void on_mag_event(void) {
ImuScaleMag(imu);

#if USE_MAGNETOMETER
#if USE_AUTO_AHRS_FREQ || !defined(AHRS_MAG_CORRECT_FREQUENCY)
PRINT_CONFIG_MSG("Calculating dt for AHRS mag update.")
// timestamp when last callback was received
Expand All @@ -393,13 +396,10 @@ PRINT_CONFIG_VAR(AHRS_MAG_CORRECT_FREQUENCY)
const float dt = (1./AHRS_MAG_CORRECT_FREQUENCY);
#endif

ImuScaleMag(imu);

#if USE_MAGNETOMETER
if (ahrs.status == AHRS_RUNNING) {
ahrs_update_mag(dt);
}
#endif
#endif // USE_MAGNETOMETER

#ifdef USE_VEHICLE_INTERFACE
vi_notify_mag_available();
Expand Down

0 comments on commit efce663

Please sign in to comment.