Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3368: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3370: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3371: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3372: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
OrbWorks Community Forum • View topic - Ptoolbox and ticks()
Page 1 of 1

PostPosted: Sun Aug 17, 2003 2:24 pm
by stefangrove
Hi

I have encountered a very strange and puzzling problem. A while ago I finished a small metronome programme. It calculates the metronome beats, plays a sound and waits for the next beat using something like while(ticks()<next_tick){}. This worked fine.

Now I have refitted the interface using PtoolboxLib without canging the actual metronome function and the metronome beeps have become eratic and very fast. At first I thought the ticks (since reset) might have become faster, but after using GetTicksPerSec() to calculate the difference, it still did not help.

The weirdest was, however, when I backtracked my steppes and removed all the PtoolBoxLib functions, it still didn't work!

Any ideas where I should look for the problem? I am not crazy.[:p]

Thanks Stef

PostPosted: Sun Aug 17, 2003 3:08 pm
by jstadolnik
There are two potential causes I can think of...

Every 497 days the ticks counter will wrap (provided you're palm has survived that long without a reset). If your app saves the next_tick time away to a database and you cross that magic wrap time boundary, then your calculations will get seriously thrown off the next time you bring up your app. Though I would think that while(ticks()<next_tick){} would end up waiting an extremely long time in your case.

Further complicating matters is that under the hood ticks() calls the TimGetTicks() palm API function which returns a 32 bit unsigned integer. Well, PocketC integers are always treated as signed numbers in calculations. This means that if ticks() returns a very larger number (with the 32th bit set or rather value greater than 2147483647), that PocketC will treat this as a negetive number rather than a positive one. As such, if you don't do a soft reset for roughly 248 days, PocketC is going to seriously mangle your time calculations. Try a soft reset and see if this fixes the problem. The best solution here is for PocketC to support unsigned integer math. I would suggest reporting this problem to Jeremy (dewey@orbworks.com).

Joe

The PToolboxLib guy.
http://www.geocities.com/retro_01775/PToolboxLib.htm

PostPosted: Mon Aug 18, 2003 2:18 am
by jstadolnik
A partial solution to the ticks() unsigned int return value would be to mask off the most significant bit. For example:

int newTicks() { return(ticks()&0x7fffffff); }

However, this still wouldn't fix the wrapping problem where the counter rolls over back to zero. To do that you'd have to keep track of the previous return value and see how it compares to the next newTicks() value you get. If their difference (new-old) is negetive, you know that a wrap occured and can compensate.

Joe

The PToolboxLib guy.
http://www.geocities.com/retro_01775/PToolboxLib.htm

PostPosted: Mon Aug 18, 2003 8:56 am
by stefangrove
Thanx for the responce.

The possibility of pocketC seeing ticks() as a negative number would not be a problem, since my emulator has to be reset quite regularly ;-) and next is calculated based on ticks():

1 next=ticks();
2 while (!stop){
3 metronomebeat...
4 next=next+l; (with l being the delay between every beat)
5
6 while (ticks()<next & !stop)
7 if (event(10) !=0)
8 stop=1;
9 }


I have managed to overcome the problem. In line 8 I had used Fevent(0) in stead of the event(10) to escape the loop, which caused the bad timing. Don't really understand why...

Is it better to use only event() OR Fevent() or can I mix them?

Stef

PostPosted: Mon Aug 18, 2003 12:34 pm
by jstadolnik
<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">
I have managed to overcome the problem. In line 8 I had used Fevent(0) in stead of the event(10) to escape the loop, which caused the bad timing. Don't really understand why...
<hr height="1" noshade id="quote"></blockquote id="quote"></font id="quote">

How does Fevent(10) behave? It may be that Fevent(0) is taking longer than 10 ticks in some cases, it does do a lot things but it should still be pretty fast.

<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">
Is it better to use only event() OR Fevent() or can I mix them?
<hr height="1" noshade id="quote"></blockquote id="quote"></font id="quote">

It's generally not good to mix them because event() cannot capture form events. Also, there are cases where event() can steal events from Fevent().

What I'm purplexed by is your statment that you removed all the PToolbox hooks out and the timing was still screwy. Is that still the case?

Joe

The PToolboxLib guy.
http://www.geocities.com/retro_01775/PToolboxLib.htm

PostPosted: Mon Aug 18, 2003 4:32 pm
by stefangrove
I did everything over and the timing is ok now. It also worked bad with event(0) = too fast I guess.

Fevent() isn't really necessary because I only need to register a screen tap to go ahead.
Currently I have

while(ticks()<next & !stop){
if (event(2)>=1)
stop=1;
}

With Fevent() it didn't work. (The loop stayed stuck)


I am getting errors reading from unallocated memory. Could this be because of buttons being disabled or hidden more than once? How can I test if a button is disabled or not?

PostPosted: Mon Aug 18, 2003 4:48 pm
by jstadolnik
<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">
With Fevent() it didn't work. (The loop stayed stuck)
<hr height="1" noshade id="quote"></blockquote id="quote"></font id="quote">

Fevent will not trap pen events unless you define variables for the x & y coordinates to write into. Use the Fctl BINDX and BINDY commands to do this.

<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">
I am getting errors reading from unallocated memory. Could this be because of buttons being disabled or hidden more than once? How can I test if a button is disabled or not?
<hr height="1" noshade id="quote"></blockquote id="quote"></font id="quote">

Hiding or disabling buttons shouldn't have any effect. However, operating on a button which doesn't exist in the current form can generate such errors. Use the Fctl EXISTS command to determine if form object is available.

Joe


The PToolboxLib guy.
http://www.geocities.com/retro_01775/PToolboxLib.htm