From 2270a932ea2b1efa606fe12fef9eeaa4311e3f80 Mon Sep 17 00:00:00 2001 From: Kano Date: Thu, 26 Sep 2013 12:24:13 +1000 Subject: [PATCH] klondike correct cvtKlnToC() temperature calculation --- driver-klondike.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/driver-klondike.c b/driver-klondike.c index b9189c60..797ee377 100644 --- a/driver-klondike.c +++ b/driver-klondike.c @@ -118,7 +118,17 @@ IDENTITY KlondikeID; static double cvtKlnToC(uint8_t temp) { - return (double)1/((double)1/(25+273.15) + log((double)temp*1000/(256-temp)/2200)/3987) - 273.15; + double Rt, stein, celsius; + + Rt = 1000.0 * 255.0 / (double)temp - 1000.0; + + stein = log(Rt / 2200.0) / 3987.0; + + stein += 1.0 / (double)(25.0 + 273.15); + + celsius = (1.0 / stein) - 273.15; + + return celsius; } static int cvtCToKln(double deg)