Why is the data bitwise AND in the examples below (bit.band):
Code: Select all
function processWheel(id, data, offset)
--wheel speed is 13 bits long, little endian
--low byte high byte
--76543210 76543210
--11111111 11111XXX
local highByte = bit.band(data[offset + 2], 0x1F)
local lowByte = data[offset + 1]
local value = highByte * 256 + lowByte
value = value * 0.0625
--convert to MPH. comment to keep KPH
value = value * 0.621371
setChannel(id, value)
end
Code: Select all
function fuelFilter(value)
--adjust for 7 bit value
value = bit.band(value, 0x7F)
--convert liters to %. tank holds 62.83 liters
return value / 0.6283
end
Thanks!
Jeff