# LSlip: It shows a smiley on yer screen! # Also outputs the average longitudinal slip of the rear tyres to a comma separated list (OFF BY DEFAULT). # Date: 20-Aug-2013 # Filename: LSplit.py # Folder: \apps\python\LSplit\ import ac import acsys # Smiley settings, you can change these. # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # # # # # # # # SmileyShowTime 0 to 3 (float, seconds). Default: 0.5 # # Action needs to last this long in order to be shown. 0 (instant), 3 (likely to miss ":)" and ":D"). # # # # SlipLimitLow 0 to ~4000 (Scalar). Default: 3000 # # Anything below this is ":|" (no slip). Too low and you never see it; too high and it's all you see. # # # # SlipLimitMid ~2000 to ~6000 (Scalar). Default: 4000 # # Between Low and Mid is ":)". Reduce to see less ":)" and more ":D". Increase to see more ":)" and less ":D". # # # # SlipLimitHigh ~4000+ (Scalar). Over 32k may be out of bounds. Default: 5500 # # Between Mid and High is ":D". More than High is ":O". Reduce to see more ":O" and less ":D". Increase to see less ":O" and more ":D". # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # # # # # SmileyShowTime = 0.5 SlipLimitLow = 3000 SlipLimitMid = 4000 SlipLimitHigh = 5500 # Slip value output settings, you can change these. # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # # # # # # # # OutputFile String. # # Full path and file name of output file. # # # # WriteToFile 0 or 1 (bool). # # 0 = output to file is disabled. 1 = output to file is enabled. A 1:25 lap is around 35kB. # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # # # # # OutputFile = 'd:\out.txt' WriteToFile = 0 ### Code starts here, stay away! ### CurLap = 0 SlipValues = '' IsFileReset = 0 SmileyTimer = 0 SmileyText = 0 def acMain(ac_version): global SmileyText # Frame settings. appWindow = ac.newApp('LSlip') ac.setSize(appWindow, 120, 60) # Text settings. SmileyText = ac.addLabel(appWindow, 'Value') ac.setPosition(SmileyText, 10, 30) ac.setFontAlignment(SmileyText, 'center') ac.setSize(SmileyText, 100, 30) return 'LSlip' def acUpdate(deltaT): global SmileyText, CurLap, SlipValues, IsFileReset, SmileyTimer, SmileyShowTime, OutputFile, SlipLimitLow, SlipLimitMid, SlipLimitHigh # Smiley section. FL, FR, RL, RR = ac.getCarState(0, acsys.CS.TyreSlip) CurSlipValue = round( (RL+RR)/2 ) if SmileyTimer > SmileyShowTime: if SlipLimitLow < CurSlipValue < SlipLimitMid+1: ac.setText(SmileyText, ':)') elif SlipLimitMid < CurSlipValue < SlipLimitHigh: ac.setText(SmileyText, ':D') elif CurSlipValue >= SlipLimitHigh: ac.setText(SmileyText, ':O') else: ac.setText(SmileyText, ':|') SmileyTimer = 0 else: SmileyTimer += deltaT # Slip value output section. CurLapCount = ac.getCarState(0, acsys.CS.LapCount) if WriteToFile: # Remove old output file at initial load. if not IsFileReset: open(OutputFile, 'w').close() IsFileReset = 1 # Write to file if lap has changed. if CurLapCount > CurLap: f = open(OutputFile, 'a') f.write(SlipValues) f.close() SlipValues = '' # remove written data from memory. CurLap = CurLap + 1 else: # Ignore small slip values, can be changed. if CurSlipValue > 75: SlipValues += str(CurSlipValue) + ','