Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

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


GetScaledBatteryInfo

You can use the GetScaledBatteryInfo function to find out the condition of the battery or batteries.

void GetScaledBatteryInfo(short whichBattery, 
                           BatteryInfo *theInfo);
whichBattery
The battery for which you want information. Set this parameter to 0 to receive combined information about all the batteries in the computer.
theInfo
A pointer to a BatteryInfo data structure, which returns information about the specified battery.
DESCRIPTION
The GetScaledBatteryInfo function provides a generic means of returning information about the battery or batteries in the system. Instead of returning a voltage value, the function returns the battery level as a fraction of the total possible voltage.

Note
Battery technologies such as nickel cadmium (NiCad) and nickel metal hydride (NiMH) have replaced sealed lead acid batteries in portable Macintosh computers. There is no single algorithm for determining the battery voltage that is correct for all portable Macintosh computers.
The value of whichBattery determines whether GetScaledBatteryInfo returns information about a particular battery or about the total battery level. The value of GetScaledBatteryInfo should be in the range of 0 to BatteryCount(). If the value of whichBattery is 0, GetScaledBatteryInfo returns a summation of all the batteries, that is, the effective battery level of the whole system. If the value of whichBattery is out of range, or the selected battery is not installed, GetScaledBatteryInfo 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 level for all batteries
From 1 to BatteryCount()Battery level for the selected battery
Less than 0 or greater than BatteryCount()0 in all fields of theInfo

The flags character contains several bits that describe the battery and charger state. If a bit value is 1, that feature is available or is operating; if the bit value is 0, that feature is not operating. Unused bits are reserved by Apple for future expansion.
Bit nameBit numberDescription
batteryInstalled7A battery is installed.
batteryCharging6The battery is charging.
chargerConnectedXThe charger is connected.

The value of warningLevel is the battery level at which the first low battery warning message will appear. The function returns a value of 0 in some cases when it's not appropriate to return the warning level.

The value of batteryLevel is the current level of the battery. A value of 0 represents the voltage at which the Power Manager will force the computer into sleep mode; a value of 255 represents the highest possible voltage.

ASSEMBLY-LANGUAGE INFORMATION
The trap is _PowerMgrDispatch ($A09E). The selector value for GetScaledBatteryInfo is 12 ($0C) in the low word of register D0. The BatteryInfo data are returned in the low word of register D0 as follows:
BitsContents
31-24Flags
23-16Warning level
15-8Reserved
7-0Battery level

SEE ALSO
The BatteryInfo data type is described in "Battery Information Structure," on page 6-27.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
3 JUL 1996