This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Dali interface scenes
#1
How to use scenes with the dali interface?

Is there a kind of "software scene" object?
Reply
#2
You can create simple scenes by making a script that writes the required values one by one.
Reply
#3
(21.10.2015, 13:26)admin Wrote: You can create simple scenes by making a script that writes the required values one by one.


And saving a scene? Do you have a short example?
Reply
#4
Short example which can be used for any kind of scenes, not only for DALI.

First, you have to define each scene via a Lua table where each item is a table with two items: group address and value. Each scene has a unique id which can be a number or a string.

callscene(id) sets all objects in given scene to their specified value. First it looks for a saved scene in storage and uses default values if storage is empty.

savescene(id) gets current values of all objects from given scene and saves the whole scene in storage.

Code:
scenes = {}

scenes[1] = {
  { '15/1/1', 50 },
  { '15/1/2', 75 },
  { '15/1/3', 90 },
}

function callscene(id)
 local key, scene

 key = 'scene_' .. id
 scene = storage.get(key, scenes[ id ])
 
 if type(scene) ~= 'table' then
   alert('Scene ' .. id .. ' not found')
   return
 end

 for _, item in ipairs(scene) do
   grp.write(item[ 1 ], item[ 2 ])
 end
end

function savescene(id)
 local key, scene

 scene = scenes[ id ]
 if type(scene) ~= 'table' then
   alert('Scene ' .. id .. ' not found')
   return
 end

 for i, item in ipairs(scene) do
   scene[ i ][ 2 ] = grp.getvalue(item[ 1 ])
 end

 key = 'scene_' .. id
 storage.set(key, scene)
end
Reply
#5
many thanks
Reply


Forum Jump: