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.

Emergency Light, decoding of status
#5
(21.09.2018, 10:04)admin Wrote: Use this event script to get specific bits from an integer value. Make sure to create bit objects manually before running it.
Code:
function getbit(value, nr)
 value = bit.rshift(value, nr)
 return bit.band(value, 1) == 1
end

value = event.getvalue()

grp.checkupdate('1/1/1', getbit(value, 0))
grp.checkupdate('1/1/2', getbit(value, 1))
grp.checkupdate('1/1/3', getbit(value, 2))
grp.checkupdate('1/1/4', getbit(value, 3))
grp.checkupdate('1/1/5', getbit(value, 4))
grp.checkupdate('1/1/6', getbit(value, 5))

Thank you for your quick reply. What about decoding 2 or 3 byte objects?  Huh
Reply


Messages In This Thread
RE: Emergency Light, decoding of status - by manos@dynamitec - 21.09.2018, 10:26

Forum Jump: