![]() |
|
4 bit dimming script - Printable Version +- LogicMachine Forum (https://forum.logicmachine.net) +-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1) +--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8) +--- Thread: 4 bit dimming script (/showthread.php?tid=4474) |
4 bit dimming script - Rajesh - 03.01.2023 script for 4 bit dimming to send command to 1 Byte unsigned integer dimming RE: 4 bit dimming script - Daniel - 03.01.2023 Have a look here https://forum.logicmachine.net/showthread.php?tid=1334&pid=8027#pid8027 RE: 4 bit dimming script - admin - 03.01.2023 In 2022 RC1 firmware and later you can use an event script with execution mode set to "Last instance only". Change parameters on first three lines as needed. Code: out = '1/1/2' -- output group address (1 byte scale)
stepsize = 5 -- step size in %
sleeptime = 0.5 -- delay in seconds between each step
dimmer = event.getvalue()
step = bit.band(dimmer, 0x07)
if step == 0 then
return
end
if bit.band(dimmer, 0x08) == 0 then
stepsize = -stepsize
end
value = grp.getvalue(out)
while true do
newvalue = math.min(value + stepsize, 100)
newvalue = math.max(newvalue, 0)
if newvalue == value then
break
end
value = newvalue
grp.write(out, value)
os.sleep(sleeptime)
end |