function checkAutoLogging()

if getGpsSpeed() > 10 then

startLogging()

else

stopLogging()

end

end

--The real analog channel should be named

--something other than FuelLevel

fuel2Id = addChannel("FuelLevel", 10, 0, 0,100,"%")

--change this to make a bigger averaging window

maxAvg = 300

--300 = 10 seconds averaging at 30Hz tick rate

--do not change

fuelAvg={}

fuel2Index = 1

function updateFuelAvg(value)

local i

if #fuelAvg == 0 then

--initialize averaging table

for i = 1, maxAvg do fuelAvg

*=0 end*

end

fuelAvg[fuel2Index] = value

fuel2Index = fuel2Index + 1

if fuel2Index > maxAvg then fuel2Index = 1 end

local sum = 0

for i = 1, #fuelAvg do

sum = sum + fuelAvg

end

fuelAvg[fuel2Index] = value

fuel2Index = fuel2Index + 1

if fuel2Index > maxAvg then fuel2Index = 1 end

local sum = 0

for i = 1, #fuelAvg do

sum = sum + fuelAvg

end

setChannel(fuel2Id, sum / maxAvg)

end

end

function accusump()

rpmThreshold = 2500

lowOilPressure = 40

local accusump = 0

if getTimerRpm(0) > rpmThreshold and getAnalog(6) < lowOilPressure then

accusump = 1

end

setGpio(1, accusump)

end

end

function warningLight()

if getAnalog(4) > 215 or getAnalog(6) < 40 or getAnalog(8) < 13 or getAnalog(5) > 275 then

setGpio(0, 1)

else

setGpio(0, 0)

end

end

setTickRate(30)

function onTick()

checkAutoLogging()

updateFuelAvg(getAnalog(3))

accusump()

warningLight()

endend

setChannel(fuel2Id, sum / maxAvg)

end

end

function accusump()

rpmThreshold = 2500

lowOilPressure = 40

local accusump = 0

if getTimerRpm(0) > rpmThreshold and getAnalog(6) < lowOilPressure then

accusump = 1

end

setGpio(1, accusump)

end

end

function warningLight()

if getAnalog(4) > 215 or getAnalog(6) < 40 or getAnalog(8) < 13 or getAnalog(5) > 275 then

setGpio(0, 1)

else

setGpio(0, 0)

end

end

setTickRate(30)

function onTick()

checkAutoLogging()

updateFuelAvg(getAnalog(3))

accusump()

warningLight()

end