Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- setTickRate(30)
- -- Set ShiftX3 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)
- --config shift light
- sxCfgLinearGraph(0,0,0,10000) --left to right graph, smooth style, 0 - 7000 RPM range
- sxSetLinearThresh(0,0,0,0,255,0,0) --green
- sxSetLinearThresh(1,0,5000,255,255,0,0) --yellow
- sxSetLinearThresh(2,0,6000,255,0,0,0) --red
- sxSetLinearThresh(3,0,8000,255,255,255,10) --whiteflash
- --configure first alert (right LED)
- sxSetAlertThresh(1,0,205,255,255,0,0) --yellow warning at 205
- sxSetAlertThresh(1,1,225,255,0,0,10) -- red flash at 225
- --configure second alert (left LED)
- sxSetAlertThresh(0,0,170,255,0,255,10) --purple at 170
- sxSetAlertThresh(0,1,280,255,255,0,5) -- yellow at 280
- --Create simulated channels and state
- --Channel ID, currentValue, increment, min, max
- rpmState = {addChannel('SimRPM', 10, 0, 0, 10000), 0, 200, 0, 10000}
- etState = {addChannel('SimEngTmp', 10, 0, 0, 300), 0, 2, 0, 300}
- oilState = {addChannel('SimOilTmp', 10, 0, 0, 300), 0, 1, 0, 300}
- display = 1
- function updateSimChannel(state, incDisplay)
- local id = state[1]
- local currentVal = state[2]
- local increment = state[3]
- local min = state[4]
- local max = state[5]
- currentVal = currentVal + increment
- -- check min/max and change direction if needed
- if currentVal >= max or currentVal <= min then
- increment = -increment
- if incDisplay == true and currentVal >= max then
- display = display + 1
- if display > 6 then display = 1 end
- sxSetDisplay(0,display)
- end
- end
- --update the virtual channel
- setChannel(id, currentVal)
- --store updated values in state
- state[2] = currentVal
- state[3] = increment
- end
- function onTick()
- updateSimChannel(rpmState, true)
- updateSimChannel(etState)
- updateSimChannel(oilState)
- --update RPM
- sxUpdateLinearGraph(getChannel("SimRPM"))
- --update engine temp alert
- sxUpdateAlert(1, getChannel("SimEngTmp"))
- --update oil pressure alert
- sxUpdateAlert(0, getChannel("SimOilTmp"))
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement