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.

4-bit to 1-byte conversion script for DALI, DMX512 etc.
#1
Resident script (sleep interval = 0), which is doing conversion from 4-bit to 1-byte

4-bit dimmer object adress is 1/1/1
1-byte output object adress is 1/1/2

By default, script will change value by 10% every 0.2 seconds when any kind of up/down telegram is received.
 
Code:
dimmer = grp.getvalue('1/1/1')
step = bit.band(dimmer, 0x07)

if step ~= 0 then
 addr = '1/1/2'
  up = bit.band(dimmer, 0x08) ~= 0
  value = grp.getvalue(addr)

  if up then
    newvalue = value + 10
  else
    newvalue = value - 10
  end

  -- clamp between 0 and 100
  newvalue = math.min(newvalue, 100)
  newvalue = math.max(newvalue, 0)

  if newvalue ~= value then
    grp.write(addr, newvalue)
  end
end

os.sleep(0.2)
Reply


Messages In This Thread
4-bit to 1-byte conversion script for DALI, DMX512 etc. - by edgars - 02.07.2015, 08:32

Forum Jump: