Skip to content

Commit 963a895

Browse files
committed
besttimetoday: add script to track best time of day
1 parent 6af21ec commit 963a895

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

besttimetoday.lua

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
local Y, M, D = getDateTime()
2+
local TODAY = string.format('%d%d%d', Y, M, D)
3+
4+
local bestTimeToday = loadVar('best_time_today')
5+
local deltaId = addChannel('LapDeltaToday', 10, 3, -100, 100, 's')
6+
7+
8+
-- reset?
9+
if loadVar('best_time_day') ~= TODAY then
10+
info('it is a new day')
11+
saveVar('best_time_day', TODAY)
12+
__update_besttime(nil)
13+
end
14+
15+
16+
function __update_besttime(bestTime)
17+
info('updating today\'s best time to: '..bestTime)
18+
saveVar('best_time_today', bestTime)
19+
bestTimeToday = bestTime
20+
end
21+
22+
23+
function tick_besttimetoday()
24+
-- track best time today
25+
local bestTimeSession = getBestTime()
26+
if bestTimeToday == nil or bestTimeSession < bestTimeToday then
27+
__update_besttime(bestTimeSession)
28+
end
29+
-- calculate delta
30+
setChannel(deltaId, 60*(getPredTime()-bestTimeToday))
31+
end
32+

build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ declare -A file_map=(
88
["frequency"]="frequency.lua"
99
["vminmax_simple"]="vminmax_simple.lua"
1010
["brakebias"]="brakebias.lua"
11+
["besttimetoday"]="besttimetoday.lua"
1112
)
1213

1314
# Check if any arguments are provided

main.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ function onTick()
2020
-- tick_mock()
2121
-- tick_vminmax_simple()
2222
-- tick_brakebias()
23+
-- tick_besttimetoday()
2324
end

0 commit comments

Comments
 (0)