@@ -1848,14 +1848,18 @@ void AP_InertialSensor::_save_gyro_calibration()
18481848 _gyro_offset (i).save ();
18491849 _gyro_id (i).save ();
18501850#if HAL_INS_TEMPERATURE_CAL_ENABLE
1851- caltemp_gyro (i).save ();
1851+ if (_backends[i]->externally_temperature_calibrated == true ) {
1852+ caltemp_gyro (i).save ();
1853+ }
18521854#endif
18531855 }
18541856 for (uint8_t i=_gyro_count; i<INS_MAX_INSTANCES; i++) {
18551857 _gyro_offset (i).set_and_save (Vector3f ());
18561858 _gyro_id (i).set_and_save (0 );
18571859#if HAL_INS_TEMPERATURE_CAL_ENABLE
1858- caltemp_gyro (i).set_and_save_ifchanged (-300 );
1860+ if (_backends[i]->externally_temperature_calibrated == true ) {
1861+ caltemp_gyro (i).set_and_save_ifchanged (-300 );
1862+ }
18591863#endif
18601864 }
18611865}
@@ -2298,6 +2302,9 @@ bool AP_InertialSensor::temperature_cal_running() const
22982302#if HAL_INS_TEMPERATURE_CAL_ENABLE
22992303 for (uint8_t i=0 ; i<INS_MAX_INSTANCES; i++) {
23002304 if (tcal (i).enable == AP_InertialSensor_TCal::Enable::LearnCalibration) {
2305+ if (_backends[i]->externally_temperature_calibrated == true ) {
2306+ return false ;
2307+ }
23012308 return true ;
23022309 }
23032310 }
@@ -2394,13 +2401,17 @@ void AP_InertialSensor::_acal_save_calibrations()
23942401 _accel_id (i).save ();
23952402 _accel_id_ok[i] = true ;
23962403#if HAL_INS_TEMPERATURE_CAL_ENABLE
2397- caltemp_accel (i).set_and_save (get_temperature (i));
2404+ if (_backends[i]->externally_temperature_calibrated == true ) {
2405+ caltemp_accel (i).set_and_save (get_temperature (i));
2406+ }
23982407#endif
23992408 } else {
24002409 _accel_offset (i).set_and_save (Vector3f ());
24012410 _accel_scale (i).set_and_save (Vector3f ());
24022411#if HAL_INS_TEMPERATURE_CAL_ENABLE
2403- caltemp_accel (i).set_and_save (-300 );
2412+ if (_backends[i]->externally_temperature_calibrated == true ) {
2413+ caltemp_accel (i).set_and_save (-300 );
2414+ }
24042415#endif
24052416 }
24062417 }
@@ -2411,7 +2422,9 @@ void AP_InertialSensor::_acal_save_calibrations()
24112422 _accel_offset (i).set_and_save (Vector3f ());
24122423 _accel_scale (i).set_and_save (Vector3f ());
24132424#if HAL_INS_TEMPERATURE_CAL_ENABLE
2414- caltemp_accel (i).set_and_save_ifchanged (-300 );
2425+ if (_backends[i]->externally_temperature_calibrated == true ) {
2426+ caltemp_accel (i).set_and_save_ifchanged (-300 );
2427+ }
24152428#endif
24162429 }
24172430
@@ -2664,7 +2677,9 @@ MAV_RESULT AP_InertialSensor::simple_accel_cal()
26642677 _accel_id (k).save ();
26652678 _accel_id_ok[k] = true ;
26662679#if HAL_INS_TEMPERATURE_CAL_ENABLE
2667- caltemp_accel (k).set_and_save (get_temperature (k));
2680+ if (_backends[k]->externally_temperature_calibrated == true ) {
2681+ caltemp_accel (k).set_and_save (get_temperature (k));
2682+ }
26682683#endif
26692684 }
26702685 for (uint8_t k=num_accels; k<INS_MAX_INSTANCES; k++) {
@@ -2795,8 +2810,12 @@ void AP_InertialSensor::send_uart_data(void)
27952810#if AP_EXTERNAL_AHRS_ENABLED
27962811void AP_InertialSensor::handle_external (const AP_ExternalAHRS::ins_data_message_t &pkt)
27972812{
2813+ TempCalibration = pkt.TempCalibration ;
27982814 for (uint8_t i = 0 ; i < _backend_count; i++) {
27992815 _backends[i]->handle_external (pkt);
2816+ if (TempCalibration == AP_ExternalAHRS::TempCal::IsTempCalibrated){
2817+ _backends[i]->externally_temperature_calibrated = true ;
2818+ }
28002819 }
28012820}
28022821#endif // AP_EXTERNAL_AHRS_ENABLED
0 commit comments