Advanced Search
Apple Developer Connection
Member Login Log In | Not a Member? Contact ADC

Previous Book Contents Book Index Next

Inside Macintosh: Devices /
Chapter 6 - Power Manager / Power Manager Reference
Power Manager Dispatch Routines / Getting Information About the Internal Batteries


You can use the GetBatteryTimes function to find out about how much battery time remains.

void GetBatteryTimes (short whichBattery, 
                     BatteryTimeRec *theTimes);
The battery for which you want to know the time remaining. Specify 0 to get combined information about all the batteries.
A pointer to a battery time structure, which contains information about the time remaining for the batteries. The BatteryTimeRec data type is described on page 6-28.
The GetBatteryTimes function returns information about the time remaining on the computer's battery or batteries. The time values are in seconds. The value of theTimes.expectedBatteryTime is the estimated time remaining based on current use patterns. The values of theTimes.minimumBatteryTime and theTimes.maximumBatteryTime are worst-case and best-case estimates, respectively. The value of theTimes.timeUntilCharged is the time that remains until the battery or batteries are fully charged.

The value of whichBattery determines whether GetBatteryTimes returns the time information about a particular battery or the total time for all batteries. The value of GetScaledBatteryInfo should be in the range of 0 to BatteryCount(). If the value of whichBattery is 0, GetBatteryTimes returns a total time for all the batteries, that is, the effective battery time for the whole system. If the value of whichBattery is out of range, or the selected battery is not installed, GetBatteryTimes will return a result of 0 in all fields. Here is a summary of the effects of the whichBattery parameter:
Value of whichBatteryInformation returned
0Total battery time for all batteries
From 1 to BatteryCount()Battery time for the selected battery
Less than 0 or greater than BatteryCount()0 in all fields of theTimes

The trap is _PowerMgrDispatch ($A09E). The selector value for GetBatteryTimes is 28 ($1C) in the low word of register D0. The pointer to BatteryTimeRec is passed in register A0.

Previous Book Contents Book Index Next

© Apple Computer, Inc.
3 JUL 1996

Get information on Apple products.
Visit the Apple Store online or at retail locations.

Copyright © 2004 Apple Computer, Inc.
All rights reserved. | Terms of use | Privacy Notice