summaryrefslogtreecommitdiff
path: root/scripts/fanatec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/fanatec.lua')
-rw-r--r--scripts/fanatec.lua1000
1 files changed, 500 insertions, 500 deletions
diff --git a/scripts/fanatec.lua b/scripts/fanatec.lua
index 46d944c..7809f2b 100644
--- a/scripts/fanatec.lua
+++ b/scripts/fanatec.lua
@@ -1,500 +1,500 @@
--- Fanatec Lua Script v1.4
--- Copyright (c)2012-2013 by Zappadoc - All Rights Reserved.
--- this script builds all functions associated with
--- digits panels of Fanatec device
--- last change by Zappadoc - 2013-09
-
--- ============================================================
--- Digits Panel functions
--- ============================================================
-
--- IN function of digits panel
--- param: recieve from SLIMax Manager the current switch position
-function fanatecDigitsEvent(swFunction)
- swValue = swFunction + 1
- -- call custom script
- local result = custom_fanatecDigitsEvent(swValue)
- -- if result = 0 bypass the script below and return 0
- -- if result = 1 bypass the script below and return 1
- if result <= 1 then return result end
- -- if result >= 2 continue
-
- -- call global custom script
- result = global_custom_fanatecDigitsEvent(swValue)
- -- if result = 0 bypass the script below and return 0
- -- if result = 1 bypass the script below and return 1
- if result <= 1 then return result end
- -- if result >= 2 continue
-
- local hr = 0
- local mn = 0
- local sc = 0
- local ms = 0
- local hd = 0
- local lpt = 0.0
- local timeFlag = false
- local unit = false
- local fPanel = ""
- local inf = ""
- local unit = false
- local spd = 0.0
- local isSlowUpdate = false
-
- -- get speed in kph or mph (use "rawspeed" to get value in meter/sec)
- local spd = GetCarInfo("speed")
-
- -- get current display unit metric or imperial
- unit = GetContextInfo("speedmetric")
-
- -- check if quick info button is down
- local qi = false
- qi = GetContextInfo("quickinfobutton")
- if qi == nil or qi == 0 then qi = false end
- if qi then
- -- get index for fanatec panel
- local qiF = GetContextInfo("fanatecquickinfo")
- if qiF == nil then qiF = 1 end
- -- force position to match QI preference
- swValue = qiF
- end
-
- -- get current simulation name
- local sim = GetContextInfo("simulation")
-
- -- is OSP Tracking ON
- local ospt = false
- ospt = GetContextInfo("osptracking")
- if ospt == nil then ospt = false end
- if ospt then
- -- show rpm
- swValue = 22
- end
-
- -- lap finished, display lap time a few seconds
- local dlt = false
- dlt = GetContextInfo("displaylaptime")
- if dlt == nil then dlt = false end
- if dlt then
- swValue = 11
- end
-
- -- check if PIT Feedback ON
- local pf = false
- pf = GetContextInfo("pitfeedback")
- if pf == nil or pf == 0 then pf = false end
- if pf then
- -- force position to PIT function if car pits
- local pit = GetCarInfo("inpits")
- if pit > 0 then
- swValue = 41
- end
- end
-
- -- check postion and compute panel string
- if swValue == 1 then
- -- oldGear is intialized in gearEvent (see gear.lua)
- if oldGear ~= nil then
- -- gear
- --local g = GetCarInfo("gear")
-
- -- get neutral
- local n = string.char(GetContextInfo("neutral"))
- -- get reverse char and convert to string
- local r = string.char(GetContextInfo("reverse"))
- -- get state of custom Optimal Shift Point (OSP) records
- local ospcustom_on = GetContextInfo("ospcustom")
-
-
- -- set neutral, reverse or current gear
- if oldGear == 0 then
- -- if neutral and using custom OSP record then add a dot to gear digit
- SetFanatecGear(n, ospcustom_on)
-
- elseif oldGear < 0 then
- -- reverse
- SetFanatecGear(r, false)
-
- else
- -- if gear = 'E' give the hand to SLIMax Manager
- -- if g == 69 then
- -- return 0
- -- end
-
- SetFanatecGear(string.char(oldGear), false)
- end
-
-
- return 1
- end
-
- elseif swValue == 2 then
- -- speed
- if round(spd) > 0 then
- fPanel = string.format("%3d", round(spd) )
- else
- fPanel = "___"
- end
-
- elseif swValue == 3 then
- -- fuel
- local fuel = GetCarInfo("fuel")
- if fuel ~= nil then
- fuel = GetFuel(fuel, unit)
- if fuel >= 100 then
- fPanel = string.format("%03d", round(fuel) )
- elseif fuel >= 10 then
- fPanel = string.format("F%02d", round(fuel))
- else
- fPanel = string.format("F%1.1f", fuel)
- end
- end
-
- elseif swValue == 4 then
- -- position
- inf = GetContextInfo("position")
- if inf ~= nil then
- if inf >= 100 then
- fPanel = string.format("%03d", inf)
- else
- fPanel = string.format("P%02d", inf)
- end
- end
-
- elseif swValue == 5 then
- -- laps completed
- inf = GetContextInfo("laps")
- if inf ~= nil then
- -- if more then 99 laps
- if inf >= 100 then
- fPanel = string.format("%3.0f", inf)
- else
- fPanel = string.format("L%2.0f", inf)
- end
- end
-
- elseif swValue == 6 then
- -- sector
- local sect = GetCarInfo("sector")
- -- check if sector > 9
- if sect >9 then
- fPanel = string.format("S%2d", sect)
- else
- fPanel = string.format("S%1d ", sect)
- end
-
- elseif swValue == 7 then
- -- total laps
- local tl = GetContextInfo("lapscount")
- if tl < 1 then tl = 0 end
- -- if more then 99 laps
- if tl >= 100 or tl >= 100 then
- fPanel = string.format("%03d", tl)
- else
- fPanel = string.format("t%02d", tl)
- end
-
- elseif swValue == 8 then
- -- water temp
- inf = GetCarInfo("watertemp")
- if inf ~= nil then
- inf = GetTemp(inf, unit)
- fPanel = string.format("%2.1f", inf)
- end
-
- elseif swValue == 9 then
- -- oil temp
- inf = GetCarInfo("oiltemp")
- if inf ~= nil then
- inf = GetTemp(inf, unit)
- fPanel = string.format("%2.1f", inf)
- end
-
- elseif swValue == 10 then
- -- best lap time
- --timeFlag = true
- --dlt = true
- lpt = GetTimeInfo("bestlaptime")
- mFanatecText = DisplayFormatTime(lpt,mRefreshLapTimeRate,2,0,3)
-
- SetFanatecDigits( mFanatecText )
- return 1
- elseif swValue == 11 then
- -- last lap time
- --timeFlag = true
- --dlt = true
- lpt = GetTimeInfo("lastlaptime")
- mFanatecText = DisplayFormatTime(lpt,mRefreshLapTimeRate,2,0,3)
- SetFanatecDigits( mFanatecText )
- return 1
- elseif swValue >= 12 and swValue <= 18 and isAppIRacing(sim) then
- --timeFlag = true
- -- iRacing partials
- local ts = GetContextInfo("partialcount")
- local sector = GetCarInfo("sector")
- if sector == nil then sector = 0 end
- if ts ~= nil and ts > 0 then
- if swValue == 12 then
- lpt = GetPartialTimeInfo("currentpartial", sector)
- elseif swValue == 13 then
- lpt = GetPartialTimeInfo("vsbestlap", sector)
- elseif swValue == 14 then
- lpt = GetPartialTimeInfo("vsoptimallap", sector)
- elseif swValue == 15 then
- lpt = GetPartialTimeInfo("vsoptimalsector", sector)
- elseif swValue == 16 then
- lpt = GetPartialTimeInfo("vssessionbestlap", sector)
- elseif swValue == 17 then
- lpt = GetPartialTimeInfo("vssessionoptimallap", sector)
- elseif swValue == 18 then
- lpt = GetPartialTimeInfo("vssessionoptimalsector", sector)
- end
- else
- lpt = 0.0
- end
- mFanatecText = DisplayFormatTime(lpt,mDeltaTimeDelay,2,1,3)
- SetFanatecDigits( mFanatecText )
- return 1
- elseif swValue == 19 then
- -- real time diff vs your best
- --timeFlag = true
- lpt = GetTimeInfo("realdiffbest")
- mFanatecText = DisplayFormatTime(lpt,mDeltaTimeDelay,2,1,3)
- SetFanatecDigits( mFanatecText )
- return 1
- elseif swValue == 20 then
- -- real time diff vs your last
- --timeFlag = true
- lpt = GetTimeInfo("realdifflast")
- mFanatecText = DisplayFormatTime(lpt,mDeltaTimeDelay,2,1,3)
- SetFanatecDigits( mFanatecText )
- return 1
-
- elseif swValue == 21 then
- -- get an average consumption of fuel per lap and gives the remaining laps
- local remainintank = GetCarInfo("remainlapsintank")
- if remainintank >= 100 then
- fPanel = string.format("%3.0f", math.floor (remainintank))
- else
- fPanel = string.format("L%2.0f", math.floor(remainintank))
- end
-
- elseif swValue == 22 then
- -- rpm
- isSlowUpdate = true
- local rpm = GetCarInfo("rpm")
- local r = rpm / 100.0
- if r < 100 then
- fPanel = string.format("%2.1f", r)
- else
- fPanel = string.format("%3d.", round(r))
- end
- elseif swValue == 23 then
- -- track size
- isSlowUpdate = true
- local trcksz = GetContextInfo("tracksize")
- local r = trcksz / 100
- if r < 100 then
- fPanel = string.format("%2.1f", r)
- else
- fPanel = string.format("%3d.", round(r))
- end
-
- elseif swValue == 24 then
- -- distance percent
- local dist = GetContextInfo("lapdistance")
- -- track size
- local trcksz = GetContextInfo("tracksize")
- local p = round(dist / (trcksz / 100))
- fPanel = string.format("%3d", p )
-
- elseif swValue == 25 then
- -- kers
- local kers = GetCarInfo("kers")
- fPanel = string.format("%3d", round(kers/1000))
-
- elseif swValue == 26 then
- -- kers max
- local kmx = GetCarInfo("kersmax")
- fPanel = string.format("%3d", round(kmx/1000))
-
- elseif swValue == 27 then
- -- drs
- local drs = GetCarInfo("drs")
- if drs == 1 then
- fPanel = "ON "
- else
- fPanel = "OFF"
- end
-
- elseif swValue == 28 then
- -- kers percent
- local kers = GetCarInfo("kers")
- fPanel = string.format("%3d", round((kers/1000)/4))
-
- elseif swValue == 29 then
- -- wheels temp if available
- inf = GetCarInfo("wheeltempfrontleft")
- if inf ~= nil then
- -- if rFactor convert Kelvin to Celsius (see global.lua)
- if isAppRFactor(sim) then inf = KtoC(inf) end
- fPanel = string.format("%3.0f", inf)
- end
-
- elseif swValue == 30 then
- inf = GetCarInfo("wheeltempfrontright")
- if inf ~= nil then
- if isAppRFactor(sim) then inf = KtoC(inf) end
- fPanel = string.format("%3.0f", inf)
- end
-
- elseif swValue == 31 then
- inf = GetCarInfo("wheeltemprearleft")
- if inf ~= nil then
- if isAppRFactor(sim) then inf = KtoC(inf) end
- fPanel = string.format("%3.0f", inf)
- end
-
- elseif swValue == 32 then
- inf = GetCarInfo("wheeltemprearright")
- if inf ~= nil then
- if isAppRFactor(sim) then inf = KtoC(inf) end
- fPanel = string.format("%3.0f", inf)
- end
-
- elseif swValue == 33 then
- -- wheels pressure if available
- inf = GetCarInfo("wheelpressfrontleft")
- if inf ~= nil then
- -- convert to psi
- fPanel = string.format("%2.1f", inf / 6.88)
- end
-
- elseif swValue == 34 then
- inf = GetCarInfo("wheelpressfrontright")
- if inf ~= nil then
- fPanel = string.format("%2.1f", inf / 6.88)
- end
-
- elseif swValue == 35 then
- inf = GetCarInfo("wheelpressrearleft")
- if inf ~= nil then
- fPanel = string.format("%2.1f", inf / 6.88)
- end
-
- elseif swValue == 36 then
- inf = GetCarInfo("wheelpressrearright")
- if inf ~= nil then
- fPanel = string.format("%2.1f", inf / 6.88)
- end
-
- elseif swValue == 37 then
- -- brakes temp if available
- inf = GetCarInfo("braketempfrontleft")
- if inf ~= nil then
- if isAppRFactor(sim) or sim == "GTR2.exe" then inf = KtoC(inf) end
- fPanel = string.format("%3.0f", inf)
- end
-
- elseif swValue == 38 then
- inf = GetCarInfo("braketempfrontright")
- if inf ~= nil then
- if isAppRFactor(sim) or sim == "GTR2.exe" then inf = KtoC(inf) end
- fPanel = string.format("%3.0f", inf)
- end
-
- elseif swValue == 39 then
- inf = GetCarInfo("braketemprearleft")
- if inf ~= nil then
- if isAppRFactor(sim) or sim == "GTR2.exe" then inf = KtoC(inf) end
- fPanel = string.format("%3.0f", inf)
- end
-
- elseif swValue == 40 then
- inf = GetCarInfo("braketemprearright")
- if inf ~= nil then
- if isAppRFactor(sim) or sim == "GTR2.exe" then inf = KtoC(inf) end
- fPanel = string.format("%3.0f", inf)
- end
-
- elseif swValue == 41 then
- -- PIT
- fPanel = "PIt"
-
- elseif swValue == 42 then
- -- sc
- local sc = GetContextInfo("safetycare")
- if sc == 1 then
- fPanel = " SC"
- else
- fPanel = " "
- end
-
- else
- fPanel = " "
- end
-
- -- the function below has been replaced with generic time display function in global.lua
-
- -- if timeFlag and lpt ~= nil then
-
- -- -- explod time
- -- hr, mn, sc, hd, ms = timeDispatcher(lpt)
-
-
- -- print("lpt:" .. lpt .. " mn:" .. mn .. " sc:" .. sc .. " hd:" .. hd .. " ms:" .. ms .."\n" )
-
- -- -- update display every mDeltaTimeDelay time
- -- -- current ticks > old backuped value
- -- if GetTicks() > mDeltaTimeOldTicks then
- -- -- store ticks + delay
- -- mDeltaTimeOldTicks = GetTicks() + ( 2 * mDeltaTimeDelay)
-
- -- if lpt == -1 or (mn + sc + ms) == 0.00 then
- -- mDeltaTimeBackup = "-.--"
-
- -- elseif mn > 0 or sc >= 10 then
-
- -- if dlt and mn <100 then
- -- -- display time and mn < 100
- -- if mn >=10 then
- -- -- mn > 10
- -- mDeltaTimeBackup = string.format( "%2d.%01d", mn, sc)
- -- else
- -- mDeltaTimeBackup = string.format( "%1d.%02d", mn, sc)
- -- end
- -- else
- -- -- delta > 9.99s or lap time > 100mn
- -- mDeltaTimeBackup = " . "
- -- end
-
- -- else
- -- -- delta
- -- if lpt < 0 then
- -- -- negative value
- -- mDeltaTimeBackup = string.format( "-%01d.%01d ", sc, round(hd))
- -- else
- -- mDeltaTimeBackup = string.format( "%01d.%02d", sc, round(hd))
- -- end
- -- end
- -- end
-
- -- fPanel = mDeltaTimeBackup
- -- end
-
- if isSlowUpdate then
- -- request slow display update
- if GetTicks() > ( mDeltaTimeDelay + mDeltaTimeOldTicks ) then
- mDeltaTimeOldTicks = GetTicks()
- mFanatecText = fPanel
- end
- else
- -- normal display update
- mFanatecText = fPanel
- end
-
- -- send string to sli manager
- SetFanatecDigits( mFanatecText )
- return 1
-end
-
-
+-- Fanatec Lua Script v1.4
+-- Copyright (c)2012-2013 by Zappadoc - All Rights Reserved.
+-- this script builds all functions associated with
+-- digits panels of Fanatec device
+-- last change by Zappadoc - 2013-09
+
+-- ============================================================
+-- Digits Panel functions
+-- ============================================================
+
+-- IN function of digits panel
+-- param: recieve from SLIMax Manager the current switch position
+function fanatecDigitsEvent(swFunction)
+ swValue = swFunction + 1
+ -- call custom script
+ local result = custom_fanatecDigitsEvent(swValue)
+ -- if result = 0 bypass the script below and return 0
+ -- if result = 1 bypass the script below and return 1
+ if result <= 1 then return result end
+ -- if result >= 2 continue
+
+ -- call global custom script
+ result = global_custom_fanatecDigitsEvent(swValue)
+ -- if result = 0 bypass the script below and return 0
+ -- if result = 1 bypass the script below and return 1
+ if result <= 1 then return result end
+ -- if result >= 2 continue
+
+ local hr = 0
+ local mn = 0
+ local sc = 0
+ local ms = 0
+ local hd = 0
+ local lpt = 0.0
+ local timeFlag = false
+ local unit = false
+ local fPanel = ""
+ local inf = ""
+ local unit = false
+ local spd = 0.0
+ local isSlowUpdate = false
+
+ -- get speed in kph or mph (use "rawspeed" to get value in meter/sec)
+ local spd = GetCarInfo("speed")
+
+ -- get current display unit metric or imperial
+ unit = GetContextInfo("speedmetric")
+
+ -- check if quick info button is down
+ local qi = false
+ qi = GetContextInfo("quickinfobutton")
+ if qi == nil or qi == 0 then qi = false end
+ if qi then
+ -- get index for fanatec panel
+ local qiF = GetContextInfo("fanatecquickinfo")
+ if qiF == nil then qiF = 1 end
+ -- force position to match QI preference
+ swValue = qiF
+ end
+
+ -- get current simulation name
+ local sim = GetContextInfo("simulation")
+
+ -- is OSP Tracking ON
+ local ospt = false
+ ospt = GetContextInfo("osptracking")
+ if ospt == nil then ospt = false end
+ if ospt then
+ -- show rpm
+ swValue = 22
+ end
+
+ -- lap finished, display lap time a few seconds
+ local dlt = false
+ dlt = GetContextInfo("displaylaptime")
+ if dlt == nil then dlt = false end
+ if dlt then
+ swValue = 11
+ end
+
+ -- check if PIT Feedback ON
+ local pf = false
+ pf = GetContextInfo("pitfeedback")
+ if pf == nil or pf == 0 then pf = false end
+ if pf then
+ -- force position to PIT function if car pits
+ local pit = GetCarInfo("inpits")
+ if pit > 0 then
+ swValue = 41
+ end
+ end
+
+ -- check postion and compute panel string
+ if swValue == 1 then
+ -- oldGear is intialized in gearEvent (see gear.lua)
+ if oldGear ~= nil then
+ -- gear
+ --local g = GetCarInfo("gear")
+
+ -- get neutral
+ local n = string.char(GetContextInfo("neutral"))
+ -- get reverse char and convert to string
+ local r = string.char(GetContextInfo("reverse"))
+ -- get state of custom Optimal Shift Point (OSP) records
+ local ospcustom_on = GetContextInfo("ospcustom")
+
+
+ -- set neutral, reverse or current gear
+ if oldGear == 0 then
+ -- if neutral and using custom OSP record then add a dot to gear digit
+ SetFanatecGear(n, ospcustom_on)
+
+ elseif oldGear < 0 then
+ -- reverse
+ SetFanatecGear(r, false)
+
+ else
+ -- if gear = 'E' give the hand to SLIMax Manager
+ -- if g == 69 then
+ -- return 0
+ -- end
+
+ SetFanatecGear(string.char(oldGear), false)
+ end
+
+
+ return 1
+ end
+
+ elseif swValue == 2 then
+ -- speed
+ if round(spd) > 0 then
+ fPanel = string.format("%3d", round(spd) )
+ else
+ fPanel = "___"
+ end
+
+ elseif swValue == 3 then
+ -- fuel
+ local fuel = GetCarInfo("fuel")
+ if fuel ~= nil then
+ fuel = GetFuel(fuel, unit)
+ if fuel >= 100 then
+ fPanel = string.format("%03d", round(fuel) )
+ elseif fuel >= 10 then
+ fPanel = string.format("F%02d", round(fuel))
+ else
+ fPanel = string.format("F%1.1f", fuel)
+ end
+ end
+
+ elseif swValue == 4 then
+ -- position
+ inf = GetContextInfo("position")
+ if inf ~= nil then
+ if inf >= 100 then
+ fPanel = string.format("%03d", inf)
+ else
+ fPanel = string.format("P%02d", inf)
+ end
+ end
+
+ elseif swValue == 5 then
+ -- laps completed
+ inf = GetContextInfo("laps")
+ if inf ~= nil then
+ -- if more then 99 laps
+ if inf >= 100 then
+ fPanel = string.format("%3.0f", inf)
+ else
+ fPanel = string.format("L%2.0f", inf)
+ end
+ end
+
+ elseif swValue == 6 then
+ -- sector
+ local sect = GetCarInfo("sector")
+ -- check if sector > 9
+ if sect >9 then
+ fPanel = string.format("S%2d", sect)
+ else
+ fPanel = string.format("S%1d ", sect)
+ end
+
+ elseif swValue == 7 then
+ -- total laps
+ local tl = GetContextInfo("lapscount")
+ if tl < 1 then tl = 0 end
+ -- if more then 99 laps
+ if tl >= 100 or tl >= 100 then
+ fPanel = string.format("%03d", tl)
+ else
+ fPanel = string.format("t%02d", tl)
+ end
+
+ elseif swValue == 8 then
+ -- water temp
+ inf = GetCarInfo("watertemp")
+ if inf ~= nil then
+ inf = GetTemp(inf, unit)
+ fPanel = string.format("%2.1f", inf)
+ end
+
+ elseif swValue == 9 then
+ -- oil temp
+ inf = GetCarInfo("oiltemp")
+ if inf ~= nil then
+ inf = GetTemp(inf, unit)
+ fPanel = string.format("%2.1f", inf)
+ end
+
+ elseif swValue == 10 then
+ -- best lap time
+ --timeFlag = true
+ --dlt = true
+ lpt = GetTimeInfo("bestlaptime")
+ mFanatecText = DisplayFormatTime(lpt,mRefreshLapTimeRate,2,0,3)
+
+ SetFanatecDigits( mFanatecText )
+ return 1
+ elseif swValue == 11 then
+ -- last lap time
+ --timeFlag = true
+ --dlt = true
+ lpt = GetTimeInfo("lastlaptime")
+ mFanatecText = DisplayFormatTime(lpt,mRefreshLapTimeRate,2,0,3)
+ SetFanatecDigits( mFanatecText )
+ return 1
+ elseif swValue >= 12 and swValue <= 18 and isAppIRacing(sim) then
+ --timeFlag = true
+ -- iRacing partials
+ local ts = GetContextInfo("partialcount")
+ local sector = GetCarInfo("sector")
+ if sector == nil then sector = 0 end
+ if ts ~= nil and ts > 0 then
+ if swValue == 12 then
+ lpt = GetPartialTimeInfo("currentpartial", sector)
+ elseif swValue == 13 then
+ lpt = GetPartialTimeInfo("vsbestlap", sector)
+ elseif swValue == 14 then
+ lpt = GetPartialTimeInfo("vsoptimallap", sector)
+ elseif swValue == 15 then
+ lpt = GetPartialTimeInfo("vsoptimalsector", sector)
+ elseif swValue == 16 then
+ lpt = GetPartialTimeInfo("vssessionbestlap", sector)
+ elseif swValue == 17 then
+ lpt = GetPartialTimeInfo("vssessionoptimallap", sector)
+ elseif swValue == 18 then
+ lpt = GetPartialTimeInfo("vssessionoptimalsector", sector)
+ end
+ else
+ lpt = 0.0
+ end
+ mFanatecText = DisplayFormatTime(lpt,mDeltaTimeDelay,2,1,3)
+ SetFanatecDigits( mFanatecText )
+ return 1
+ elseif swValue == 19 then
+ -- real time diff vs your best
+ --timeFlag = true
+ lpt = GetTimeInfo("realdiffbest")
+ mFanatecText = DisplayFormatTime(lpt,mDeltaTimeDelay,2,1,3)
+ SetFanatecDigits( mFanatecText )
+ return 1
+ elseif swValue == 20 then
+ -- real time diff vs your last
+ --timeFlag = true
+ lpt = GetTimeInfo("realdifflast")
+ mFanatecText = DisplayFormatTime(lpt,mDeltaTimeDelay,2,1,3)
+ SetFanatecDigits( mFanatecText )
+ return 1
+
+ elseif swValue == 21 then
+ -- get an average consumption of fuel per lap and gives the remaining laps
+ local remainintank = GetCarInfo("remainlapsintank")
+ if remainintank >= 100 then
+ fPanel = string.format("%3.0f", math.floor (remainintank))
+ else
+ fPanel = string.format("L%2.0f", math.floor(remainintank))
+ end
+
+ elseif swValue == 22 then
+ -- rpm
+ isSlowUpdate = true
+ local rpm = GetCarInfo("rpm")
+ local r = rpm / 100.0
+ if r < 100 then
+ fPanel = string.format("%2.1f", r)
+ else
+ fPanel = string.format("%3d.", round(r))
+ end
+ elseif swValue == 23 then
+ -- track size
+ isSlowUpdate = true
+ local trcksz = GetContextInfo("tracksize")
+ local r = trcksz / 100
+ if r < 100 then
+ fPanel = string.format("%2.1f", r)
+ else
+ fPanel = string.format("%3d.", round(r))
+ end
+
+ elseif swValue == 24 then
+ -- distance percent
+ local dist = GetContextInfo("lapdistance")
+ -- track size
+ local trcksz = GetContextInfo("tracksize")
+ local p = round(dist / (trcksz / 100))
+ fPanel = string.format("%3d", p )
+
+ elseif swValue == 25 then
+ -- kers
+ local kers = GetCarInfo("kers")
+ fPanel = string.format("%3d", round(kers/1000))
+
+ elseif swValue == 26 then
+ -- kers max
+ local kmx = GetCarInfo("kersmax")
+ fPanel = string.format("%3d", round(kmx/1000))
+
+ elseif swValue == 27 then
+ -- drs
+ local drs = GetCarInfo("drs")
+ if drs == 1 then
+ fPanel = "ON "
+ else
+ fPanel = "OFF"
+ end
+
+ elseif swValue == 28 then
+ -- kers percent
+ local kers = GetCarInfo("kers")
+ fPanel = string.format("%3d", round((kers/1000)/4))
+
+ elseif swValue == 29 then
+ -- wheels temp if available
+ inf = GetCarInfo("wheeltempfrontleft")
+ if inf ~= nil then
+ -- if rFactor convert Kelvin to Celsius (see global.lua)
+ if isAppRFactor(sim) then inf = KtoC(inf) end
+ fPanel = string.format("%3.0f", inf)
+ end
+
+ elseif swValue == 30 then
+ inf = GetCarInfo("wheeltempfrontright")
+ if inf ~= nil then
+ if isAppRFactor(sim) then inf = KtoC(inf) end
+ fPanel = string.format("%3.0f", inf)
+ end
+
+ elseif swValue == 31 then
+ inf = GetCarInfo("wheeltemprearleft")
+ if inf ~= nil then
+ if isAppRFactor(sim) then inf = KtoC(inf) end
+ fPanel = string.format("%3.0f", inf)
+ end
+
+ elseif swValue == 32 then
+ inf = GetCarInfo("wheeltemprearright")
+ if inf ~= nil then
+ if isAppRFactor(sim) then inf = KtoC(inf) end
+ fPanel = string.format("%3.0f", inf)
+ end
+
+ elseif swValue == 33 then
+ -- wheels pressure if available
+ inf = GetCarInfo("wheelpressfrontleft")
+ if inf ~= nil then
+ -- convert to psi
+ fPanel = string.format("%2.1f", inf / 6.88)
+ end
+
+ elseif swValue == 34 then
+ inf = GetCarInfo("wheelpressfrontright")
+ if inf ~= nil then
+ fPanel = string.format("%2.1f", inf / 6.88)
+ end
+
+ elseif swValue == 35 then
+ inf = GetCarInfo("wheelpressrearleft")
+ if inf ~= nil then
+ fPanel = string.format("%2.1f", inf / 6.88)
+ end
+
+ elseif swValue == 36 then
+ inf = GetCarInfo("wheelpressrearright")
+ if inf ~= nil then
+ fPanel = string.format("%2.1f", inf / 6.88)
+ end
+
+ elseif swValue == 37 then
+ -- brakes temp if available
+ inf = GetCarInfo("braketempfrontleft")
+ if inf ~= nil then
+ if isAppRFactor(sim) or sim == "GTR2.exe" then inf = KtoC(inf) end
+ fPanel = string.format("%3.0f", inf)
+ end
+
+ elseif swValue == 38 then
+ inf = GetCarInfo("braketempfrontright")
+ if inf ~= nil then
+ if isAppRFactor(sim) or sim == "GTR2.exe" then inf = KtoC(inf) end
+ fPanel = string.format("%3.0f", inf)
+ end
+
+ elseif swValue == 39 then
+ inf = GetCarInfo("braketemprearleft")
+ if inf ~= nil then
+ if isAppRFactor(sim) or sim == "GTR2.exe" then inf = KtoC(inf) end
+ fPanel = string.format("%3.0f", inf)
+ end
+
+ elseif swValue == 40 then
+ inf = GetCarInfo("braketemprearright")
+ if inf ~= nil then
+ if isAppRFactor(sim) or sim == "GTR2.exe" then inf = KtoC(inf) end
+ fPanel = string.format("%3.0f", inf)
+ end
+
+ elseif swValue == 41 then
+ -- PIT
+ fPanel = "PIt"
+
+ elseif swValue == 42 then
+ -- sc
+ local sc = GetContextInfo("safetycare")
+ if sc == 1 then
+ fPanel = " SC"
+ else
+ fPanel = " "
+ end
+
+ else
+ fPanel = " "
+ end
+
+ -- the function below has been replaced with generic time display function in global.lua
+
+ -- if timeFlag and lpt ~= nil then
+
+ -- -- explod time
+ -- hr, mn, sc, hd, ms = timeDispatcher(lpt)
+
+
+ -- print("lpt:" .. lpt .. " mn:" .. mn .. " sc:" .. sc .. " hd:" .. hd .. " ms:" .. ms .."\n" )
+
+ -- -- update display every mDeltaTimeDelay time
+ -- -- current ticks > old backuped value
+ -- if GetTicks() > mDeltaTimeOldTicks then
+ -- -- store ticks + delay
+ -- mDeltaTimeOldTicks = GetTicks() + ( 2 * mDeltaTimeDelay)
+
+ -- if lpt == -1 or (mn + sc + ms) == 0.00 then
+ -- mDeltaTimeBackup = "-.--"
+
+ -- elseif mn > 0 or sc >= 10 then
+
+ -- if dlt and mn <100 then
+ -- -- display time and mn < 100
+ -- if mn >=10 then
+ -- -- mn > 10
+ -- mDeltaTimeBackup = string.format( "%2d.%01d", mn, sc)
+ -- else
+ -- mDeltaTimeBackup = string.format( "%1d.%02d", mn, sc)
+ -- end
+ -- else
+ -- -- delta > 9.99s or lap time > 100mn
+ -- mDeltaTimeBackup = " . "
+ -- end
+
+ -- else
+ -- -- delta
+ -- if lpt < 0 then
+ -- -- negative value
+ -- mDeltaTimeBackup = string.format( "-%01d.%01d ", sc, round(hd))
+ -- else
+ -- mDeltaTimeBackup = string.format( "%01d.%02d", sc, round(hd))
+ -- end
+ -- end
+ -- end
+
+ -- fPanel = mDeltaTimeBackup
+ -- end
+
+ if isSlowUpdate then
+ -- request slow display update
+ if GetTicks() > ( mDeltaTimeDelay + mDeltaTimeOldTicks ) then
+ mDeltaTimeOldTicks = GetTicks()
+ mFanatecText = fPanel
+ end
+ else
+ -- normal display update
+ mFanatecText = fPanel
+ end
+
+ -- send string to sli manager
+ SetFanatecDigits( mFanatecText )
+ return 1
+end
+
+