VoiceIt Technologies, LLC

Web Based Support
It is currently Fri Sep 10, 2010 7:56 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Fixed time loops and time delay routines
PostPosted: Fri Apr 21, 2006 9:57 am 
Offline

Joined: Fri Apr 21, 2006 9:37 am
Posts: 2
I am new to PocketStudio and to Palm OS in general. I am used to Delphi programning, and there is a handy "timer" component for that.

I looked into the repeat button, but it requires the user to hold the button. I aslo tried to mimic the event loop from the project source, but I could not make it work. I tried to use the nil event from the form, but then there is no control of the timing.

Does anyone have an example of code, or any suggestions?

Thanks.


Top
 Profile  
 
 Post subject: Delay if you're still interested
PostPosted: Wed Jul 18, 2007 10:33 am 
Offline

Joined: Wed Jul 18, 2007 10:08 am
Posts: 1
here's how I did a fine-grained delay for an IR program to mimic the remote control for my Olympus camera. I needed a precise 'mark' time between sending bursts of IR carrier, but 'systaskdelay' is too coarse because 'systicksperscond' is usually equal to 100, providing only 10 msec increments.

Unit delay;

interface
uses
PalmOS;
procedure Finedelay(delaynum:uint32);
function ticksper1m:uint32;

implementation

procedure Finedelay(delaynum:uint32);
begin
asm
move.l delaynum, d0
@countdown:
add #-1,d0
bne @countdown
end;
end;

function ticksper1m:uint32;
var startcount:uint32;
begin
StartCount:=TimGetTicks;
FineDelay(1000000);
result:=TimGetTicks-startcount;
end;

end.

'ticksper1m' counts how many 'systicks' elapse during 1000000 iterations of the simple asm loop 'Finedelay'. On a 16mhz dragonball, its about 144 ticks. On 33 mhz CLie, its about 112 or so. You'd think it's be 72 but oh well, whatever. From there you can calculate the number you'd pass to 'finedelay' for a given # of uSECs. Since 'systickspersecond' is usually=100, then one loop on my 16 mhz handspring =1.44 uSECs. Do the math from there. This works most of the time but I noticed that 1 out of about 10 IR transmissions failed to trip the camera. I fixed it by sending
the IR code four times. THere is probably some system trap or something that interrupts 'finedelay.' I'm also a newbie and still am after sweating away at this Palm stuff for over 4 years off and on, so there are probably more elegant and bulletproof solutions, but this does fine for me, maybe will help,
Russ


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 27, 2007 12:04 pm 
Offline

Joined: Thu Dec 27, 2007 11:47 am
Posts: 6
Other way:

function SysTaskDelay(delay: Int32): Err; external sysTrapSysTaskDelay;


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group