RGB control from LogicMachine
Example: RGB control from LogicMachine
Task
How is it possible to control RGB LED strips from LogicMachine color palette? You have to create a script which will split 3byte object in 3 x 1byte objects which are then sent into KNX bus. Also there is another script to see the status ob the LEDs which is creating 3byte object from 3 x 1byte objects.
Add RGB object
In Objects menu add KNX object with Data type = RGB color:
Adjust Vis.parameters for this created object – choose necessary presets:
Once the object is added into visualization map, it looks like this:
Event-based program to split 3byte into 3x1byte
- ------------------- Configurable parameters ----------------------------------------------------------
- redGroup = '1/1/5' --- modify ether group address or name of group
- greenGroup = 'LED1 Green Value' --- modify ether group address or name of group
- blueGroup = '1/1/7' --- modify ether group address or name of group
- ----------------------------------------------------------------------------------------------------------------
- value = event.getvalue()
- Blue= bit.band(value, 0xFF)
- Green = bit.rshift(bit.band(value, 0xFF00), 8)
- Red = bit.rshift(bit.band(value, 0xFF0000), 16)
- grp.write(redGroup, Red)
- grp.write(greenGroup, Green)
- grp.write(blueGroup, Blue)
Event-based program to combine 3x1byte into 3byte object to see status
- ------------------- Configurable parameters ---------------------------
- redGroup = '1/1/1' --- either group address or name
- greenGroup = 'LED1 Green Status' --- either group address or name
- blueGroup = '1/1/3' --- either group address or name
- rgbGroup = 'RGB Value' --- either group address or name
- -----------------------------------------------------------------------
- red = grp.getvalue(redGroup)
- green = grp.getvalue(greenGroup)
- blue = grp.getvalue(blueGroup)
-
- rgb = bit.bor(bit.lshift(red, 16), bit.lshift(green, 8), blue)
- grp.update(rgbGroup, rgb)