-- DMX init, returns new DMX object
-- create metatable and set user parameters
n = setmetatable({}, { __index = DMX })
_, n.conn = pcall(require('redis').connect)
-- merge parameters that are set by user
for k, v in pairs(defaults) do
if n.params[ k ] == nil then
self.dm, err = luadmx.open(params.port)
self.dm:setcount(params.channels)
-- number of transaction ticks
self.ticks = math.max(1, params.transition * params.resolution)
self.sleep = 1 / params.resolution
-- empty channel value map
self.conn:ltrim(params.skey, 1, 0)
for chan = 1, params.channels do
self.channels[ chan ] = { current = 0, target = 0, ticks = 0 }
self.conn:lpush(params.skey, 0)
self.dm:setchannel(chan, 0)
local max, channels, ticks, values, val