1.) Is it possible to set the timer to 0 or specific value?
2.) Is it possible to stop/pause the timer counting? Or at least stop it from triggering the interrupt in switch statment with timerafter function?
Thank you for answers!
Gregor Krušič
How to restart the timer?
-
- Junior Member
- Posts: 7
- Joined: Mon May 26, 2014 10:32 pm
-
- Respected Member
- Posts: 318
- Joined: Tue Dec 15, 2009 12:46 am
It's not possible to either stop a timer / reset the counter to a particular value. Instead of resetting the counter to zero I'd suggest maintaining an offset variable that you add to the timer value. Instead of stopping the timer you could use a boolean guard on the case to decide whether to wait for events on the timer, for example:
select {
// Only wait for events on the timer if t_enabled is non-zero.
case t_enabled => t :> time:
...
break;
}
One thing worth mentioning is that currently all timers on the same tile return the same time which can be useful when coordinating actions across multiple tasks. If timers could be stopped / reset then you would lose this property.
select {
// Only wait for events on the timer if t_enabled is non-zero.
case t_enabled => t :> time:
...
break;
}
One thing worth mentioning is that currently all timers on the same tile return the same time which can be useful when coordinating actions across multiple tasks. If timers could be stopped / reset then you would lose this property.