GetScaledBatteryInfoYou can use the
GetScaledBatteryInfofunction to find out the condition of the battery or batteries.
void GetScaledBatteryInfo(short whichBattery, BatteryInfo *theInfo);
- The battery for which you want information. Set this parameter to 0 to receive combined information about all the batteries in the computer.
- A pointer to a
BatteryInfodata structure, which returns information about the specified battery.
GetScaledBatteryInfofunction 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.
The value of
- 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.
GetScaledBatteryInforeturns information about a particular battery or about the total battery level. The value of
GetScaledBatteryInfoshould be in the range of 0 to
BatteryCount(). If the value of
GetScaledBatteryInforeturns a summation of all the batteries, that is, the effective battery level of the whole system. If the value of
whichBatteryis out of range, or the selected battery is not installed,
GetScaledBatteryInfowill return a result of 0 in all fields. Here is a summary of the effects of the
Information returned 0 Total battery level for all batteries From 1 to
Battery level for the selected battery Less than 0 or greater than
0 in all fields of
flagscharacter 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 name Bit number Description
7 A battery is installed.
6 The battery is charging.
X The charger is connected.
The value of
warningLevelis 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
batteryLevelis 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 INFORMATIONThe trap is
_PowerMgrDispatch($A09E). The selector value for
GetScaledBatteryInfois 12 ($0C) in the low word of register D0. The
BatteryInfodata are returned in the low word of register D0 as follows:
Bits Contents 31-24 Flags 23-16 Warning level 15-8 Reserved 7-0 Battery level
BatteryInfodata type is described in "Battery Information Structure," on page 6-27.