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.

dim up / down to percentage
#4
Use an event script with execution mode set to "Last instance only".
Code:
out = '32/0/25'

dimmer = event.getvalue()
step = bit.band(dimmer, 0x07)

if step == 0 then
  return
end

up = bit.band(dimmer, 0x08) ~= 0

vstep = up and 5 or -5
value = grp.getvalue(out)

while true do
  nvalue = value + vstep
  nvalue = math.min(nvalue, 100)
  nvalue = math.max(nvalue, 0)

  if nvalue ~= value then
    grp.write(out, nvalue)
    value = nvalue

    os.sleep(0.2)
  else
    break
  end
end

What do you mean by everything gets slow? The script sends 5 telegrams per second which is not a high load. You can lower this by increasing the sleep time. You might need to adjust the step size to keep the dimming speed the same as before.
Reply


Messages In This Thread
dim up / down to percentage - by KoBra - 15.10.2023, 18:45
RE: dim up / down to percentage - by KoBra - 15.10.2023, 20:16
RE: dim up / down to percentage - by admin - 16.10.2023, 05:52
RE: dim up / down to percentage - by KoBra - 16.10.2023, 09:31
RE: dim up / down to percentage - by admin - 16.10.2023, 09:36

Forum Jump: