Skip to content

Instantly share code, notes, and snippets.

val = 0
-- transmit on CAN1 and receive on CAN2
function onTick()
--transmit value on CAN1
txCAN(0, 1234, 0, {val})
--receive on CAN2
id, e, data = rxCAN(1)
@brentpicasso
brentpicasso / pct_gsum_max_calculator.lua
Created June 17, 2019 16:37
Percentage of Max Gsum calculator
-- Calculates and tracks how much of your maximum grip you are using, in real-time
setTickRate(25)
maxGsumId = addChannel("MaxGsum", 25, 2, -2.0, 2.0)
pctGsumMaxId = addChannel("PctMaxGsum", 25, 0, 0, 100)
maxGsum = 0
function updateGsumStats()
local gsum = getChannel("Gsum")
if gsum ~= nil and gsum > 0 then
@brentpicasso
brentpicasso / shiftx3_controlling_secondary.lua
Last active April 16, 2019 22:10
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)
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)
--config shift light
sxCfgLinearGraph(0,0,0,10000) --left to right graph, smooth style, 0 - 7000 RPM range
@brentpicasso
brentpicasso / gist:488a78d8f558c223e1634226dd8f07b6
Created February 12, 2019 23:38
iOS keep sleep timer from enabling
// Prevent sleep
[NSTimer scheduledTimerWithTimeInterval:2.0 repeats:YES block: ^(NSTimer * _Nonnull timer) {
[UIApplication sharedApplication].idleTimerDisabled = NO;
[UIApplication sharedApplication].idleTimerDisabled = YES;
NSLog(@"idle timer");
}];
NSLog(@"Initializing python");
Py_Initialize();
@brentpicasso
brentpicasso / RaceCapture_simple_Lua_CAN_bus_analyzer.lua
Last active April 22, 2022 21:24
Simple CAN bus analyzer for RaceCapture using Lua scripting
-- Simple CAN bus analyzer
-- This script is useful for reverse engineering CAN bus data
-- and detecting patterns.
--
-- Up to 100 individual 8 bit channels can be created. Additional channels will not be tracked.
-- CAN bus data will appear in the data stream with the channel name: <CAN ID>_<OFFSET>
-- Once script is running, you can monitor the data under Dashboard / Raw Channels View.
----------------------------------------
--Configuration
@brentpicasso
brentpicasso / ShiftX3_test.lua
Created October 10, 2018 14:45
Disco lights + 7 segment + button test
sxCan = 1
sxId=0
tickRate=30
sxBright=0
disp = 0
function rndc()
return math.random(0,255)
end
@brentpicasso
brentpicasso / test_virtual_channels.lua
Created October 4, 2018 16:48
Test virtual channels (EngineTemp and OilTemp)
maxEt = 300
maxOt = 300
etId = addChannel("EngineTemp", 10, 0, 0, maxEt)
otId = addChannel("OilTemp", 10, 0, 0, maxOt)
et = 0
ot = 0
setTickRate(50)
function onTick()
et=et+1
@brentpicasso
brentpicasso / RX8_manual_PID_query_engine_temp_fuel_level.lua
Last active July 12, 2018 22:46
Manual PID query with delay between PIDs to deal with RX8 ecu that cannot process rapid OBDII queries.
--Implements a simple OBDII engine in lua scripting, with a configurable delay between PIDs.
-- IMPORTANT: Ensure built-in OBDII is turned off in Setup
--
--500K baud. set your baud rate here.
initCAN(0, 500000)
--standard 11 bit PID request 0x7DF
--extended 29 bit PID request 0x18DB33F1
--standard 11 bit PID response 0x7E8
--extended 29 bit PID response 0x18DAF110
@brentpicasso
brentpicasso / pred_time_simulator_time_delta.lua
Created June 21, 2018 15:25
Predicted time simulator + alternating TimeDelta, for testing UI
setTickRate(2)
delta = 0
dir = 0.05
did = addChannel('TimeDelta2', 50, 2, -10, 10, 'sec')
pid = addChannel('PredTime', 10, 4, 0, 5, 'min')
clid = addChannel('CurrentLap', 50, 0)
lcid = addChannel('LapCount', 50, 0)