Skip to content

DisplayScripting

Josh Wardell edited this page Aug 26, 2020 · 12 revisions

Display scripting documentation

TODO

Example display scripts

Battery Power

Script:

if (CANServer_getAnalysisVar("DisplayOn") < 1) then
    return "1m t0b1000r"
end

local battPowerKW = (CANServer_getAnalysisVar("BattVolts") * CANServer_getAnalysisVar("BattAmps") / 1000.0)
local graphBattPower = math.floor(math.min(math.max((24) * (battPowerKW) / (300), -24), 24))

return "65535c" .. math.floor(battPowerKW * 10) .. "vWK  Bu" .. graphBattPower .. "b0m100r"

Analysis signals:

{
    "n": "BattVolts",
    "fid": 306,
    "sb": 0,
    "bl": 16,
    "f": 0.01,
    "so": 0,
    "s": false,
    "bo": true,
    "v": 1
}
{
    "n": "BattAmps",
    "fid": 306,
    "sb": 16,
    "bl": 16,
    "f": -0.1,
    "so": 0,
    "s": true,
    "bo": true,
    "v": 1
}

Motor Torque(s)

Rear Script:

if (CANServer_getAnalysisVar("DisplayOn") < 1) then
    return "1m t0b1000r"
end

local rearTorque = CANServer_getAnalysisVar("RearTorque")
local graphRearTorque = math.floor(math.min(math.max((24) * (rearTorque) / (400), -24), 24))

return "65535c" .. math.floor(rearTorque * 10) .. "vMNu" .. graphRearTorque .. "b0m100r"

Front Script:

if (CANServer_getAnalysisVar("DisplayOn") < 1) then
    return "1m t0b1000r"
end

local frontTorque = CANServer_getAnalysisVar("FrontTorque")
local graphFrontTorque = math.floor(math.min(math.max((24) * (frontTorque) / (400), -24), 24))

return "65535c" .. math.floor(frontTorque * 10) .. "vMNu" .. graphFrontTorque .. "b0m100r"

Analysis signals:

{
    "n": "RearTorque",
    "fid": 472,
    "sb": 24,
    "bl": 13,
    "f": 0.25,
    "so": 0,
    "s": true,
    "bo": true,
    "v": 1
}
{
    "n": "FrontTorque",
    "fid": 469,
    "sb": 24,
    "bl": 13,
    "f": 0.25,
    "so": 0,
    "s": true,
    "bo": true,
    "v": 1
}

MPH/KPH speedometer with blind spot detection arrows

Script:


if (CANServer_getAnalysisVar("DisplayOn") < 1) then
    return "1m t0b1000r"
end

local battPowerKW = (CANServer_getAnalysisVar("BattVolts") * CANServer_getAnalysisVar("BattAmps") / 1000.0)
local graphBattPower = math.floor(math.min(math.max((24) * (battPowerKW) / (300), -24), 24))

local bsr = CANServer_getAnalysisVar("BSR");
local bsl = CANServer_getAnalysisVar("BSL");

if (bsr > 0 and bsl > 0) then
	return "3v63488c6m100r";
elseif (bsr > 0 and bls == 0) then
	return "2v63488c6m100r";
elseif (bsr == 0 and bsl > 0) then
	return "1v63488c6m100r";
else 
	local speedUnitText = "HMK"
	local displaySpeed = CANServer_getAnalysisVar("VehSpeed")
	if (CANServer_getAnalysisVar("DistanceUnitMiles") == 1) then
		speedUnitText = "HPM"
		displaySpeed = displaySpeed * 0.6213712;
	end

	return "65535c" .. math.floor(displaySpeed * 10) .. "v" .. speedUnitText .. "u" 
				.. graphBattPower .. "b0m100r"
end

Analysis signals:

Advanced Battery info

Script:

if (CANServer_getAnalysisVar("DisplayOn") < 1) then
    return "1m4s               t0b1000r"
end

local rearTorque = CANServer_getAnalysisVar("RearTorque")
local graphRearTorque = math.floor(math.min(math.max((24) * (rearTorque) / (400), -24), 24))

return "65535c1s -BATTERY STATUS- " .. CANServer_getAnalysisVar("Range") .. "MI "  .. CANServer_getAnalysisVar("uSOE") .. "%SOC   "  .. CANServer_getAnalysisVar("MinBattTemp")*1.8+32 .. "F  " .. CANServer_getAnalysisVar("battTempPct") .. "%   " .. CANServer_getAnalysisVar("EnergyRemaining") .. " OF ".. CANServer_getAnalysisVar("FullPackEnergy") .. "KWHt" .. graphRearTorque .. "b1m1o100r"

Analysis signals:


{
	"n": "EnergyRemaining",
	"fid": 850,
	"sb": 11,
	"bl": 11,
	"f": 0.1,
	"so": 0,
	"s": false,
	"bo": true,
	"v": 1
}

{
	"n": "FullPackEnergy",
	"fid": 850,
	"sb": 0,
	"bl": 11,
	"f": 0.1,
	"so": 0,
	"s": false,
	"bo": true,
	"v": 1
}

{
	"n": "FullPackEnergy",
	"fid": 850,
	"sb": 0,
	"bl": 11,
	"f": 0.1,
	"so": 0,
	"s": false,
	"bo": true,
	"v": 1
}

{
	"n": "Range",
	"fid": 826,
	"sb": 0,
	"bl": 10,
	"f": 1,
	"so": 0,
	"s": false,
	"bo": true,
	"v": 1
}

{
	"n": "battTempPct",
	"fid": 658,
	"sb": 50,
	"bl": 8,
	"f": 0.4,
	"so": 0,
	"s": false,
	"bo": true,
	"v": 1
}

{
	"n": "uSOE",
	"fid": 826,
	"sb": 56,
	"bl": 7,
	"f": 1,
	"so": 0,
	"s": false,
	"bo": true,
	"v": 1
}

Clone this wiki locally