Skip to content

Instantly share code, notes, and snippets.

@brentpicasso
brentpicasso / e46_expanded_channels.lua
Last active January 26, 2020 18:12
E46 expanded channels using 2.8.7 firmware and bitOp library
--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
@brentpicasso
brentpicasso / E46_CAN_simulator.lua
Created January 25, 2016 19:54
Simulator script for E46
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 January 26, 2016 01:04
Adding raw low / high byte debugging for wheel speeds
--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
@brentpicasso
brentpicasso / lapping_simulator_with_pit_stops.lua
Last active November 3, 2017 16:07
Lapping simulator with pit stops
--this script adequately simulates varying speeds and periodic pit stops
--disable all GPS channels
--disable lap timing
dist = 0
speed = 30
speedDir = 0
maxSpeedDir = 2
minSpeedDir = -2
lapCount = 0
currentLap = 1
--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 July 14, 2016 20:24
Trailing average for an sensor channel
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 November 6, 2016 22:02
All possible sample rate combinations for RaceCapture/Pro - for testing. save this as a RCP configuration file (all_sample_rates.rcp)
{
"rcpCfg": {
"analogCfg": {
"0": {
"alpha": 1.0,
"map": {
"raw": [
0.0,
1.25,
2.5,
@brentpicasso
brentpicasso / gist:247d898f369cfb731e0014bb6f9dcb3c
Created December 12, 2016 21:37
Create Random tire and brake temperature data for RaceCapture/Pro
tires = 4
tireZones = 4
tirePrefixes = {'TireTmpFL', 'TireTmpFR', 'TireTmpRL', 'TireTmpRR'}
tireValues = {}
tireIds = {}
minTireVal = 0
maxTireVal = 300
brakes = 4
brakeZones = 4
@brentpicasso
brentpicasso / tire_temperature_simulator.lua
Last active January 27, 2020 20:48
Simulated tire and brake temperature data based on g-force readings.
--Note, If 2.10.2 firmware, AccelX and AccelY need to be inverted in the RCP configuration.
tires = 4
tireZones = 4
tirePrefixes = {'TireTmpLF', 'TireTmpRF', 'TireTmpLR', 'TireTmpRR'}
tireValues = {}
tireIds = {}
minTireVal = 0
maxTireVal = 300
@brentpicasso
brentpicasso / car_overview_simulator.lua
Last active September 30, 2019 01:53
Simulated tire, brake temperature, TPMS and engine sensors. Tire and brake data based on g-force readings.
--Note, If 2.10.2 firmware, AccelX and AccelY need to be inverted in the RCP configuration.
tires = 4
tireZones = 4
tirePrefixes = {'TireTmpLF', 'TireTmpRF', 'TireTmpLR', 'TireTmpRR'}
tireValues = {}
tireIds = {}
minTireVal = 0
maxTireVal = 300