Remembering favorite RGB lamp colors is a basic requirement for controlling colored lighting. To meet expectations, we have created a solution that allows you to save any number of DMX lighting scenes.
What will you learn in this tutorial?
After reading this tutorial, you will be able to create interfaces that allow you to save/call any number of DMX scenes, both from the Remote menu and the Display visualization. Scene saving will be implemented in the Logic tab. All necessary code is contained in the script dmxscene.lua , which is available in the resources component update in version 130311 for the Base module.
You can preview the script code by going to the Resources tab > Scripts and opening the file dmxscene.lua. If for some reason the script is missing in your module, you can add it manually by clicking the Add button and then selecting the file from your local drive.
The script is also attached to this tutorial.
1. Group and Scene Declaration #
To start creating lighting scenes, you first need to import the dmxscene.luascript into the Logic tab. To import scripts, use the command import ’<skrypt>’, in our caseimport ’dmxscene’.
To make scene management more intuitive, the script will automatically group them according to the name you provide. This way, you can create many scenes associated with, for example, a given room or a specific lighting source. You can add any number of scenes to a group. Creating a new group is very simple and is limited to adding a single line of code in the Logic tab according to the following scheme: <zmienna> = dmxscene(’<grupa>’,<slot1>,...,<slotn>), where <zmienna> is any variable name by which we refer to the group. In the further part of the tutorial, these variables will be called objects, and <grupa> is any group name. After the group name, enter the addresses of any number of DMX channels/slots to be assigned to the group.
Examples of group declarations:
salon = dmxscene(’salon’,2,3,4,5,6,7,8,9,10)
salonsufit = dmxscene(’sufit’,2,3,4)
The same DMX channels/slots can be present in several groups. By introducing them this way, it will be possible to save scenes for entire rooms as well as independent scenes for specific light sources.
The script allows saving many scenes relating to the same set of DMX channels (to the same group). The save function is used for this. As an argument to the save function, pass the name of the scene you want to save. The syntax is as follows: obiekt:save(’nazwa’), e.g. salon:save(’relaks’).
Such a function call will save the DMX channel values specified in the group declaration to the scene named ’relaks’, in the example above, these will be numbers from 2 to 10.
Scenes are saved in the non-volatile memory of the Base module (as MEM-type variables). Each time thesavefunction is called, the scene is overwritten with the current values of the DMX channels assigned to that scene. The values of all scenes can be previewed in the State tab. Each scene is a separate MEM variable named the same as the group and scene name. The value of a given MEM variable is the individual channel values expressed in hexadecimal code. The general form is: MEM.dmxs.<nazwa>.<scena>=<wartość>.
To recall scenes, use the restore function. Therestore function takes the name of the scene you want to recall as an argument. The syntax is as follows: obiekt:restore(’nazwa’), e.g. <salon:restore(’relaks’).
Having declared groups, you can now proceed to create the scene control interface.
Before moving on to the next step, remember to save the Logic tab.
2. Remote #
The interface in the Remote application will consist of at least two elements:
RGB Light – selection of color and brightness, and controls
Button – a button to save and recall the scene.
A short press will recall the scene, while a long press will save the current values of the DMX channels indicated in the group declaration. If several scenes are declared for a given set of DMX channels, add the appropriate number of Buttons.
The procedure below refers to the ‘salon’ group declaration shown in the previous section.
- Add a new RGB Light element, then double-click it and fill in its properties. In the following fields, enter the DMX channel numbers assigned to a given color, e.g.
DMX.2DMX.3,DMX.4. Our group includes channels 2 to 10, so repeat this step 3 times. - Add a Button, double-click it, and fill in its properties:
- In the Label cell, enter the button description. Select the Press tab. Click Add command and in the window that appears, in the Name field, enter:
C.LOGIC, and in the Value field:<nazwa>:restore(’<scena>’), in our casesalon:restore(’relaks’). Go to the Hold tab and repeat the previous step, changing the Value field to<nazwa>:save(’<scena>’), in our casesalon:save(’relaks’).
- In the Label cell, enter the button description. Select the Press tab. Click Add command and in the window that appears, in the Name field, enter:
An example interface is shown in the image below:

3. Visualization #
Calling up DMX scenes can be easily implemented in the visualization. The controls used here are the Button type. The definition of the control is limited only to assigning a command and optionally a label to the Buttons.
The command must have the following syntax: LOGIC=obiekt:restore(’scena’), in our case: LOGIC=salon:restore(’relaks’).
--
-- DMX Scenes
--
-- Copyright 2013 DOMIQ Sp. z o.o.
--
function dmxscene(group,…)
assert(group, "Group name required")
for ,v in ipairs(arg) do
assert(v >= 0 and v <= 255, "Invalid slot value "..v)
end
local t = {}
function t:save(name)
local val = {}
for ,v in ipairs(arg) do
table.insert(val,
string.format('%02x',
math.ceil((get('DMX.'..v))*2.55)))
end
set(string.format('MEM.dmxs.%s.%s',group,name),
table.concat(val))
end
function t:restore(name)
local val = get(string.format('MEM.dmxs.%s.%s',group,name))
assert(val,"Missing scene "..name)
local c = 0
for v in string.gmatch(val,"(%x%x)") do
c = c + 1
command('C.DMX.'..arg[c],
math.floor(tonumber(v,16)/2.55+0,5))
end
end
return t
end