Im going insane. Help required geeting 2 scripts to work
Posted: Tue Sep 26, 2017 11:40 am
Hi All.
I have a script running currently that is very simple and turns my fans on and off sepeding on coolant temp.
What I want to do is run this script and Another which just filters my fuel level reading.
My problem is that when I try to run both scripts my fans stop working. its like the script is being ignored.
Here is the fan script and below that is what I was trying to run to allow both functions to work at the same time
function onTick()
if getAnalog(1) > 90
then
setGpio(0, 1)
else
setGpio(0, 0)
end
end
AND
function getCoolantTemp()
if getAnalog(1) > 90
then
setGpio(0, 1)
else
setGpio(0, 0)
end
end
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
setChannel(fuel2Id, sum / maxAvg)
end
setTickRate(30)
function onTick()
getcoolantTemp()
updateFuelAvg(getAnalog(0))
end
Any help would be greatly appreciated
I have a script running currently that is very simple and turns my fans on and off sepeding on coolant temp.
What I want to do is run this script and Another which just filters my fuel level reading.
My problem is that when I try to run both scripts my fans stop working. its like the script is being ignored.
Here is the fan script and below that is what I was trying to run to allow both functions to work at the same time
function onTick()
if getAnalog(1) > 90
then
setGpio(0, 1)
else
setGpio(0, 0)
end
end
AND
function getCoolantTemp()
if getAnalog(1) > 90
then
setGpio(0, 1)
else
setGpio(0, 0)
end
end
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
setChannel(fuel2Id, sum / maxAvg)
end
setTickRate(30)
function onTick()
getcoolantTemp()
updateFuelAvg(getAnalog(0))
end
Any help would be greatly appreciated