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.

Convert 2 byte to bits
#3
(02.05.2024, 07:46)admin Wrote: See this: https://forum.logicmachine.net/showthread.php?tid=1081

Thanks admin. So far so good.. But now i like to make a text loop showing each error for 2 seconds.

Code:
value = event.getvalue()

errors = {
    [0] = 'Condensatiebeveiliging actief',
    [1] = 'Droogfase van het sensoroppervlak',
    [2] = 'Waarden van digitaal-analoogomzetter ongeldig',
    [3] = 'Meetwaarde van druksensor ongeldig',
    [4] = 'Meetwaarde van helderheidssensor noord ongeldig',
    [5] = 'Meetwaarde helderheidssensor oost ongeldig',
    [6] = 'Meetwaarde van helderheidssensor zuid ongeldig',
    [7] = 'Meetwaarde van helderheidssensor west ongeldig',
    [8] = 'Schemermeetwaarde ongeldig',
    [9] = 'Meetwaarde van globale stralingssensor ongeldig',
    [10] = 'Meetwaarde van luchttemperatuursensor ongeldig',
    [11] = 'Meetwaarde van neerslagsensor ongeldig',
    [12] = 'Meetwaarde van windsnelheidssensor ongeldig',
    [13] = 'Meetwaarde van windrichtingsensor ongeldig',
    [14] = 'Meetwaarde van de vochtmeting ongeldig',
    [15] = 'Interne systeemfout',
}

result = {}

for i = 0, 15 do
  mask = bit.lshift(1, i)
  if bit.band(mask, value) ~= 0 then
    if errors[ i ] then
      table.insert(result, errors[ i ])
    end
  end
end

text = table.concat(result, '\n')
grp.update('5/6/3', text)
Reply


Messages In This Thread
Convert 2 byte to bits - by Joep - 02.05.2024, 07:43
RE: Convert 2 byte to bits - by admin - 02.05.2024, 07:46
RE: Convert 2 byte to bits - by Joep - 02.05.2024, 08:39
RE: Convert 2 byte to bits - by admin - 02.05.2024, 11:50
RE: Convert 2 byte to bits - by Joep - 02.05.2024, 12:04

Forum Jump: