a question about app_easy_timer

4 posts / 0 new
Last post
RandyYu
Offline
Last seen:2 years 8 months ago
加入:2015-01-28 08:49
a question about app_easy_timer

when use the app_easy_timer() call back a function,
for example app_easy_timer(100,Fn1);
At a location in the program,I want to check if the function of Fn1 is excute or not.
if it does not excute I will to cannel the callback.
(the method to add a flag in Fn1 does not fit for me )

thanks

Keywords:
Device:
MT_dialog
Offline
Last seen:4 weeks 1 day ago
工作人员
加入:2015-06-08 11:34
Hi RandyYu,

Hi RandyYu,

I am not aware any other method to suggest if a function has allready run or not, other than placing a flag to indicate that, why that method does not suite you ?

如果你know for sure that you timer has started counting (the app_easy_timer() returns an id once its set, you can store that id in a variable) so you can set this id to an EASY_TIMER_INVALID_TIMER when the handler occurs, therefore you can check if the value of the variable !=EASY_TIMER_INVALID_TIMER the callback hasn't run yet and if variable == EASY_TIMER_INVALID_TIMER the timer has elapsed and the function has been called.

Thanks MT_dialog

RandyYu
Offline
Last seen:2 years 8 months ago
加入:2015-01-28 08:49
I had modified as you said

I had modified as you said
in the callback function
{
handler = EASY_TIMER_INVALID_TIMER ;
}
处理程序= app_easy_timer ();
when I want to cancel or modify the timer
I have a judgement if(handler != EASY_TIMER_INVALID_TIMER )
{
app_easy_timer_cancel(handler)
}
some times it will stop at ASSERT_WARNING(0) ,

when use the there function it's often encounter the problem.
how to slove the problem?

thanks very much

MT_dialog
Offline
Last seen:4 weeks 1 day ago
工作人员
加入:2015-06-08 11:34
Hi RandyYu,

Hi RandyYu,

如果你get that error it means that either you are cancelling a timer with an invalid handler value or you cancel a timer that has no callback (either a NULL callback or an emptycallback). Check the app_easy_timer_cancel() there is a condition that checks the above mentioned issues, you can check that in order to debug it.

I suppose that the reason is that when you cancel the timer (when you call the app_easy_timer_cancel()) you dont set the handler value in EASY_TIMER_INVALID_TIMER, so when running the cancelation function you pass a valid handle with a canceled callback and you get an error since you attemp to cancel an allready cancelled timer.

Thanks MT_dialog