mirror of
https://github.com/nodemcu/nodemcu-firmware.git
synced 2025-02-06 21:18:25 +08:00
Fix float version, auto-detect int/float, OO tmr (#1866)
This commit is contained in:
parent
46f651cccb
commit
925991715f
@ -25,7 +25,7 @@ return({
|
|||||||
if s.parasite == 1 then break end -- parasite sensor blocks bus during conversion
|
if s.parasite == 1 then break end -- parasite sensor blocks bus during conversion
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
tmr.alarm(tmr.create(), 750, tmr.ALARM_SINGLE, function() self:readout() end)
|
tmr.create():alarm(750, tmr.ALARM_SINGLE, function() self:readout() end)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
readTemp = function(self, cb, lpin)
|
readTemp = function(self, cb, lpin)
|
||||||
@ -83,6 +83,7 @@ return({
|
|||||||
t = t * 5000 -- DS18S20, 1 fractional bit
|
t = t * 5000 -- DS18S20, 1 fractional bit
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if 1/2 == 0 then
|
||||||
-- integer version
|
-- integer version
|
||||||
local sgn = t<0 and -1 or 1
|
local sgn = t<0 and -1 or 1
|
||||||
local tA = sgn*t
|
local tA = sgn*t
|
||||||
@ -95,13 +96,15 @@ return({
|
|||||||
s.status = 2
|
s.status = 2
|
||||||
end
|
end
|
||||||
-- end integer version
|
-- end integer version
|
||||||
-- -- float version
|
else
|
||||||
-- if t and (math.floor(t/10000)~=85) then
|
-- float version
|
||||||
-- self.temp[s.addr]=t
|
if t and (math.floor(t/10000)~=85) then
|
||||||
-- print(encoder.toHex(s.addr), t)
|
self.temp[s.addr]=t/10000
|
||||||
-- s.status = 2
|
print(encoder.toHex(s.addr), t)
|
||||||
-- end
|
s.status = 2
|
||||||
-- -- end float version
|
end
|
||||||
|
-- end float version
|
||||||
|
end
|
||||||
end
|
end
|
||||||
next = next or s.status == 0
|
next = next or s.status == 0
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user