18.09.2015, 06:40
Right now we don't have enough resources to implement this.
Here's a function for start/stop dimming:
Usage:
1. Add bindimmer function to Common functions
2. Create 3 objects:
1/1/1 - binary (dim up)
1/1/2 - binary (dim down)
1/1/3 - 1-byte scale (output)
3. Create an event script for each binary object:
4. You can tune step and delay variables in bindimmer function to adjust dimming speed
Here's a function for start/stop dimming:
Code:
function bindimmer(up, down, out, event)
local main, rev, step, val, new, delay
step = 10 -- in %
delay = 0.5 -- in seconds
-- ignore "stop" command
val = tonumber(event.datahex, 16)
if val == 0 then
return
end
-- up, normal mode
if event.dst == up then
main, rev = up, down
-- down, reverse step
elseif event.dst == down then
main, rev = down, up
step = -step
-- invalid object
else
return
end
-- current output object value
val = grp.getvalue(out) or 0
while true do
-- main object in "stop" state
if not grp.getvalue(main) then
return
end
-- reverse object in "start" state
if grp.getvalue(rev) then
return
end
-- get new value
new = math.min(100, val + step)
new = math.max(0, new)
-- no change, stop
if new == val then
return
end
-- write new value
val = new
grp.write(out, new, dt.scale)
-- wait for next run
os.sleep(delay)
end
end
Usage:
1. Add bindimmer function to Common functions
2. Create 3 objects:
1/1/1 - binary (dim up)
1/1/2 - binary (dim down)
1/1/3 - 1-byte scale (output)
3. Create an event script for each binary object:
Code:
bindimmer('1/1/1', '1/1/2', '1/1/3', event)
4. You can tune step and delay variables in bindimmer function to adjust dimming speed