switch require() to dofile() to ease memory cleanup

This commit is contained in:
Vladimir Dronnikov 2015-02-06 22:22:09 +03:00
parent 7f970df70b
commit 165e91e60d
4 changed files with 14 additions and 21 deletions

View File

@ -5,7 +5,7 @@
-- Vladimir Dronnikov <dronnikov@gmail.com> -- Vladimir Dronnikov <dronnikov@gmail.com>
-- --
-- Example: -- Example:
-- require("irsend").nec(4, 0x00ff00ff) -- dofile("irsend.lua").nec(4, 0x00ff00ff)
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
local M local M
do do

View File

@ -6,7 +6,7 @@
-- Heavily based on work of Christee <Christee@nodemcu.com> -- Heavily based on work of Christee <Christee@nodemcu.com>
-- --
-- Example: -- Example:
-- require("bmp085").read(sda, scl) -- dofile("bmp085.lua").read(sda, scl)
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
local M local M
do do
@ -59,20 +59,13 @@ do
MD = r16(0xBE) MD = r16(0xBE)
end end
-- get raw P -- get raw P
local p
-- NB: optimize for oss = 0
if not oss then oss = 0 end if not oss then oss = 0 end
if oss == 0 then if oss <= 0 then oss = 0 end
oss = 0 if oss > 3 then oss = 3 end
w8(0xF4, 0x34)
tmr.delay(5000)
p = r8(0xF6) * 256 + r8(0xF7)
else
w8(0xF4, 0x34 + 64 * oss) w8(0xF4, 0x34 + 64 * oss)
tmr.delay(30000) tmr.delay((4 + 3 ^ oss) * 1000)
p = r8(0xF6) * 65536 + r8(0xF7) * 256 + r8(0xF8) local p = r8(0xF6) * 65536 + r8(0xF7) * 256 + r8(0xF8)
p = p / 2 ^ (8 - oss) p = p / 2 ^ (8 - oss)
end
-- get T -- get T
w8(0xF4, 0x2E) w8(0xF4, 0x2E)
tmr.delay(5000) tmr.delay(5000)

View File

@ -5,8 +5,8 @@
-- Vladimir Dronnikov <dronnikov@gmail.com> -- Vladimir Dronnikov <dronnikov@gmail.com>
-- --
-- Example: -- Example:
-- print("DHT11", require("dht22").read(4)) -- print("DHT11", dofile("dht22.lua").read(4))
-- print("DHT22", require("dht22").read(4, true)) -- print("DHT22", dofile("dht22.lua").read(4, true))
-- NB: the very first read sometimes fails -- NB: the very first read sometimes fails
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
local M local M

View File

@ -5,7 +5,7 @@
-- Vladimir Dronnikov <dronnikov@gmail.com> -- Vladimir Dronnikov <dronnikov@gmail.com>
-- --
-- Example: -- Example:
-- require("ds18b20").read(4, function(r) for k, v in pairs(r) do print(k, v) end end) -- dofile("ds18b20.lua").read(4, function(r) for k, v in pairs(r) do print(k, v) end end)
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
local M local M
do do