sensors: Update single axis temp comp method to 5th order

This allows future use with baro sensors that require a higher fit order
This commit is contained in:
Paul Riseborough
2017-01-02 15:22:58 +01:00
committed by Lorenz Meier
parent 6a78df7fa0
commit c2fc283fdb
2 changed files with 60 additions and 28 deletions
@@ -181,7 +181,7 @@ int update_parameters(const ParameterHandles &parameter_handles, Parameters &par
return ret;
}
bool correct_data_1D(struct SENSOR_CAL_DATA_1D &coef, const float &measured_temp, float &offset)
bool calc_thermal_offsets_1D(struct SENSOR_CAL_DATA_1D &coef, const float &measured_temp, float &offset)
{
bool ret = true;
@@ -204,8 +204,15 @@ bool correct_data_1D(struct SENSOR_CAL_DATA_1D &coef, const float &measured_temp
delta_temp -= coef.ref_temp;
// calulate the offset
offset = coef.x0 + coef.x1 * delta_temp + coef.x2 * delta_temp * delta_temp + coef.x3 * delta_temp * delta_temp *
delta_temp;
offset = coef.x0 + coef.x1 * delta_temp;
delta_temp *= delta_temp;
offset += coef.x2 * delta_temp;
delta_temp *= delta_temp;
offset += coef.x3 * delta_temp;
delta_temp *= delta_temp;
offset += coef.x4 * delta_temp;
delta_temp *= delta_temp;
offset += coef.x5 * delta_temp;
return ret;