Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
92599171
Commit
92599171
authored
Mar 16, 2017
by
Arnim Läuger
Committed by
Marcel Stör
Mar 16, 2017
Browse files
Fix float version, auto-detect int/float, OO tmr (#1866)
parent
46f651cc
Changes
1
Hide whitespace changes
Inline
Side-by-side
lua_modules/ds18b20/ds18b20.lua
View file @
92599171
...
@@ -25,7 +25,7 @@ return({
...
@@ -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,25 +83,28 @@ return({
...
@@ -83,25 +83,28 @@ return({
t
=
t
*
5000
-- DS18S20, 1 fractional bit
t
=
t
*
5000
-- DS18S20, 1 fractional bit
end
end
-- integer version
if
1
/
2
==
0
then
local
sgn
=
t
<
0
and
-
1
or
1
-- integer version
local
tA
=
sgn
*
t
local
sgn
=
t
<
0
and
-
1
or
1
local
tH
=
tA
/
10000
local
tA
=
sgn
*
t
local
tL
=
(
tA
%
10000
)
/
1000
+
((
tA
%
1000
)
/
100
>=
5
and
1
or
0
)
local
tH
=
tA
/
10000
local
tL
=
(
tA
%
10000
)
/
1000
+
((
tA
%
1000
)
/
100
>=
5
and
1
or
0
)
if
tH
and
(
tH
~=
85
)
then
if
tH
and
(
tH
~=
85
)
then
self
.
temp
[
s
.
addr
]
=
(
sgn
<
0
and
"-"
or
""
)
..
tH
..
"."
..
tL
self
.
temp
[
s
.
addr
]
=
(
sgn
<
0
and
"-"
or
""
)
..
tH
..
"."
..
tL
print
(
encoder
.
toHex
(
s
.
addr
),(
sgn
<
0
and
"-"
or
""
)
..
tH
..
"."
..
tL
)
print
(
encoder
.
toHex
(
s
.
addr
),(
sgn
<
0
and
"-"
or
""
)
..
tH
..
"."
..
tL
)
s
.
status
=
2
s
.
status
=
2
end
-- end integer version
else
-- float version
if
t
and
(
math.floor
(
t
/
10000
)
~=
85
)
then
self
.
temp
[
s
.
addr
]
=
t
/
10000
print
(
encoder
.
toHex
(
s
.
addr
),
t
)
s
.
status
=
2
end
-- end float version
end
end
-- end integer version
-- -- float version
-- if t and (math.floor(t/10000)~=85) then
-- self.temp[s.addr]=t
-- print(encoder.toHex(s.addr), t)
-- s.status = 2
-- end
-- -- end float version
end
end
next
=
next
or
s
.
status
==
0
next
=
next
or
s
.
status
==
0
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment