Commit 4bde88cd authored by Tobias Mädel's avatar Tobias Mädel
Browse files

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
parent 055c55a7
...@@ -105,11 +105,10 @@ function readNumber(addr, unit) ...@@ -105,11 +105,10 @@ function readNumber(addr, unit)
else else
return nil return nil
end end
t1 = t / 10000 t = t / 10000
t2 = t % 10000
-- print("Temperature="..t1.."."..t2.." Centigrade") -- print("Temperature="..t1.."."..t2.." Centigrade")
-- result = t1.."."..t2 -- result = t1.."."..t2
return t1, t2 return t
end end
tmr.wdclr() tmr.wdclr()
else else
...@@ -122,11 +121,11 @@ function readNumber(addr, unit) ...@@ -122,11 +121,11 @@ function readNumber(addr, unit)
end end
function read(addr, unit) function read(addr, unit)
t1, t2 = readNumber(addr, unit) t = readNumber(addr, unit)
if((t1 == nil ) or (t2 ==nil)) then if (t == nil) then
return nil return nil
else else
return t1.."."..string.format("%04u", t2) return t
end end
end end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment