Created
June 17, 2017 22:00
-
-
Save brentpicasso/722a4e9f44dbc000ff76e2c2af217df5 to your computer and use it in GitHub Desktop.
ShiftX2 OBDII stepped shift light
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
shiftx_can = 1 | |
shiftx_id = 0xE3700 | |
function shiftx_tx(offset, data) | |
txCAN(shiftx_can, shiftx_id + offset, 1, data) | |
sleep(10) | |
end | |
function splitWord(value) | |
return bit.band(value, 0xFF), bit.rshift(bit.band(value, 0xFF00),8) | |
end | |
function setLinearThreshold(id, seg, threshold, red, green, blue, flash) | |
local lowt | |
local hight | |
lowt, hight = splitWord(threshold) | |
shiftx_tx(41,{id, seg, lowt, hight, red, green, blue, flash}) | |
sleep(10) | |
end | |
function configLinearGraph( renderStyle, linearStyle, lowRange, highRange) | |
local lowRangeLow | |
local lowRangeHigh | |
local highRangeLow | |
local highRangeHigh | |
lowRangeLow, lowRangeHigh = splitWord(lowRange) | |
highRangeLow, highRangeHigh = splitWord(highRange) | |
shiftx_tx(40,{renderStyle, linearStyle, lowRangeLow, lowRangeHigh, highRangeLow, highRangeHigh}) | |
sleep(10) | |
end | |
function updateLinearGraph(value) | |
low, high = splitWord(value) | |
shiftx_tx(42, {low, high}) | |
end | |
function onTick() | |
local rpm = readOBD2(12) | |
updateLinearGraph(rpm) | |
end | |
setTickRate(30) | |
initCAN(0, 500000) | |
configLinearGraph( 0, 1, 0, 7000) | |
setLinearThreshold(0, 3, 2000, 0, 255, 0, 0) | |
setLinearThreshold(1, 5, 5000, 255,127, 0, 0) | |
setLinearThreshold(2, 7, 6000, 255, 0, 0, 10) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment