EasyManua.ls Logo

Embedded Systems LM5p-GSMC - DMX Interconnection with Lm

Default Icon
291 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
236
16. DMX interconnection with LM
DMX protocol support is realized upon RS485 serial port.
DMX function
Add the following user library in Scripting
User libraries.
local luadmx =
require('luadmx')
module('DMX', package.seeall)
local DMX = {}
-- default params
local defaults = {
-- storage key
skey = 'dmx_line_1',
-- RS-485 port
port = '/dev/RS485',
-- number of calls per second
resolution = 20,
-- total number of channels to use
channels = 3,
-- transition time in seconds, does not include DMX transfer time
transition = 2,
}
-- value setter
function set(chan, val, key)
key = key or defaults.skey
chan = tonumber(chan) or 0
val = tonumber(val) or -1
-- validate channel number and value
if chan >= 1 and chan <= 512 and val >= 0 and val <= 255 then
storage.exec('lset', key, chan - 1, val)
end
end
-- value getter
function get(chan, key)
local res, val
key = key or defaults.skey
chan = tonumber(chan) or 0
-- validate channel number and value
if chan >= 1 and chan <= 512 then
res = storage.exec('lrange', key, chan - 1, chan - 1)
if type(res) == 'table' then
val = tonumber(res[ 1 ])
end
end

Table of Contents

Related product manuals