Skip to content

Instantly share code, notes, and snippets.

setTickRate(30)
initCAN(0, 500000)
txCAN(0, 744389 + 10, 1, {0, 9, 0,0,0,5})
leds = 7
function onTick()
local x = getImu(3) / 10
local l = math.floor(math.abs(x))
if l > leds then l = leds end
setTickRate(30)
initCAN(0, 500000)
txCAN(0, 744389 + 12, 1, {0, 0, 5, 0, 0 , 255, 0, 0})
sleep(10)
txCAN(0, 744389 + 12, 1, {0, 1, 20, 0, 255, 0 , 0, 0})
sleep(10)
txCAN(0, 744389 + 12, 1, {1, 0, 5, 0, 0 , 255, 0, 0})
sleep(10)
@brentpicasso
brentpicasso / shiftx2_linear_graph_example.lua
Last active February 6, 2017 22:04
ShiftX2 linear graph configuration example
function splitWord(value)
return bit.band(value, 0xFF), bit.rshift(bit.band(value, 0xFF00),8)
end
function setLinearThreshold(id, threshold, red, green, blue, flash)
local lowt
local hight
lowt, hight = splitWord(threshold)
txCAN(0, 744389 + 15, 1, {id, 0, lowt, hight, red, green, blue, flash})
@brentpicasso
brentpicasso / shiftx2_obdii_smooth_shift_light.lua
Last active June 17, 2017 22:02
Demo script reading RPM from RaceCapture input, and updating the current shift light value
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
@brentpicasso
brentpicasso / shiftx2_predictive_timer_simulator.lua
Last active February 7, 2017 21:24
ShiftX2 predictive timer simulator
function splitWord(value)
return bit.band(value, 0xFF), bit.rshift(bit.band(value, 0xFF00),8)
end
function setLinearThreshold(id, threshold, red, green, blue, flash)
local lowt
local hight
lowt, hight = splitWord(threshold)
txCAN(0, 744389 + 15, 1, {id, 0, lowt, hight, red, green, blue, flash})
@brentpicasso
brentpicasso / shiftx2_full_demo.lua
Last active June 17, 2017 21:05
ShiftX2 full demo including discovery and auto-configuration
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
@brentpicasso
brentpicasso / shiftx2_afr_simulator.lua
Created February 12, 2017 23:21
ShiftX2 AFR simulator
slcan = 1
function splitWord(value)
return bit.band(value, 0xFF), bit.rshift(bit.band(value, 0xFF00),8)
end
function sl_cfgAlert(id, threshId, threshold, red, green, blue, flash)
local lowt
local hight
lowt, hight = splitWord(threshold)
txCAN(slcan, 744389 + 12, 1, {id, threshId, lowt, hight, red, green, blue, flash})
@brentpicasso
brentpicasso / shiftx2_pred_timer_simulator.lua
Last active June 17, 2017 21:45
ShiftX2 predictive timer simulator
--this script adequately simulates varying speeds and periodic pit stops
--disable all GPS channels
--disable lap timing
shiftx_can = 1
shiftx_id = 0xE3700
dist = 0
speed = 30
speedDir = 0
maxSpeedDir = 2
@brentpicasso
brentpicasso / shiftx2_random_colors.lua
Last active June 20, 2017 19:35
ShiftX2 random colors
sxCan = 0
sxId=0
tickRate=30
sxBright=0
function rndc()
return math.random(0,255)
end
function sxOnUpdate()
@brentpicasso
brentpicasso / shiftx2_color_sweep.lua
Last active June 22, 2017 20:10
Cycles ShiftX2 through all colors
sxCan = 0
sxId=0
tickRate=30
sxBright=0
r = 0
g = 0
b = 0
step = 10