Merge remote-tracking branch 'nodemcu/master'
This commit is contained in:
commit
e0120e9b45
|
@ -659,13 +659,19 @@ typedef struct LoadFSF {
|
||||||
static const char *getFSF (lua_State *L, void *ud, size_t *size) {
|
static const char *getFSF (lua_State *L, void *ud, size_t *size) {
|
||||||
LoadFSF *lf = (LoadFSF *)ud;
|
LoadFSF *lf = (LoadFSF *)ud;
|
||||||
(void)L;
|
(void)L;
|
||||||
|
|
||||||
|
if (L == NULL && size == NULL) // Direct mode check
|
||||||
|
return NULL;
|
||||||
|
|
||||||
if (lf->extraline) {
|
if (lf->extraline) {
|
||||||
lf->extraline = 0;
|
lf->extraline = 0;
|
||||||
*size = 1;
|
*size = 1;
|
||||||
return "\n";
|
return "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fs_eof(lf->f)) return NULL;
|
if (fs_eof(lf->f)) return NULL;
|
||||||
*size = fs_read(lf->f, lf->buff, sizeof(lf->buff));
|
*size = fs_read(lf->f, lf->buff, sizeof(lf->buff));
|
||||||
|
|
||||||
return (*size > 0) ? lf->buff : NULL;
|
return (*size > 0) ? lf->buff : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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)
|
||||||
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
|
||||||
|
|
Loading…
Reference in New Issue