Battery Info


Basic provides several functions which can be used to monitor the status of the battery.


GetBatteryStatus()

0 = Waiting for Data
1 = Battery Status Unknown
2 = Battery Charging
3 = Battery Discharging
4 = Battery Not Charging
5 = Battery Full


GetBatteryLevel()

This function returns the current battery level.


GetBatteryScale()

This function returns the maximum battery level.
The percent of battery charge remaining can be calculated with the following:

Percent = GetBatteryLevel() / GetBatteryScale() * 100



GetBatteryTemp()

This function returns the current battery temperature in celsius.


GetBatteryVolts()

This function returns the current battery voltage.


It takes a few seconds for battery info to be returned from Android the first time you request the info. Placing the following code at the beginning of your program will pause your program until the data becomes available.

timeout = Time() + 5000
Do Until Time() > timeout or GetBatteryStatus() <> 0
Wait 250
Loop






Become a Patron