I tried sticking that command in my AppEventLoop function following the 
function EvtGetEvent and that didn't work for me, the device still went to 
sleep.  Where else can you place it so it is constantly accessed while my app 
is running?

~Tony


>>> [EMAIL PROTECTED] 5/24/2005 8:24 AM >>>
If you're in some sort of loop, you can just call  
EvtResetAutoOffTimer() periodically for as long as you need to stay  
awake...

Dave


On May 24, 2005, at 7:38 AM, Dr. Vesselin Bontchev wrote:

> Hello folks,
>
> While my application is working, it flashes various information on a  
> form and it's an annoyance if the device decides to go to sleep in the  
> middle of the process. What is the proper way of preventing that?
>
> The Palm OS Programmer's Companion
>
> http://www.palmos.com/dev/support/docs/palmos/PalmOSCompanion/ 
> AppStartupAndStop.html#998079
>
> suggests registering to receive notifications about the  
> sysNotifySleepRequestEvent even and then doing
>
>     ((SleepEventParamType *) (notify->notifyDetailsP))->deferSleep++;
>
> If I do that, the device indeed doesn't go to sleep for the duration  
> of the process. Unfortunately, it refuses to go to sleep after the  
> process has finished and I have unregistered with the Nitification  
> manager. Even the power button cannot turn the device off any more - I  
> have to reset it.
>
> The Companion also says:
>
> "After you defer sleep, your code is free to finish what it was doing.  
> When it is finished, you must allow the system to continue with the  
> sleep event. To do so, create a keyDownEvent with the resumeSleepChr  
> and the command key bit set (to signal that the character is virtual)  
> and add it to the event queue. When the system receives this event, it  
> will again broadcast the sysNotifySleepRequestEvent to all clients. If  
> deferSleep is 0 after all clients return, then the system knows it is  
> safe to go to sleep, and it broadcasts the sysNotifySleepNotifyEvent  
> to all of its clients."
>
> It doesn't explain how exactly to do that. I tried the following:
>
>     EventType theEvent;
>
>     MemSet (&theEvent, sizeof (EventType), 0);
>     theEvent.eType = keyDownEvent;
>     theEvent.data.keyDown.chr = resumeSleepChr;
>     theEvent.data.keyDown.keyCode = 0;
>     theEvent.data.keyDown.modifiers = commandKeyMask;
>     EvtAddEventToQueue (&theEvent);
>
> and it works - but *too* well, in the sense that it unconditionally  
> puts the device to sleep!
>
> How can I do that properly, folks? I want the auto-off attempts to  
> fail while the process is going on - but I don't want to block the  
> power-off button and I don't want the device to go to sleep  
> immediately after the process has finished; I want it to do that only  
> if enough idle time has passed.
>
> Or should I use some completely different approach? Like, messing up  
> with the auto-off settings (SysSetAutoOffTime), resetting the auto-off  
> timer (EvtResetAutoOffTimer) or something else like that?
>
> http://www.palmos.com/dev/support/docs/palmos/PalmOSReference/ 
> SystemEventManager.html#1071368
>
> Regards,
> Vesselin
> -- 
> For information on using the PalmSource Developer Forums, or to  
> unsubscribe, please see http://www.palmos.com/dev/support/forums/ 
>


-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/

Reply via email to