RaceCapturePro2 ShiftLights

Sequential Shift light

One way to enable shift light is by using the PWM / Analog output channels to trigger a 3 + 1 shift light output. In this case, we used 3 of the outputs to control the 3 LED segments on the ShiftX Sequential Shift Light display, and the 4th output controls a focused Red LED that flashes at the top end of the RPM range.

  • Example Video:

Video

Script

Requirements

  • A working RPM signal connected to the first timer input channel on RaceCapture/Pro.
  • Shift light boards connected to PWM / Analog out 1 - 3; flash alert LED to the 4th output
--[[ 

3 stage + 1 sequential shift light

Input 
Timer 0 - RPM 

Tach Lights 
0 - Green Light 
1 - Yellow Light 
2 - Red Light
3 - Flash alert 
]] 


-- Globals -- 
LIGHTS = 4 
LIGHT_VALS = {} 
FREQUENCY_HZ = 10 

-- 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) 
        lightOff(3) 
   elseif 3000 < rpm and rpm < 4500 then 
        lightOn(0) 
        lightOff(1) 
        lightOff(2) 
        lightOff(3)
   elseif 4500 < rpm and rpm < 5000 then 
        lightOn(0) 
        lightOn(1) 
        lightOff(2)
        lightOff(3) 
   elseif 5000 < rpm and rpm < 5500 then 
        lightOn(0) 
        lightOn(1) 
        lightOn(2)
        lightOff(3) 
   else 
        toggleLight(3) 
   end 
end 


function controlLights() 
   checkRpm() 
   updateLights() 
end 

-- Start! 

function onTick() 
   controlLights() 
end