15.05.2018, 12:59 (This post was last modified: 15.05.2018, 13:25 by Jayce.)
Hello,
I have LED Dali strip, which I can set RGB values to. I wanted to use a mosaic widget to set color value but it only works with HEX code. I have three seperate group adresses (r, g, b) and I need to convert them to one HEX group address that I can link to that widget. Is this possible?
EDIT: First question has been solved, sorry I did some deeper research and found whole article.
A completely different question. Is is possible to DIM pre-mixed RGB color? Let's say I also have 3 group adresses, which I mixed and got my final color. I now want to dim it so it's the same color but less bright.
Thank you very much! Haven't tried that yet but if it works, is there a way to automatize it? I only need a single switch group that switches on already mixed and dimmed RGB strip.
(16.05.2018, 09:04)Jayce Wrote: Thank you very much! Haven't tried that yet but if it works, is there a way to automatize it? I only need a single switch group that switches on already mixed and dimmed RGB strip.
I forgot to mention that the second question was outside of mosaic. Let me explain myself better. Right now, I have created a group (let's call it RGB), where I put a simple script that sets three groups (red, green and blue) to certain value. That means when I set RGB group to 1, my exact color mixture turns on. The problem is it is too bright. I need to dim it. As you said, I might be able to dim it with RGBW widget, but that is widget. I'd need it to be outside of mosaic.
addressred = '1/1/16'addressgreen = '1/1/17'addressblue = '1/1/18'addresswhite = '1/1/19'addresssaturation = '1/1/20'-- Get Value of RGB pickervalue = event.getvalue()
-- Convert to HEX for splitting to 3 byte valuesvalue = lmcore.inttohex(value, 3) -- 3 = number of bytes inside value-- Split First 2 byte HEX values from 3 byte HEXredandgreen = string.sub(value, 1, 4)
-- Split First Value from 2 byte HEXred = string.sub(redandgreen, 1, 2)
-- Split Last value from 2 byte HEXgreen = string.sub(redandgreen, -2)
-- Split Last byte value from 3 byte HEXblue = string.sub(value, -2)
-- Convert HEX values back to integervaluered = lmcore.hextoint (red)
valuegreen = lmcore.hextoint (green)
valueblue = lmcore.hextoint (blue)
-- Calculate lowest value of RGB valuelow = math.min(unpack({valuered, valuegreen, valueblue}))
-- Calculate highest value of RGB valuehigh = math.max(unpack({valuered, valuegreen, valueblue}))
-- Calculate Saturation (The saturation is the colorfulness of a color relative to its own brightness) The difference between the last two variables divided by the highest is the saturation.saturation = math.floor((100 * ((high - low) / high)) + 0.5)
ifvaluered == 0andvaluegreen == 0andvalueblue == 0thenwhite = 0elsewhite = math.floor(((255 - saturation) / 255 * (valuered + valuegreen + valueblue) / 3)+ 0.5)
end-- Write integer RGB values and Calculated White & Saturation to KNXgrp.update(addressred, math.floor((valuered / 2.55) + 0.5))
grp.update(addressgreen, math.floor((valuegreen / 2.55) + 0.5))
grp.update(addressblue, math.floor((valueblue / 2.55) + 0.5))
grp.update(addresswhite, math.floor((white / 2.55) + 0.5))
grp.update(addresssaturation, saturation)