diff --git a/libraries/AP_Compass/AP_Compass.cpp b/libraries/AP_Compass/AP_Compass.cpp index 015fc06a1f..4d8db95e30 100644 --- a/libraries/AP_Compass/AP_Compass.cpp +++ b/libraries/AP_Compass/AP_Compass.cpp @@ -383,7 +383,6 @@ Compass::Compass(void) : for (uint8_t i=0; idelay(1000); hal.scheduler->reboot(false); } } bool -Compass::start_calibration(uint8_t i, bool retry, bool autosave, float delay, bool autoreboot) +Compass::_start_calibration(uint8_t i, bool retry, float delay) { if (!healthy(i)) { return false; } - memset(_reports_sent,0,sizeof(_reports_sent)); - if (!is_calibrating() && delay > 0.5f) { + if (!use_for_yaw(i)) { + return false; + } + if (!is_calibrating()) { AP_Notify::events.initiated_compass_cal = 1; } if (i == get_primary() && _state[i].external != 0) { @@ -57,8 +61,8 @@ Compass::start_calibration(uint8_t i, bool retry, bool autosave, float delay, bo // lot noisier _calibrator[i].set_tolerance(_calibration_threshold*2); } - _calibrator[i].start(retry, autosave, delay); - _compass_cal_autoreboot = autoreboot; + _cal_saved[i] = false; + _calibrator[i].start(retry, delay); // disable compass learning both for calibration and after completion _learn.set_and_save(0); @@ -67,26 +71,15 @@ Compass::start_calibration(uint8_t i, bool retry, bool autosave, float delay, bo } bool -Compass::start_calibration_mask(uint8_t mask, bool retry, bool autosave, float delay, bool autoreboot) +Compass::_start_calibration_mask(uint8_t mask, bool retry, bool autosave, float delay, bool autoreboot) { + _cal_autosave = autosave; + _compass_cal_autoreboot = autoreboot; + for (uint8_t i=0; i