Just about anything can generate a nilEvent, so setting EvtGetEvent to
timeout after 5ms will generate a nilEvent only if there are no events on
the event queue for 5ms.  The best way around this is to increase the
frequency of the nilEvent timeout.  I've suggested in the past to at least
double the required frequency.  Here's the bad news:  I think the best
resolution you can hope to achieve using nilEvents is around 10ms.  There
are a couple of other programs that achieve rather fast resolution hacking
into the hardware but I wouldn't suggest it or presume to know how its done.


Another possible problem:
>ticks_per_5ms = (SysTicksPerSecond() / 1000) * 5;
SysTicksPerSecond() typically returns a Word which is much less than 1000
(it varies between devices but I think it's typically around 100).  So,
SysTicksPerSecond/1000 is less than 1.  Unless you convert it to a float
first, your answer will always be 0.  ( integer math states 100/1000*5 = 0).
I don't know what giving EvtGetEvent a timeout value of 0 will produce.
Maybe Palm or another developer knows.

-----Original Message-----
From: Brian Whitman <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Date: Monday, June 07, 1999 7:44 PM
Subject: timing


>
>'Twas suggested that I ask this question here. Would love any feedback. I
>know the Palm's 'not meant' to do hard lock timing things, but... any
>ideas?
>
>---------- Forwarded message ----------
>Date: Mon, 7 Jun 1999 18:25:23 -0400 (EDT)
>From: Brian Whitman <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: [handheld-music] pilot tips
>
>
>I've asked this on pilot.programmer and got stuck still even with some
>great help. I'm having trouble working out a good, stable timing loop for
>the Palm OS for MIDI events.
>
>Not sure how many palm coders we have on here, but here goes:
>
>My old timing loop was just a:
>
>EvtGetEvent(&event, 5);
>/* do stuff that should happen every 5 ms */
>
>since I wanted to do something every 5ms. So if there were no user events,
>it would 'time out' after 5ms and execute my time-based code (send out
>controllers, etc...)
>
>But this doesn't really work. As in: it sends out controller data every so
>often, but surely not every 5ms. More like every 100ms. Someone brought up
>the fact that other system events will slow it down, since it won't always
>'time out' at 5-- so he suggested and I implemented:
>
>
>ticks_per_5ms = (SysTicksPerSecond() / 1000) * 5;
>next_tick = TimGetTicks() + ticks_per_5ms;
>do
> {
> EvtGetEvent(&event, max (0, next_tick - TimGetTicks()) );
> next_tick = next_tick + ticks_per_5ms;
>                /* do stuff that should happen every 5 ms */
>...
>
>But -- this doesn't do it either. What happens here is that the stuff that
>should happen every 5ms only happens *if I'm sending it user events as
>well*, i.e. drawing the pen around, whatever...
>
>I can't find source anywhere of timing specific palm code, so I'd like to
>see if anyone else uses something different. The first thing works-- but
>the resolution isn't as good as I know the Palm can do.
>
>-brian
>
>
>
>
>------------------------------------------------------------------------
>ONElist:  the best source for group communications.
>http://www.onelist.com
>Join a new list today!
>------------------------------------------------------------------------
>handheld-music web: http://www.crudites.org/soundventures/handheld-music
>
>
>


Reply via email to