summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugues Hiegel <hugues@hiegel.fr>2013-11-21 08:33:58 +0100
committerHugues Hiegel <hugues@hiegel.fr>2013-11-21 08:33:58 +0100
commit506ca9e9d9d79c1464baf185389a1750e37e9a0a (patch)
tree57aafae99ab4768783b8d19e849a9003c402447e
parent25d2c96938071f45def98fbdc30cf20a57a71784 (diff)
old stuff backup
-rw-r--r--tricks/global_To_sectorSplits.diff297
-rw-r--r--tricks/k2000_test.lua40
-rw-r--r--tricks/k2000_test2.lua74
-rw-r--r--tricks/marquee.lua35
-rw-r--r--tricks/sectorTimes.lua159
5 files changed, 605 insertions, 0 deletions
diff --git a/tricks/global_To_sectorSplits.diff b/tricks/global_To_sectorSplits.diff
new file mode 100644
index 0000000..d5c1fcb
--- /dev/null
+++ b/tricks/global_To_sectorSplits.diff
@@ -0,0 +1,297 @@
+diff --git a/scripts/global.lua b/scripts/global.lua
+index 867e73e..ac3c797 100644
+--- a/scripts/global.lua
++++ b/scripts/global.lua
+@@ -28,6 +28,9 @@ mDeltaTimeDelay = 200
+ -- change the delay below to increase or decrease the update of lap time
+ mRefreshLapTimeRate = 50
+
++-- display sector split times
++mSectorSplitDelay = 8000
++
+ -- get feedback on display when you turn encoder or press button assigned to internal functions, see control.lua
+ -- true if you want to display switch pos and value
+ mSwitchFeedbackAllowed = false
+@@ -161,21 +164,16 @@ mRPMLedTable = {
+ -- SLI device type
+ -- mDeviceType no longer avaialable use GetDeviceType(devID) see 2.3 API
+
++mLastSectorTime = {}
++mBestSectorTime = {}
++mCurrentSector = 0
++mSectors = 0
+
+--- init globals
+-if mOld_ls1 == nil then
+- mOld_bs1 = 0.00000
+- mOld_bs2 = 0.00000
+- mOld_bt = 0.00000
+- mDelta_lpt = 0.00000
+- mDelta_lptb = 0.00000
+- mOld_ls1 = 0.00000
+- mOld_ls2 = 0.00000
+- mOld_lt = 0.00000
+- mDelta_lpt = 0.00000
+- mDelta_lptb = 0.00000
+- mDelta_Sect1 = 0.0000
+- mDelta_Sect1b = 0.0000
++function initSectorTimes()
++ --mSectors = GetContextInfo("sectorcount")
++ mLastSectorTime = {}
++ mBestSectorTime = {}
++ mCurrentSector = 1
+ end
+
+
+@@ -283,7 +281,7 @@ function GetSLIMaxInfo()
+ end
+
+ -- get cpu ticks
+- function GetTicks()
++function GetTicks()
+ local tcks = GetContextInfo("ticks")
+ if tcks == nil then tcks = 0 end
+ return tcks
+@@ -576,158 +574,114 @@ function DisplayFormatTime(lptime, delay, dec, deltaflag, numDigits)
+ return Panel
+ end
+
+-
+--- return delta time vs last time + sector diff
+-function GetDeltaLastTime(isRF)
+-
+- local lpt = 0.0
+-
++function UpdateSectorTimes()
+ local sector = GetCarInfo("sector")
+
+- if mDiffSectorDelay == nil or mDiffOldSector == nil or mDiffOldSector ~= sector then
+- -- 8s delay, increase it if needed
+- mDiffSectorDelay = GetTicks() + 8000
+- mDiffOldSector = sector
+-
+- if sector == 1 then
+- -- diff lap time 3
+- local lt = GetTimeInfo("lastlaptime")
+-
+- if lt > 0 and mOld_lt > 0 then
+- -- diff
+- mDelta_lpt = lt - mOld_lt
++ if mCurrentSector ~= sector then
++ local lastSector = sector - 1
++ if lastSector == 0 then lastSector = table.getn(mLastSectorTime) end
++
++ local ls = 0.00000
++
++ if isAppRFactor(GetContextInfo("simulation")) then
++ ls = GetTimeInfo(string.format("sector%d", lastSector))
++ else
++ ls = GetTimeInfo(string.format("lastsector%d", lastSector))
++ end
++
++ print ( "sector "..lastSector.." : " .. ls)
++
++ --
++ if mLastSectorTime[lastSector] == nil then
++ mLastSectorTime[lastSector] = {0.00000, 0.00000}
++ end
++ -- save previous best sector for sector split times
++ mLastSectorTime[lastSector][2] = mLastSectorTime[lastSector][1]
++ -- stores last sector time
++ mLastSectorTime[lastSector][1] = ls
++
++ --
++ if mBestSectorTime[lastSector] == nil then
++ mBestSectorTime[lastSector] = {0.00000, 0.00000}
++ end
++ -- save previous best sector for sector split times
++ mBestSectorTime[lastSector][2] = mBestSectorTime[lastSector][1]
++ if ls ~= 0.0 and mBestSectorTime[lastSector][1] > ls then
++ -- stores best sector time if better than best :)
++ mBestSectorTime[lastSector][1] = ls
++ end
++
++
++ -- save current sector value
++ mCurrentSector = sector
++ -- set ticks for display
++ mDiffSectorDelay = GetTicks() + mSectorSplitDelay
+ end
+- -- backup lt
+- mOld_lt = lt
+- -- save bt for delta vs best function
+- mOld_bt = GetTimeInfo("bestlaptime")
+-
++end
+
+- elseif sector == 2 then
+- -- diff sector 1
+- local ls1 = GetTimeInfo("lastsector1")
+- if isRF then
+- ls1 = GetTimeInfo("sector1")
+- end
++-- return delta time vs last time + sector diff
++function GetDeltaLastTime()
+
+- if ls1 > 0 and mOld_ls1 > 0 then
+- mDelta_lpt = ls1 - mOld_ls1
+- mDelta_Sect1 = mDelta_lpt
+- end
++ local lpt = 0.0
+
+- -- backup
+- mOld_ls1 = ls1
+- -- save bt for delta vs best function
+- mOld_bs = GetTimeInfo("bestsector1")
++ if mDiffSectorDelay ~= nil and GetTicks() < mDiffSectorDelay then
+
+- else
+- -- diff sector 2
+- local ls2 = GetTimeInfo("lastsector2")
+- if isRF then
+- ls2 = GetTimeInfo("sector2")
+- end
++ local lastSector = GetCarInfo("sector") - 1
++ if lastSector == 0 then lastSector = table.getn(mLastSectorTime) end
+
++ local ls = 0.00000
+
+- if ls2 > 0 and mOld_ls2 > 0 then
+- if mDelta_total_split_sectors then
+- mDelta_lpt = mDelta_Sect1 + (ls2 - mOld_ls2)
+- else
+- mDelta_lpt = ls2 - mOld_ls2
+- end
+- end
+- -- backup value
+- mOld_ls2 = ls2
+- -- save bt for delta vs best function below
+- mOld_bs2 = GetTimeInfo("bestsector2")
++ if isAppRFactor(GetContextInfo("simulation")) then
++ ls = GetTimeInfo(string.format("sector%d", lastSector))
++ else
++ ls = GetTimeInfo(string.format("lastsector%d", lastSector))
++ end
+
+- end
+- end
++ local start = lastSector
++ -- check whether to sum all sector diff values or not
++ if mDelta_total_split_sectors then start = 1 end
++ for i = start, lastSector, 1 do
++ local ls = mLastSectorTime[i][1]
++ local old_ls = mLastSectorTime[i][2]
++ if ls > 0 and old_ls > 0 then
++ lpt = lpt + (ls - old_ls)
++ end
++ end
+
+- -- display delta by default
+- lpt = GetTimeInfo("realdifflast")
+-
+- if mDiffSectorDelay > GetTicks() then
+- lpt = mDelta_lpt
++ else
++ -- display delta by default
++ lpt = GetTimeInfo("realdifflast")
+ end
+
+ return lpt
+ end
+
+ -- return delta time vs best time + sector diff
+-function GetDeltaBestTime(isRF)
+- local lpt = 0.0
+-
+- -- get sector
+- local sector = GetCarInfo("sector")
++function GetDeltaBestTime()
+
+- -- set delay
+- if mDiffSectorDelay == nil or mDiffOldSector == nil or mDiffOldSector ~= sector then
+- -- 8s delay, increase it if needed
+- mDiffSectorDelay = GetTicks() + 8000
+- mDiffOldSector = sector
+-
+- -- display sector diff during delay
+- if sector == 1 then
+-
+- -- diff last lap time vs best
+- local bt = GetTimeInfo("lastlaptime")
+-
+- -- save lt for delta vs last function above
+- mOld_lt = bt
+-
+- -- compare
+- if bt > 0 and mOld_bt > 0 then
+- -- delta
+- mDelta_lptb = bt - mOld_bt
+- end
+- -- backup
+- mOld_bt = GetTimeInfo("bestlaptime")
++ local lpt = 0.0
+
++ if mDiffSectorDelay ~= nil and GetTicks() < mDiffSectorDelay then
+
+- elseif sector == 2 then
+- -- diff sector 1
+- local bs1 = GetTimeInfo("lastsector1")
+- if isRF then
+- bs1 = GetTimeInfo("sector1")
+- end
+- -- save lt for delta vs last function
+- mOld_ls1 = bs1
++ local lastSector = GetCarInfo("sector") - 1
++ if lastSector == 0 then lastSector = mSectors end
+
+- -- compare
+- if bs1 > 0 and mOld_bs1 > 0 then
+- mDelta_lptb = bs1 - mOld_bs1
+- mDelta_Sect1b = mDelta_lptb
+- end
++ local ls = 0.00000
+
+- mOld_bs1 = GetTimeInfo("bestsector1")
++ local start = lastSector
++ -- check whether to sum all sector diff values or not
++ if mDelta_total_split_sectors then start = 1 end
++ for i = start, lastSector, 1 do
++ local ls = mLastSectorTime[i][1]
++ local old_bs = mBestSectorTime[i][2]
++ if ls > 0 and old_bs > 0 then
++ lpt = lpt + (ls - old_bs)
++ end
++ end
+
+ else
+- -- diff sector 2
+- local bs2 = GetTimeInfo("lastsector2")
+- if isRF then
+- bs2 = GetTimeInfo("sector2")
+- end
+- -- save lt for delta vs last function
+- mOld_ls2 = bs2
+-
+- -- compare with old value
+- if bs2 > 0 and mOld_bs2 > 0 then
+- if mDelta_total_split_sectors then
+- mDelta_lptb = mDelta_Sect1b + (bs2 - mOld_bs2)
+- else
+- mDelta_lptb = bs2 - mOld_bs2
+- end
+- end
+- -- backup
+- mOld_bs2 = GetTimeInfo("bestsector2")
+- end
+- end
+-
+- -- display delta by default
+- lpt = GetTimeInfo("realdiffbest")
+-
+- if mDiffSectorDelay > GetTicks() then
+- lpt = mDelta_lptb
++ -- display delta by default
++ lpt = GetTimeInfo("realdiffbest")
+ end
+
+ return lpt
diff --git a/tricks/k2000_test.lua b/tricks/k2000_test.lua
new file mode 100644
index 0000000..2ac27f9
--- /dev/null
+++ b/tricks/k2000_test.lua
@@ -0,0 +1,40 @@
+function global_custom_enterSessionEvent(devType)
+
+ Marquee( GetContextInfo("carname") , 50 )
+
+ -- trying to play with Ext/Warn LEDS
+ -- 1 to activate, then 0 to deactivate
+ for j = 1,0 do
+ -- i will set/unset outtermost leds, then innermost leds recursively, to get a funny 'K2000' behaviour. <img src="http://www.eksimracing.com/forum/Smileys/default/wink.gif" alt=";)" title="Wink" class="smiley" border="0">
+ for i = 0,2 do
+
+ -- outter most, from left
+ SetWarnLed(1+i, j)
+ -- outter most from right
+ SetWarnLed(6-i, j)
+
+ -- same as above, with external leds (yeah, with i=2, the SAME led will be set twice. That’s not a problem)
+ SetExtLed(1+i, j)
+ SetExtLed(5-i, j)
+
+ -- The following doesn’t change anything to led status... they are definitely OFF ...
+ SLISendReport(1)
+ SLISleep(200)
+ end
+ end
+
+ -- same trick with RPMleds
+ for j = 1, 0 do
+ for i = 0, 6 do
+ led = led.format("RPM%d", i)
+ mRPMLedTable[led] = j
+ led = led.format("RPM%d",12-i)
+ mRPMLedTable[led] = j
+ SetRPMLed("mRPMLedTable")
+ SLISendReport(1)
+ SLISleep(200)
+ end
+ end
+
+ return 1
+end
diff --git a/tricks/k2000_test2.lua b/tricks/k2000_test2.lua
new file mode 100644
index 0000000..bcdac3d
--- /dev/null
+++ b/tricks/k2000_test2.lua
@@ -0,0 +1,74 @@
+- ================================
+-- custom globals
+mGugusse_EnterExit = 0
+mGugusse_OldTicks = 0
+mGugusse_step = 0
+mGugusse_Delay = 1000
+mGugusse_state = 1
+mGugusse_count = 0
+
+-- ================================
+-- custom functions
+
+-- ================================
+-- custom events
+-- from global_custom_scripts.lua
+function global_custom_enterSessionEvent(devType)
+
+ mGugusse_EnterExit = 1
+
+ return 2
+end
+
+-- from global_custom_scripts.lua
+function global_custom_exitSessionEvent(devType)
+ return 2
+end
+
+function global_custom_deviceReport(devType)
+ -- type your script here (just before sending report to the device )
+
+ -- get current device name
+-- SMX2
+ local dev = mDeviceType[devType]
+ if dev == nil then dev = "none" end
+ -- SMX3
+-- local dev = GetDeviceType(devType)
+ -- restrict to sli-pro device
+ if mGugusse_EnterExit == 1 and dev == "SLI-PRO" then
+
+ -- time ref
+ if GetContextInfo("ticks") > mGugusse_OldTicks then
+ -- set the delay (1sec)
+ mGugusse_OldTicks = GetContextInfo("ticks") + mGugusse_Delay;
+ -- set the leds with current state 1 or 0
+ SetWarnLed(1+mGugusse_step, mGugusse_state)
+ SetWarnLed(6-mGugusse_step, mGugusse_state)
+ -- print info for Debug Console
+ print(mGugusse_EnterExit, dev, mGugusse_step);
+ -- next led
+ mGugusse_step = mGugusse_step + 1
+ -- check the max value
+ if mGugusse_step > 2 then
+ -- reset all var
+ mGugusse_OldTicks = GetContextInfo("ticks") + mGugusse_Delay;
+ mGugusse_step = 0
+ if mGugusse_state == 0 then
+ mGugusse_state = 1
+ else
+ mGugusse_state = 0
+ end
+ -- job done, exit
+ if mGugusse_count > 3 then
+ mGugusse_EnterExit = 0
+ end
+ mGugusse_count = mGugusse_count + 1
+ end
+ end
+ -- set gear digit OFF (right and left panel are already OFF)
+ SetGearDigit(" ")
+ -- bypass
+ return 1
+ end
+ return 2
+end
diff --git a/tricks/marquee.lua b/tricks/marquee.lua
new file mode 100644
index 0000000..546f374
--- /dev/null
+++ b/tricks/marquee.lua
@@ -0,0 +1,35 @@
+-- marquee
+function Marquee(mString, mDelay)
+ local length = string.len(mString)
+
+ for i = 1,length+12 do
+
+ local mRight = ""
+ local mIddle = " "
+ local mLeft = ""
+
+ -- right
+ for j = i-5,i do
+ if j <= 0 then mRight = mRight .. " " end
+ if j > 0 and j <= length then mRight = mRight .. string.sub(mString, j, j) end
+ if j > length then mRight = mRight .. " " end
+ end
+ -- middle
+ j = i - 6
+ if j > 0 and j <= length then mIddle = string.sub(mString, j , j) end
+ -- left
+ for j = i-12,i-7 do
+ if j <= 0 then mLeft = mLeft .. " " end
+ if j > 0 and j <= length then mLeft = mLeft .. string.sub(mString, j, j) end
+ if j > length then mLeft = mLeft .. " " end
+ end
+
+
+ SetRightDigits(mRight)
+ SetGearDigit(mIddle)
+ SetLeftDigits(mLeft)
+
+ SLISendReport(1)
+ SLISleep(mDelay)
+ end
+end
diff --git a/tricks/sectorTimes.lua b/tricks/sectorTimes.lua
new file mode 100644
index 0000000..426bb0c
--- /dev/null
+++ b/tricks/sectorTimes.lua
@@ -0,0 +1,159 @@
+
+-- true to show the total delta splits sector 1 + sector 2
+-- false to show the delta of sector 2 only
+mDelta_total_split_sectors = false
+
+-- display sector split times
+mSectorSplitDelay = 8000
+
+
+mLastSectorTime = {}
+mBestSectorTime = {}
+mCurrentSector = 0
+mSectors = 0
+
+function initSectorTimes()
+ --mSectors = GetContextInfo("sectorcount")
+ mLastSectorTime = {}
+ mBestSectorTime = {}
+ mCurrentSector = 1
+end
+
+function getSector(sector)
+ local currentSector = GetCarInfo("sector")
+ if sector == nil or sector == 0 then
+ sector = currentSector
+ elseif sector == -1 then
+ sector = currentSector - 1
+ if sector == 0 then
+ sector = table.getn(mLastSectorTime)
+ end
+ end
+ return sector
+end
+function getSectorBest(sector)
+
+ --return GetContextInfo(string.format("bestsector%d", getSector(sector)))
+ return mBestSectorTime{getSector(sector)}{1}
+
+end
+function getSectorTime(sector)
+
+ --if isAppRFactor(GetContextInfo("simulation")) then
+ -- return GetContextInfo(string.format("sector%d", getSector(sector)))
+ --else
+ -- return GetContextInfo(string.format("lastsector%d", getSector(sector)))
+ --end
+ return mLastSectorTime{getSector(sector)}{1}
+
+end
+
+
+
+function UpdateSectorTimes()
+ local sector = GetCarInfo("sector")
+
+ if mCurrentSector ~= sector then
+ local lastSector = sector - 1
+ if lastSector == 0 then lastSector = table.getn(mLastSectorTime) end
+
+ local ls = 0.00000
+
+ if isAppRFactor(GetContextInfo("simulation")) then
+ ls = GetTimeInfo(string.format("sector%d", lastSector))
+ else
+ ls = GetTimeInfo(string.format("lastsector%d", lastSector))
+ end
+
+ print ( "sector "..lastSector.." : " .. ls)
+
+ --
+ if mLastSectorTime[lastSector] == nil then
+ mLastSectorTime[lastSector] = {0.00000, 0.00000}
+ end
+ -- save previous best sector for sector split times
+ mLastSectorTime[lastSector][2] = mLastSectorTime[lastSector][1]
+ -- stores last sector time
+ mLastSectorTime[lastSector][1] = ls
+
+ --
+ if mBestSectorTime[lastSector] == nil then
+ mBestSectorTime[lastSector] = {0.00000, 0.00000}
+ end
+ -- save previous best sector for sector split times
+ mBestSectorTime[lastSector][2] = mBestSectorTime[lastSector][1]
+ if ls ~= 0.0 and mBestSectorTime[lastSector][1] > ls then
+ -- stores best sector time if better than best :)
+ mBestSectorTime[lastSector][1] = ls
+ end
+
+
+ -- save current sector value
+ mCurrentSector = sector
+ -- set ticks for display
+ mDiffSectorDelay = GetTicks() + mSectorSplitDelay
+ end
+end
+
+-- return delta time vs last time + sector diff
+function SectorSplitLast()
+
+ local lastSector = GetCarInfo("sector") - 1
+ if lastSector == 0 then lastSector = table.getn(mLastSectorTime) end
+
+ local ls = 0.00000
+
+ if isAppRFactor(GetContextInfo("simulation")) then
+ ls = GetTimeInfo(string.format("sector%d", lastSector))
+ else
+ ls = GetTimeInfo(string.format("lastsector%d", lastSector))
+ end
+
+ local start = lastSector
+ -- check whether to sum all sector diff values or not
+ if mDelta_total_split_sectors then start = 1 end
+ for i = start, lastSector, 1 do
+ local ls = mLastSectorTime[i][1]
+ local old_ls = mLastSectorTime[i][2]
+ if ls > 0 and old_ls > 0 then
+ lpt = lpt + (ls - old_ls)
+ end
+ end
+
+
+ return lpt
+end
+
+-- return delta time vs best time + sector diff
+function SectorSplitBest()
+
+ local lpt = 0.0
+
+ if mDiffSectorDelay ~= nil and GetTicks() < mDiffSectorDelay then
+
+ local lastSector = GetCarInfo("sector") - 1
+ if lastSector == 0 then lastSector = mSectors end
+
+ local ls = 0.00000
+
+ local start = lastSector
+ -- check whether to sum all sector diff values or not
+ if mDelta_total_split_sectors then start = 1 end
+ for i = start, lastSector, 1 do
+ local ls = mLastSectorTime[i][1]
+ local old_bs = mBestSectorTime[i][2]
+ if ls > 0 and old_bs > 0 then
+ lpt = lpt + (ls - old_bs)
+ end
+ end
+
+ else
+ -- display delta by default
+ lpt = GetTimeInfo("realdiffbest")
+ end
+
+ return lpt
+end
+
+--==============================================
+require "scripts/slidevice"