From 4bde88cd8146f0df3f4c9880e5265dab5702cfa4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20M=C3=A4del?= Date: Sun, 1 Feb 2015 18:20:45 +0100 Subject: [PATCH] Fixed DS18B20 handling because of new floating point handling Hi, because of the new floating point API, the old ds18b20 code returns strange values like "19.8250.8250". This change fixes that. Best regards, Tobias --- lua_modules/ds18b20/ds18b20.lua | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lua_modules/ds18b20/ds18b20.lua b/lua_modules/ds18b20/ds18b20.lua index dba2ee46..c31addcf 100644 --- a/lua_modules/ds18b20/ds18b20.lua +++ b/lua_modules/ds18b20/ds18b20.lua @@ -105,11 +105,10 @@ function readNumber(addr, unit) else return nil end - t1 = t / 10000 - t2 = t % 10000 + t = t / 10000 -- print("Temperature="..t1.."."..t2.." Centigrade") -- result = t1.."."..t2 - return t1, t2 + return t end tmr.wdclr() else @@ -122,11 +121,11 @@ function readNumber(addr, unit) end function read(addr, unit) - t1, t2 = readNumber(addr, unit) - if((t1 == nil ) or (t2 ==nil)) then + t = readNumber(addr, unit) + if (t == nil) then return nil else - return t1.."."..string.format("%04u", t2) + return t end end