According to the section on power management in the docs, your app
should not be running when the unit is 'off'.  EvtGetEvent should
basically stop returning until the unit is turned back on.  That has
always been my experience, but there might be exceptions.

Your app is a power hog while it is running.  The system actually has
three power states, sleep, doze, and on.  The system typically spends a
lot of time in doze mode waiting for user input.  But you are asking to
do processing every system tick.  Do you really need to update your
animations at 100 Hz?  Typically you would use the SysTicksPerSecond
call to calculate a timeout value for EvtGetEvent which is the bare
minimum to meet your requirements (2 Hz, 5 Hz, 10 Hz, etc.)  The system
can then 'doze' the rest of the time.

Sorry I couldn't be of more help,
-jjf

-----Original Message-----
From: revcom [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 24, 2000 7:13 PM
To: Palm Developer Forum
Subject: Why does my app kill the batteries??


Hi there,

When running my app that I have developed, I shut the Palm off with the
app
still running.

This seems to decrease the battery life noticeably.

What am I doing wrong?

I have attached my EventLoop code in the case someone can spot my error

Thank you for your help,

================================
static void EventLoop(void)
{
 short err;
 EventType event;
 long appStarted = TimGetSeconds();

 g.running = true;
 do
 {
  if (TimGetSeconds() >= appStarted + FIVE_MINUTES) {
   if (invalidUserName()) {
    FrmAlert(1001);
    break;
   }
  }

  EvtGetEvent(&event, 1);//For now

  doLetterTimer(&g.teacherWords);//Letter finished yet?
  doLetterTimer(&g.studentWords);
  doAnimation(&g.teacherWords); //Do next animations if time
  doAnimation(&g.studentWords);

  //Stop animation and repair damage BEFORE menu drops
  if ((event.eType == keyDownEvent) &&
   (event.data.keyDown.chr == menuChr) &&
   (FrmGetFormId(FrmGetActiveForm()) == MAIN_FORM_ID)) {
   int redrawStudentLetter = studentAnimating() ?
          g.studentWords.animateLetter : -1;
   int redrawTeacherLetter = teacherAnimating() ?
          g.teacherWords.animateLetter : -1;

   stopAndResetAnimations();
   //(drawLetter won't draw if letterIndex < 0
   if (redrawStudentLetter >= 0) {
    repairStudentArea();
   }
   drawLetter(&g.teacherWords, redrawTeacherLetter);
  }
  if ((event.eType == keyDownEvent) &&
   g.disableButtons) {
   switch (event.data.keyDown.chr) {
    case launchChr: //Application silk-screen
    case menuChr: //Menu silk-screen
    case calcChr: //Calculator silk-screen
    case findChr: //Find silk-screen
    case hard1Chr: //ToDo button
    case hard2Chr: //PhoneList button
    case hard3Chr: // button
    case hard4Chr: //Memo button
    case hardPowerChr://Power button
    case pageUpChr: //ScrollUp button
    case pageDownChr://ScrollDown button

     SndPlaySystemSound(sndConfirmation);
     continue;
    break;
   }
  }
  if (!SysHandleEvent(&event)) {
   if (!MenuHandleEvent((void *)0, &event, &err)) {
    if (event.eType == appStopEvent) {//Query if screen not clear
     if (teacherAreaClear() && studentAreaClear()) {
      g.running = false;   //Just quit
     }
     else {
      if (!FrmAlert(1008)) {
       g.running = false;
      }
     }
    }
    if (!ApplicationHandleEvent(&event)) {
     FrmDispatchEvent(&event);
    }
   }
  }
/*  if (event.eType != nilEvent) {
   Err err = MemHeapCheck(MemPtrHeapID(StudentNames[0]));
   if (err) {
    StrPrintF(g.tempStr, "Heap check failed %d", err);
    ErrFatalDisplayIf(true, g.tempStr);
   }
  }
*/
 } while (g.running);
}


Robert Crago
Revelation Computing Pty Limited
PO Box 459, ASPLEY
Brisbane, Australia 4034


-- 
For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palm.com/devzone/mailinglists.html

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palm.com/devzone/mailinglists.html

Reply via email to