Important: The information in this document is obsolete and should not be used for new development.
GetScaledBatteryInfo
You can use theGetScaledBatteryInfo
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
TheGetScaledBatteryInfo
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.
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.
whichBattery
determines whetherGetScaledBatteryInfo
returns information about a particular battery or about the total battery level. The value ofGetScaledBatteryInfo
should be in the range of 0 toBatteryCount()
. If the value ofwhichBattery
is 0,GetScaledBatteryInfo
returns a summation of all the batteries, that is, the effective battery level of the whole system. If the value ofwhichBattery
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 thewhichBattery
parameter:
Value of whichBattery
Information 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 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 name Bit number Description batteryInstalled
7 A battery is installed. batteryCharging
6 The battery is charging. chargerConnected
X The 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 forGetScaledBatteryInfo
is 12 ($0C) in the low word of register D0. TheBatteryInfo
data 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
TheBatteryInfo
data type is described in "Battery Information Structure," on page 6-27.