Re: Help with timer function
You're lacking a loop that keeps you inside your function until the condition applies. You also need to query the time inside that loop, or else it won't stop.
Also, the current parameter makes no sense at all and introduces an obscure dependency on another function.
Re: Help with timer function
I tried a while loop, but never ended....what should I do with the current parameter then? I need t2-t1 = elapsed time, where current is t1, correct?
Re: Help with timer function
This is not working code, it's just to illustrate the concept. You still need to supply a time measuring function (any one will do, but I recommend clock() from the CRT) and its return type.
Code:
void busy_delay(unsigned int seconds)
{
datatype now = time_func() / TICKS_PER_SECOND;
while(time_func() / TICKS_PER_SECOND - now < seconds) {
// just wait
}
}
Re: Help with timer function
Ok, so its not possible just to use gettickcount, like I did?
Re: Help with timer function
GetTickCount is one of the function you can substitute for my imaginary time_func(). TICKS_PER_SECOND would then equal 1000. I just don't think it's a good choice.
Re: Help with timer function
ok, thanks for your help :)