Browse Source

AP_Compass: move responsibility for logging into library

master
Peter Barker 6 years ago committed by Andrew Tridgell
parent
commit
bf23f1df67
  1. 6
      libraries/AP_Compass/AP_Compass.cpp
  2. 6
      libraries/AP_Compass/AP_Compass.h

6
libraries/AP_Compass/AP_Compass.cpp

@ -981,7 +981,11 @@ Compass::read(void) @@ -981,7 +981,11 @@ Compass::read(void)
if (_learn == LEARN_INFLIGHT && learn != nullptr) {
learn->update();
}
return healthy();
bool ret = healthy();
if (ret && _log_bit != (uint32_t)-1 && AP::logger().should_log(_log_bit) && !AP::ahrs().have_ekf_logging()) {
AP::logger().Write_Compass();
}
return ret;
}
uint8_t

6
libraries/AP_Compass/AP_Compass.h

@ -143,6 +143,9 @@ public: @@ -143,6 +143,9 @@ public:
bool compass_cal_requires_reboot() const { return _cal_complete_requires_reboot; }
bool is_calibrating() const;
// indicate which bit in LOG_BITMASK indicates we should log compass readings
void set_log_bit(uint32_t log_bit) { _log_bit = log_bit; }
/*
handle an incoming MAG_CAL command
*/
@ -404,6 +407,9 @@ private: @@ -404,6 +407,9 @@ private:
// first-time-around flag used by offset nulling
bool _null_init_done;
// stores which bit is used to indicate we should log compass readings
uint32_t _log_bit = -1;
// used by offset correction
static const uint8_t _mag_history_size = 20;

Loading…
Cancel
Save