RegisterSearchFAQMemberlistUsergroupsLog in
Reply to topic Page 1 of 1
Time Delay in Script
Author Message
Reply with quote
Post Time Delay in Script 
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.

View user's profile Send private message
Reply with quote
Post  
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.


Code:
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:
if TicksSinceUnderFive < getTickRate() * 60


View user's profile Send private message
Reply with quote
Post  
Thanks for the tip. After reading this, it would be interesting to have a "call me later" function where you could go:

schedule("FunctionName", millisecondsFromNow)

That could add some flexibility, for certain.


_________________
Brent Picasso
CEO and Founder, Autosport Labs
Facebook | Twitter
View user's profile Send private message Send e-mail
Reply with quote
Post  
You could simply have the race capture start when you move and not stop until you power it off. That's exactly what we do. I cannot ever be sure we wont be stopped for some length of time in a race.

View user's profile Send private message
Display posts from previous:
Reply to topic Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum