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.

2 byte to 1 byte
#2
Hi,

That depends on what you want to do, what information do you need from the 2 byte value to the 1 byte value?

Could be something like this:
Code:
twobytevalue = event.getvalue()
onebytevalue = math.floor((twobytevalue / 256) + 0.5)
grp.write('1/1/2', onebytevalue)
Or:
Code:
twobytevalue = event.getvalue()
if twobytevalue < 255 then
  onebytevalue = math.floor(twobytevalue + 0.5) -- round airflow to integer
else
  onebytevalue = 255 -- if airflow is higher then 255 then max is reached
end
grp.write('1/1/2', onebytevalue)
BR,

Erwin
Reply


Messages In This Thread
2 byte to 1 byte - by Frankg - 18.10.2017, 06:55
RE: 2 byte to 1 byte - by Erwin van der Zwart - 18.10.2017, 07:54

Forum Jump: