Let me preface this by saying that scripting is most assuredly not my strong point:), so sorry if this is an easy question.
Anyway, I would like to be able to setup a automatic logging start/stop script such that at say 5mph it starts logging, then stops logging once the speed has been below 5mph and stayed there for perhaps 60 seconds. I use the logger primarily for autocross, and I would like it to start when I leave my spot in grid and pull up to the starting line, but then not shut off while I am sitting at the line.
Time Delay in Script
-
- Posts: 22
- Joined: Fri Nov 01, 2013 9:48 pm
- Location: Bay Area, CA
Not sure if you found an answer as it has been a while since the post, but you can try the following. note: I haven't tested this, but I'll toss it out as an idea that might work on the latest firmware.
We're basically creating a counter to count the number of times we go through the loop (the 'loop' is the onTick method that is continuously excited at the interval set by 'setTickRate' as long as the unit is powered) when we're under 60. the counter in this case is set to '1' which should mean the loop executes one time per second. (if you set tick rate to 10, set the 'if TicksSinceUnderFive < 60 then' to 'if TicksSinceUnderFive < 600 then' )
Sidenote for the Autosportlabs crew: this may be a good use case for a 'getTickRate' method, to make this more dynamic the if line could be:
Code: Select all
setTickRate(1) #setting it to 1 to make it easier to understand
TicksSinceUnderFive = 0 #creating a counter
function onTick()
if getGpsSpeed() > 5 then
TicksSinceUnderFive = 0 #reset counter
startLogging()
else
TicksSinceUnderFive = TicksSinceUnderFive + 1 #under 5 increase the counter
if TicksSinceUnderFive > 60 then #has it been 60 seconds/cycles
stopLogging()
TicksSinceUnderFive = 0 #reset the counter, overkill
end
end
end
We're basically creating a counter to count the number of times we go through the loop (the 'loop' is the onTick method that is continuously excited at the interval set by 'setTickRate' as long as the unit is powered) when we're under 60. the counter in this case is set to '1' which should mean the loop executes one time per second. (if you set tick rate to 10, set the 'if TicksSinceUnderFive < 60 then' to 'if TicksSinceUnderFive < 600 then' )
Sidenote for the Autosportlabs crew: this may be a good use case for a 'getTickRate' method, to make this more dynamic the if line could be:
Code: Select all
if TicksSinceUnderFive < getTickRate() * 60
-
- Posts: 18
- Joined: Sat Aug 09, 2014 5:55 pm
- Location: Florida