Is there any way to pause/resume a timer?
Specifically, I want a timer (for a fixation duration) to run when in a specific state, pause when leaving that state (when fixation is broken), and then resume (without restarting completely) when re-entering the state (re-fixation).
What would be the best way to do something like this? Some options that come to mind are using render_actions or explicitly getting times with now(), but if I could pause/resume timers directly that seems more straightforward.
I implemented this as a schedule action:
%define start_fixation_timer ()
if (fix_timer_off) {
fix_timer_off = false
schedule (
delay = 0ms
duration = 10ms
repeats = -999
cancel = fix_timer_off
) {
total_fix_time += 10
}
}
%end
I pause the timer by setting fix_timer_off = true, reset it with total_fix_time = 0, and check for a completed fixation with total_fix_time >= fixation_duration.
While a bit of error in the timing is fine for my purposes, I get a lot of the following errors printed in the console: 03:26:01: WARNING: Scheduled action is starting 780us behind intended schedule
03:26:01: ERROR: Scheduled action is starting 2206us behind intended schedule
How would you recommend dealing with these errors? Is there a way to suppress them below some threshold?