Article # 451, added by Geoworks, historical record
| first | previous | index | next | last |

Detecting power down on the OmniGo.



Q. How can my application detect when the user has turned the power
   on or off on the OmniGo 100?

A. First of all, unless your application is affected by external events
   (such as serial input) or for some other reason needs to know when
   the OmniGo powers on or off, you should not worry about power
   notifications.

   If your application does require this information, then it can
   register a notification routine with the power driver. There is
   only a limited number of vectors available, so your registration
   is not guaranteed to be successful.

   During device power down, there is nothing you can do to prevent the
   powerdown.

   On powerup, your routine can @send a message to let your application
   know that unit is powering back on. The notification routine should
   be small to prevent power on/off from becoming sluggish.

   Here is how you register for notification:
       #define DR_POWER_ON_OFF_NOTIFY 26

       GeodeHandle        powerDriverHandle;
       DriverPassParams   passParams;
       DriverReturnParams returnParams;

       powerDriverHandle = GeodeGetDefaultDriver( GDDT_POWER_MANAGEMENT );
       ...
       DriverCallEntryPoint ( powerDriverHandle,
			      DR_POWER_ON_OFF_NOTIFY,
			      &passParams,
			      &returnParams );

   In passParams, dx:cx = fptr to call back routine.

   returnParams will have carry set if you could not register for the
   notification (because too many routines are already registered).

   The callback routine must be written in assembly because the ax
   register will contain either ax = 0 (PNC_POWER_SHUTTING_OFF) or
   ax = 1 (PNC_POWER_TURNING_ON).