Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ShiftX3 with control of alternate ShiftX2/3
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)
--create gear channel
gearId = addChannel("Gear", 10, 0, 0, 6)
--config shift light
sxCfgLinearGraph(0,0,0,7000) --left to right graph, smooth style, 0 - 7000 RPM range
sxSetLinearThresh(0,0,1000,0,255,0,0) --green at 3000 RPM
sxSetLinearThresh(1,0,5000,255,255,0,0) --yellow at 5000 RPM
sxSetLinearThresh(2,0,6000,255,0,0,10) --red+flash at 6000 RPM
function control_other_shiftx()
--this sets the first LED of the secondary shiftX2/3 to white, flashing at 5Hz
-- params: 0 = CAN1
-- 931584 + 10 = base address for secondary ShiftX device + 10 offset for "Set Discrete LED"
-- 1 = "isExtended"
-- data payload {0 = first LED, 1 = 1 led to set, 255=red max brightness, 255=green max brightness, 255=blue max brightness, 5=5Hz}
txCAN(0, 931584 + 10, 1, {0, 1, 255, 255, 255, 5})
end
function onTick()
sxUpdateLinearGraph(getChannel("RPM"))
-- calculate gear: tire diameter(cm), final gear ratio, individual gear ratios 1-6
local gear = calcGear(62.7, 3.45, 4.23, 2.52, 1.66, 1.22, 1.0, 0.8)
setChannel(gearId, gear)
sxSetDisplay(0, gear)
control_other_shiftx()
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.