Hello I am new to this group
I was hoping there would be a palm developers group!
Anyway, my question:

I am working on an application which will eventually be running all day.
This would run down the battery on the palm very quickly I am sure so I
would like to be able to program the application to power down the Palm when
it is not being used by a user. The majority of the application is user
independent anyway. I have been reading the online manuals for AlmSetAlarm
and AlmSetProcAlarm and it all looks very promising. I have a couple of
queries though. I am not sure how all the stuff I have read will fit
together. For example, I don't know what kind of thing I need to put in as
the parameters of the function. It told me to see AlmAlarmProcPtr but I
didn't really understand this.
What I want to do is power down the Palm (should I use the system only
function SysSleep?) and then after a certain length of time I want to call
another form which will power up the palm again and perform some operations.
As I have said I have looked into AlmSetProcAlarm and also read a bit about
the fact that time should be passed in/stored as in seconds from 1904
(what's that all about?!).

If you would be so kind as to explain to me how it all fits together and
help me by suggesting a plan of how I would code this I would be most
grateful!

I have had an answer to this already which I didnt understand but couldnt
reply to the bloke who answered coz that would have cost me money or
something?!
He said this:
"All times expressed in seconds are expressed in seconds since midnight Jan
1st 1904. You don't actually have to calculate the number of seconds since
then although the TimeManager section of the Programmers Reference lists
functions that will do that. You can simply get the current time (in seconds
since 1904) and add to that when you want your alarm to go off.  For
instance the following code will get you the second count since 1904 + 5
minutes.
UINT32 alarmTime = TimGetSeconds + 5 * 60;
You can then use that to set the alarm time. Also you'll want to know that
each time an alarm goes off you need to reset it if you want it to happen
again (i.e. a repeating alarm).

As for putting the Palm to sleep, if you have an event loop just make sure
to use evtWaitForever i.e. (EvtGetEvent(&event, evtWaitForever) then after
some length of time (which is a user preference) the device will just go to
sleep.  The primary difference between a proc alarm and a regular alarm is
that regular alarms turn the display on while you can have proc alarms,
which run without anything visible to the end user of your application.
Finally your question about the AlmAlarmProcPtr is define as follows (in
AlarmMgr.h if you are curious)
typedef void (*AlmAlarmProcPtr)(UInt16  /* AlmProcCmdEnum*/ almProcCmd,
SysAlarmTriggeredParamType *paramP);
all that means is that functions that take a AlmAlarmProcPtr need to be
passed a function name that has the following prototype
void yourFunctionName(UInt16 procCmd, SysAlarmTriggeredParamType* paramP);

What you do with the procCmd and the param passed to you is up to you.  But
that function will be called when the alarm goes off (if it's a proc alarm)
otherwise your application will get launched with a launch code of
sysAppLaunchCmdAlarmTriggered in which you should do short calculations
(don't do any UI stuff here that would block other alarms) and then again
with a launch code of sysAppLaunchCmdDisplayAlarm where you should display
UI if that's what's needed and also reset the alarm if you want it to go off
again."

I think I was with him until he started talking about EvtGetEvent, etc. I
think what I do want to use is AlmSetAlarm to set the alarm as I want to
display something on the screen but then AlmSetProcAlarm is attractive too
as I want to call a function at the time the alarm goes. Oh and in his last
paragraph what are procCmd and paramP? I think he assumed my C was better
than it is!

Any help would be gratefully received

Gareth James <><
Sparkling Armada Ltd
Swansea, UK




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

Reply via email to