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.

RGB 3 x 1 byte absolute % dimming from KNX
#13
(23.05.2022, 09:51)admin Wrote: Add to common functions:
Code:
function rgbdim(config)
  local red = grp.getvalue(config.in_red)
  local green = grp.getvalue(config.in_green)
  local blue = grp.getvalue(config.in_blue)
  local level = grp.getvalue(config.in_level)

  local max = math.max(1, red, green, blue)
  local mult = level / max

  red = math.round(red * mult)
  green = math.round(green * mult)
  blue = math.round(blue * mult)
    
  grp.write(config.out_red, red, dt.scale)
  grp.write(config.out_green, green, dt.scale)
  grp.write(config.out_blue, blue, dt.scale)
end

Add a common tag to 4 input objects (red, green, blue, level) and attach event script to this tag. Change group addresses as needed. Make sure that output objects are not tagged with the same tag or you will get an infinite loop. All objects should have 1 byte scaled data type.
Code:
rgbdim({
  in_red = '32/1/12',
  in_green = '32/1/13',
  in_blue = '32/1/14',
  in_level = '32/1/15',
  out_red = '32/1/16',
  out_green = '32/1/17',
  out_blue = '32/1/18',
})

Incredible! Thank you so much!  Heart
Reply


Messages In This Thread
RE: RGB 3 x 1 byte absolute % dimming from KNX - by alexll - 23.05.2022, 10:06

Forum Jump: