Ed,
The tick counter WILL stop when your device goes to sleep, and the devices WILL go to sleep while running your app unless you want to disable sleep entirely, which could be bad news from a battery standpoint. I think your best bet is to NOT just save TimGetTicks() but save TimGetSeconds() plus an offset for how many ticks past the second you are. Every time the device powers up again in your app you need to resynch your tickcounter with the device second counter (TimGetSeconds). Wait for TimGetSeconds() to change value, then immediately establish a new base for your ticks offset. Good news is that this resynch takes, by definition, less than one second. If you save the seconds+tick offset, and resynch when necessary, the values will be good across power on/off and resets as well.
Bob.
Ed Pugh wrote:
Hi.
I am thinking about writing an application that accurately timestamps "events" (which are timed by either a screen button tap or by pressing a hard key) to the nearest 1/10 second. So, timestamps should reflect the time-of-day to the nearest 1/10 second; something like:
HH:MM:SS.s
When the application is first started, I can measure the 10 ms tick counter value at the next time-of-day clock increment, thus "synchronizing" the one against the other.
However, there is a possibility that the user could turn off the palm or allow the auto-off timer to expire (while the application is running), and then turn the Palm back on. If this happens, the tick counter will stop while the Palm is "off". (In fact, I would like the user to be able to turn the palm back on AND enter a new timestamp, by pressing a hard-key.)
I would like the application to work with PalmOS 2.0 onward, but MUST at least work with PalmOS 3.0 onward. (Some of my potential users have PDA's running older PalmOS versions.)
Questions:
1. How do I determine if the tick counter stops at any time while the application is "running"? Is there an event that my application can receive when the Palm is turned back on after being turned off or after going into auto-off sleep? OR, is there an event that it can receive BEFORE going to sleep as a result of pressing the power key or the auto-off timer expiry?
2. Is "sleeping" the ONLY thing that can disrupt the synchronization between the two clocks? So long as the Palm stays "on", will the syncronization be maintained, or should it be periodically updated?
3. If an application "intercepts" a hard key, and the palm is turned off (or times out) while that application is running, will pressing the hard-key still go to the application after powering up the Palm, or will it launch its "normal" application instead? (I can find this out later by actually trying it when I get back home.)
Thanks and regards,
Ed.
-- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
