ENP-DI7
di7
library implements interface for work with the ENP-DI7 module.
This is device with 7 digital and counters inputs.
di7.is_closed
-- @param id number id of digital input
-- @return boolean|nil, number
function di7.is_closed(id)
end
Returns status on digital input.
Returns 0 as last return value on success.
Example
status, result = di7.is_closed(3)
if status == nil then
enapter.log("Reading input 3 status failed: "..result.." "..di7.err_to_str(result), "error", true)
elseif status then
enapter.log("Input 3 is closed")
else
enapter.log("Input 3 is opened")
end
di7.is_opened
-- @param id number id of digital input
-- @return boolean|nil, number
function di7.is_opened(id)
end
Returns status on digital input.
Returns 0 as last return value on success.
Example
status, result = di7.is_opened(2)
if status == nil then
enapter.log("Reading input 2 status failed: "..result.." "..di7.err_to_str(result), "error", true)
elseif status then
enapter.log("Input 2 is opened")
else
enapter.log("Input 2 is closed")
end
di7.read_counter
-- @param id number id of digital input
-- @return number|nil, number|nil, number
function di7.read_counter(id)
end
Returns counter and time in seconds since last reset of digital input.
Returns 0 as last return value on success.
Example
counter, reset_time, result = di7.read_counter(7)
if result and result ~= 0 then
enapter.log("Reading counter for input 7 failed: "..result.." "..di7.err_to_str(result), "error", true)
else
enapter.log("Counter for input 7: "..counter.."\n Reset time for input 7: "..reset_time)
end
di7.set_counter
-- @param id number id of digital input
-- @param count number counter value of digital input
-- @return number
function di7.set_counter(id, count)
end
Set counter on digital input.
Returns 0 on success.
Example
result = di7.set_counter(5, 12)
if result and result ~= 0 then
enapter.log("Set counter for input 5 failed: "..result.." "..di7.err_to_str(result), "error", true)
end
di7.set_debounce
-- @param time number units is 100us (10 stands for 1000us)
-- @return number
function di7.set_debounce(time)
end
Set anti-bounce delay
Default time is 100us
Returns 0 on success.
Example
result = di7.set_debounce(2)
if result and result ~= 0 then
enapter.log("Set debounce failed: "..result.." "..di7.err_to_str(result), "error", true)
end
di7.err_to_str
-- @param error number
-- @return string
function di7.err_to_str(error)
end
Returns string representation of error code