Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
9818c506
Commit
9818c506
authored
Mar 15, 2015
by
funshine
Browse files
Merge branch 'master' into dev
parents
0b95ae08
6c8cace9
Changes
1
Hide whitespace changes
Inline
Side-by-side
lua_modules/ds18b20/ds18b20.lua
View file @
9818c506
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
-- NODEMCU TEAM
-- NODEMCU TEAM
-- LICENCE: http://opensource.org/licenses/MIT
-- LICENCE: http://opensource.org/licenses/MIT
-- Vowstar <vowstar@nodemcu.com>
-- Vowstar <vowstar@nodemcu.com>
-- 2015/02/14 sza2 <sza2trash@gmail.com> Fix for negative values
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- Set module name as parameter of require
-- Set module name as parameter of require
...
@@ -96,12 +97,16 @@ function readNumber(addr, unit)
...
@@ -96,12 +97,16 @@ function readNumber(addr, unit)
crc
=
ow
.
crc8
(
string.sub
(
data
,
1
,
8
))
crc
=
ow
.
crc8
(
string.sub
(
data
,
1
,
8
))
-- print("CRC="..crc)
-- print("CRC="..crc)
if
(
crc
==
data
:
byte
(
9
))
then
if
(
crc
==
data
:
byte
(
9
))
then
t
=
(
data
:
byte
(
1
)
+
data
:
byte
(
2
)
*
256
)
if
(
t
>
32767
)
then
t
=
t
-
65536
end
if
(
unit
==
nil
or
unit
==
C
)
then
if
(
unit
==
nil
or
unit
==
C
)
then
t
=
(
data
:
byte
(
1
)
+
data
:
byte
(
2
)
*
256
)
*
625
t
=
t
*
625
elseif
(
unit
==
F
)
then
elseif
(
unit
==
F
)
then
t
=
(
data
:
byte
(
1
)
+
data
:
byte
(
2
)
*
256
)
*
1125
+
320000
t
=
t
*
1125
+
320000
elseif
(
unit
==
K
)
then
elseif
(
unit
==
K
)
then
t
=
(
data
:
byte
(
1
)
+
data
:
byte
(
2
)
*
256
)
*
625
+
2731500
t
=
t
*
625
+
2731500
else
else
return
nil
return
nil
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