Skip to content

Instantly share code, notes, and snippets.

Avatar

Brent Picasso brentpicasso

View GitHub Profile
@brentpicasso
brentpicasso / E46_CAN_simulator.lua
Created Jan 25, 2016
Simulator script for E46
View E46_CAN_simulator.lua
setTickRate(30)
function encodeWheel(value)
low_byte = bit.band(value, 0xFF)
high_byte = bit.rshift(bit.band(value, 0x1F00), 5)
return low_byte, high_byte
end
lf_wheel = 0
rf_wheel = 0
@brentpicasso
brentpicasso / E46_debugging.lua
Last active Jan 26, 2016
Adding raw low / high byte debugging for wheel speeds
View E46_debugging.lua
--This example configured for E46 CAN
-- Automatically starts logging with engine 'on' (RPM triggered)
--how frequently we poll for CAN messages
tickRate = 30
--the CAN baud rate
CAN_baud = 500000
--CAN channel to listen on. 0=first CAN channel, 1=second
CAN_chan = 0
--add your virtual channels here
View RPM simulator
--RPM simulator!
rpm = 0
rpmDir = 100
maxRpm = 10000
rpmId = addChannel("RPM", 10, 0, 0, 10000)
setTickRate(50)
function onTick()
setChannel(rpmId, rpm)
rpm=rpm + rpmDir
@brentpicasso
brentpicasso / gist:d9fbf7dd44e010651bccbad910d290a4
Last active Jul 14, 2016
Trailing average for an sensor channel
View gist:d9fbf7dd44e010651bccbad910d290a4
fuel2Id = addChannel("Fuel2", 25, 2, 0,10,"%")
--change this to make a bigger averaging window
--300 = 10 seconds averaging at 30Hz tick rate
maxAvg = 300
fuelAvg={}
fuel2Index = 1
function updateFuel2(value)
local i
@brentpicasso
brentpicasso / all_sample_rates.rcp
Last active Nov 6, 2016
All possible sample rate combinations for RaceCapture/Pro - for testing. save this as a RCP configuration file (all_sample_rates.rcp)
View all_sample_rates.rcp
{
"rcpCfg": {
"analogCfg": {
"0": {
"alpha": 1.0,
"map": {
"raw": [
0.0,
1.25,
2.5,
@brentpicasso
brentpicasso / gist:247d898f369cfb731e0014bb6f9dcb3c
Created Dec 12, 2016
Create Random tire and brake temperature data for RaceCapture/Pro
View gist:247d898f369cfb731e0014bb6f9dcb3c
tires = 4
tireZones = 4
tirePrefixes = {'TireTmpFL', 'TireTmpFR', 'TireTmpRL', 'TireTmpRR'}
tireValues = {}
tireIds = {}
minTireVal = 0
maxTireVal = 300
brakes = 4
brakeZones = 4
View ShiftX2 Yaw sensor display
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
View gist:bb10380d570559fbce0cc6d700bded59
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 Feb 6, 2017
ShiftX2 linear graph configuration example
View shiftx2_linear_graph_example.lua
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_predictive_timer_simulator.lua
Last active Feb 7, 2017
ShiftX2 predictive timer simulator
View shiftx2_predictive_timer_simulator.lua
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})
You can’t perform that action at this time.