Important: The information in this document is obsolete and should not be used for new development.
GetScaledBatteryInfo
You can use theGetScaledBatteryInfofunction 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
BatteryInfodata structure, which returns information about the specified battery.DESCRIPTION
TheGetScaledBatteryInfofunction 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
- 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.
![]()
whichBatterydetermines whetherGetScaledBatteryInforeturns information about a particular battery or about the total battery level. The value ofGetScaledBatteryInfoshould be in the range of 0 toBatteryCount(). If the value ofwhichBatteryis 0,GetScaledBatteryInforeturns a summation of all the batteries, that is, the effective battery level of the whole system. If the value ofwhichBatteryis 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 thewhichBatteryparameter:
Value of whichBatteryInformation returned 0 Total 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 theInfoThe
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 batteryInstalled7 A battery is installed. batteryCharging6 The battery is charging. chargerConnectedX 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 INFORMATION
The trap is_PowerMgrDispatch($A09E). The selector value forGetScaledBatteryInfois 12 ($0C) in the low word of register D0. TheBatteryInfodata 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 SEE ALSO
TheBatteryInfodata type is described in "Battery Information Structure," on page 6-27.