It's like the Lua script doesn't like that first line.[lua] Startup script error: ([string "batt_u_warn = 11..."]:19.0: 'then' expected near '=')
[lua] Failure: Failed to load script
I also don't see any missing "then" statements.
So I'm a bit puzzled why this doesn't work.
Code: Select all
batt_u_warn = 11
tmot_warn = 112
tmot_low = 60
toil_warn = 250
toil_low = 60
setTickRate(10) --TickRate is in Hz
-- Set ShiftX2 configuration parameters with default parameters
-- orientation: 0=normal, 1=inverted (display above LED bar)
-- brightness: 0-100%, 0 = auto brightness
-- can bus: 0=CAN1, 1=CAN2
sxSetConfig(0,0,1)
--warning errors--
if getChannel("tmot") < tmot_low or getChannel("toil") < toil_low
then WarnLvl = 1
elseif getChannel("batt_u") < batt_u_warn or getChannel("tmot") > tmot_warn or getChannel("toil") > toil_warn
then WarnLvl = 2
elseif oilamp_b = 1
then WarnLvl = 4
else WarnLvl = 0
end
--config shift light
sxCfgLinearGraph(0,0,0,7500) --left to right graph, smooth style, 0 - 7500 RPM range
sxSetLinearThresh(0,0,5800,0,255,0,0) --green at 5800 RPM
sxSetLinearThresh(1,0,6500,255,255,0,0) --yellow at 6500 RPM
sxSetLinearThresh(2,0,7000,255,0,0,0) --red+flash at 7000 RPM
sxSetLinearThresh(3,0,7200,255,0,0,10) --red flash at 7200rpm
--configure side LED warnings
sxSetAlertThresh(0,0,1,0,0,255,0) -- blue solid right LED at WarnLvl 1
sxSetAlertThresh(1,0,1,0,0,255,0) -- blue solid left LED at WarnLvl 1
sxSetAlertThresh(0,1,2,255,255,0,0) -- yellow solid right LED at WarnLvl 2
sxSetAlertThresh(1,1,2,255,255,0,0) -- yellow solid left LED at WarnLvl 2
sxSetAlertThresh(0,2,4,255,0,0,10) -- red flash right LED at WarnLvl 4
sxSetAlertThresh(1,2,4,255,0,0,10) --red flash left LED at WarnLvl 4
function onTick()
sxUpdateAlert(0,WarnLvl) --set right LED
sxUpdateAlert(1,WarnLvl) --set left LED
--Start section rev graph
sxUpdateLinearGraph(getChannel("rev"))
--local nmot = 1900 --10000 all green, 1000 all red flashing,11000 all yellow, 6000 none
--sxUpdateLinearGraph(nmot)
--End section rev graph
--Start section send GPS speed on CAN
local speed = getGpsSpeed()*1.6092*255 --convert to kph and rescale for increased precision
speedL = bit.band(speed, 0xFF) --mask out high byte
speedH = bit.rshift(speed, 8) --shift high byte to the right
--format the speed in a CAN message. Speed is in the first two bytes
local msg = {speedL,speedH}
txCAN(1, 1917, 0, msg)
--End section send GPS speed on CAN
end
* Solid blue when engine hasn't warmed up yet.
* Solid yellow for warning
* Blinking red for critical error
Used part of this script for inspiration:
viewtopic.php?t=5849