Would someone check this script and let me know if it looks right. I am pulling two 1600psi brake pressure senders in via AnalogX and want to create a virtual channel (gauge) that shows the percentage of one against the total of the two (to show brake bias %). thanks, Dave
--Create Virtual Channels:
vfbrakeId = addChannel("vfbrake", 10, 0, 0, 1600, "psi")
vrbrakeId = addChannel("vrbrake", 10, 0, 0, 1600, "psi")
bbsId = addChannel("BrakeBias", 10, 0, 0, 100, "%")
function processCan()
id, ext, data = rxCAN(0)
if id == 935444 then
setChannel(vfbrakeId, data[7], 16, 40, -200)
setChannel(vrbrakeId, data[9], 16, 40, -200)
end
function setChannel()
local a1 = vfbrake()
local a2 = vrbrake()
setChannel(bbsId, (a2 / (a1 + a2)))
end
function onTick()
processCan()
setChannel()
end
end