![]() |
|
Color spectrum dimming - 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: Color spectrum dimming (/showthread.php?tid=1408) |
Color spectrum dimming - Jayce - 23.05.2018 Hello everybody! I was wondering if it is possible to make this kind of "effect" with a simple RGB strip. When holding a simple push button set to dimming, colors of the strip would go across the spectrum of all colors (with speed / step size as I choose), when released it would stay at that color. Second button would do the same but backwards. Not sure if this would be any effective but it's the only way I thought of to make this using a physical push button. I have 3 unsigned integer group adresses (R,G,B). I tried to do it with this script I lightly modified but it doesn't work well. The script is in two event scripts, both 3 byte dimming from a pushbutton, one is set to brighter (ON) and the second one to darker (OFF). Code: step = 1
stepTime = 0.001
ballastAddress1 = 19 --RED
ballastAddress2 = 27 --GREEN
ballastAddress3 = 28 --BLUE
gatewayID='internal'
-----------------------------------------------------------------------------------------------------
valuein = event.getvalue()
require('user.dali')
res, err = dalicmd(gatewayID, 'queryactual', { addrtype = 'short', address = ballastAddress1 })
res, err = dalicmd(gatewayID, 'queryactual', { addrtype = 'short', address = ballastAddress2 })
res, err = dalicmd(gatewayID, 'queryactual', { addrtype = 'short', address = ballastAddress3 })
-- read ok
if res then
status = res:byte()
end
while( valuein==9 ) do
status = status + step
if (status >254) then
dalicmd(gatewayID, 'arc', { addrtype = 'short', address = ballastAddress1, value = 254})
dalicmd(gatewayID, 'arc', { addrtype = 'short', address = ballastAddress2, value = 254})
dalicmd(gatewayID, 'arc', { addrtype = 'short', address = ballastAddress3, value = 254})
else
dalicmd(gatewayID, 'arc', { addrtype = 'short', address = ballastAddress1, value = status})
dalicmd(gatewayID, 'arc', { addrtype = 'short', address = ballastAddress2, value = status})
dalicmd(gatewayID, 'arc', { addrtype = 'short', address = ballastAddress3, value = status})
end
valuein = grp.getvalue(event.dst)
os.sleep(stepTime)
end
while( valuein==1 ) do
status = status - step
if (status <0) then
dalicmd(gatewayID, 'arc', { addrtype = 'short', address = ballastAddress1, value = 0})
dalicmd(gatewayID, 'arc', { addrtype = 'short', address = ballastAddress2, value = 0})
dalicmd(gatewayID, 'arc', { addrtype = 'short', address = ballastAddress3, value = 0})
else
dalicmd(gatewayID, 'arc', { addrtype = 'short', address = ballastAddress1, value = status})
dalicmd(gatewayID, 'arc', { addrtype = 'short', address = ballastAddress2, value = status})
dalicmd(gatewayID, 'arc', { addrtype = 'short', address = ballastAddress3, value = status})
end
valuein = grp.getvalue(event.dst)
os.sleep(stepTime)
endRE: Color spectrum dimming - Daniel - 23.05.2018 Hi I would do it in resident script which would be enabled/disabled by your object. This script might help you https://forum.logicmachine.net/showthread.php?tid=157 BR |