Making Shift lights flash on shiftx
Making Shift lights flash on shiftx
How to make all shift lights flash on my shift x or when max rpm is reached if somone could supply a script I can add into my existing one that would be great
Here is a script I wrote a while back. It uses the 3 PWM outputs on the RCP unit to control the lights instead of the GPIO units. You will need to adjust your RPM values accordingly.
[/code]
Code: Select all
--[[
Inputs as wired on 2014-12-05 -- Stieg
Input
Timer 0 - RPM
Tach Lights
0 - Green Light
1 - Yellow Light
2 - Red Light
]]
-- Globals --
LIGHTS = 3
LIGHT_VALS = {}
FREQUENCY_HZ = 25
-- Global Init --
setTickRate(FREQUENCY_HZ)
function toggleLight(index)
LIGHT_VALS[index] = not LIGHT_VALS[index]
end
function lightOn(index)
LIGHT_VALS[index] = true
end
function lightOff(index)
LIGHT_VALS[index] = false
end
local lCount = 0
repeat
lightOff(lCount)
lCount = lCount + 1
until lCount >= LIGHTS
-- Script --
function updateLights()
local l = 0
repeat
-- Convert our booleans to 1 (true) or 0 (false) --
local val = LIGHT_VALS[l]
local dc = 0
if not val then
dc = 100
end
setPwmDutyCycle(l, dc)
l = l + 1
until l >= LIGHTS
end
function checkRpm()
local rpm = getTimerRpm(0)
if rpm < 3000 then
lightOff(0)
lightOff(1)
lightOff(2)
elseif 3000 < rpm and rpm < 4500 then
lightOn(0)
lightOff(1)
lightOff(2)
elseif 4500 < rpm and rpm < 5000 then
lightOn(0)
lightOn(1)
lightOff(2)
elseif 5000 < rpm and rpm < 5500 then
lightOn(0)
lightOn(1)
lightOn(2)
else
toggleLight(0)
toggleLight(1)
toggleLight(2)
end
end
function controlLights()
checkRpm()
updateLights()
end
-- Start!
function onTick()
controlLights()
end
Andrew Stiegmann (Stieg)
Principal Engineer
Autosport Labs Inc.
Principal Engineer
Autosport Labs Inc.
I use the gpio so my current one looks like this
Code:
setTickRate(15) --15Hz
--Shift Now!!!!
function onTick()
rpm=getTimerRpm(2) --read RPM
--activate LEDs
if rpm > 8000 then return end --this filters out RPM spikes
if rpm > 6600 then setGpio(2,1) else setGpio(2,0) end
if rpm > 7000 then setGpio(1,1) else setGpio(1,0) end
if rpm > 7400 then setGpio(0,1) else setGpio(0,0) end
end
Code:
setTickRate(15) --15Hz
--Shift Now!!!!
function onTick()
rpm=getTimerRpm(2) --read RPM
--activate LEDs
if rpm > 8000 then return end --this filters out RPM spikes
if rpm > 6600 then setGpio(2,1) else setGpio(2,0) end
if rpm > 7000 then setGpio(1,1) else setGpio(1,0) end
if rpm > 7400 then setGpio(0,1) else setGpio(0,0) end
end
Code: Select all
If rpm > 7400 toggle Gpio (2,1) (1,1) (0,1) end
Andrew Stiegmann (Stieg)
Principal Engineer
Autosport Labs Inc.
Principal Engineer
Autosport Labs Inc.
If you intend to edit the scripts then it would be wise to jump into Lua a bit first to get an idea of what is happening. Here is a free tutorial provided by the folks who wrote LUA: https://www.lua.org/pil/contents.html#1. I would suggest you merely adjust the numbers in the checkRpm function in the script provided rather than try to add to it. Trying to jump straight in and do larger edits without experience will lead to lots of frustration, and that is no fun.What is meant by 3 calls I am a complete novice
Andrew Stiegmann (Stieg)
Principal Engineer
Autosport Labs Inc.
Principal Engineer
Autosport Labs Inc.