From fa6bf2a91ffa2d1959cfa8b1b9e3fc1246c1ae33 Mon Sep 17 00:00:00 2001 From: bezineb5 Date: Sun, 21 Mar 2021 08:50:01 -0400 Subject: [PATCH] [TLV493D] Method to calibrate temperature offset (#10) --- tlv493d/tlv493d.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tlv493d/tlv493d.go b/tlv493d/tlv493d.go index 775304e..a9d755b 100644 --- a/tlv493d/tlv493d.go +++ b/tlv493d/tlv493d.go @@ -426,15 +426,14 @@ func (d *Dev) StopContinousRead() { } // CalibrateTemperatureOffsetCompensation computes the temperature offset compensation based upon a reading from the sensor compared to the actual temperature. +// // The returned value must be stored and passed in Opts.TemperatureOffsetCompensation in future uses of TLV493D driver. -// See TLV493D user manual, "3.2 Calculation of the temperature" for more information +// See TLV493D user manual, "3.2 Calculation of the temperature" for more information. func CalibrateTemperatureOffsetCompensation(temperatureOffsetCompensation int, measuredTemperature physic.Temperature, actualTemperature physic.Temperature) int { // Compute measurement based upon reference documentation rawTemp := int((measuredTemperature-referenceTemperature)/temperatureScaling) + temperatureOffsetCompensation // Compute the new offset by matching the raw measurement between the measure and the actual value - newOffset := rawTemp - int((actualTemperature-referenceTemperature)/temperatureScaling) - - return newOffset + return rawTemp - int((actualTemperature-referenceTemperature)/temperatureScaling) } func bestModeForFrequency(frequency physic.Frequency) (Mode, error) {