On Tue, Jun 05, 2001 at 04:23:55PM -0500, Herbert Valliant wrote:
>
> I sent the following message Sunday afternoon. As it was not returned in
> the digest, I assume it got lost in the ether. So here it is again.
> Apologies if you already received this.
>
> 2001/06/02
>
> Dear Listers
>
> I need to execute a function exactly once a second on the
> second.
Do a TimGetTicks() to get the current clock.
Have your EvtGetEvent wait for 900-950 milliseconds (90-95 ticks).
Poll TimGetTicks until it is greater than the original value + 100.
This won't work if you get a notification or an alarm or something
since that will interrupt the polling loop, but you shouldn't be
trying to do something that critical (note that most such things
merely queue something).
If you need to be even more precise than 1ms, there are ways...
This is the technique I use (plus reading the timer register to go to
a higher rez) for MIDI in MusicBox (Part of ZBoxZ, GPL source at
palmboxer.sourceforge.net).
> I dreamed up the following scheme which appears to function,
> except for occassonal bursts of timing jitter of a few ticks
> which could be a problem:
>
> static void EventLoop(void)
> {
> the usual stuff
> .
> .
> timeout = 75; //ticks = 750mS
>
> do
> {
> EvtGetEvent (&event,timeout);
> if ......
> if ......
> if ......
> if (event is not premature);
> {
> poll until seconds counter changes value;
> retrieve and display current ticks; // for testing only
> do my stuff; // not included in test program
> }
> calculate new timeout;
> }
> while .... ;
> }
>
> Can anyone suggest a more elegant and/or possibly more precise
> solution?
>
> Please accept my thanks in advance for any help/suggestions.
>
> sincerely
> Herb Valliant
>
>
>
>
>
> --
> For information on using the Palm Developer Forums, or to unsubscribe, please see
>http://www.palmos.com/dev/tech/support/forums/
--
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/