int DeviceGetBatteryLevel();

 

Gets the current battery level of the device.

 

Return Value

 

Returns a value between 0 and 100 representing the percentage of battery charge on the device.

 

Remarks

 

DeviceGetBatteryLevel() returns the current battery charge level of the device expressed as a percentage between 0 and 100.

 

Windows Simulator NOTE: To provide values for the Windows Simulator, be sure to edit C:\DragonFireSDK\DragonFireSDK.ini and modify the value for BatteryLevel in the Device section.

 

NOTE: Calling DeviceGetBatteryLevel() without a prior call to DeviceSetBateryMonitoring() will make the call to DeviceSetBateryMonitoring() for you, and it is your responsibility to turn off battery monitoring when you no longer need battery information.

 

Availability

 

Available in DragonFireSDK 1.4 and later.

 

Example

 

#include "DragonFireSDK.h"

 

int MyFont;

int BatteryLevelText;

 

int Value;

char TextBuffer[100];

 

void AppMain()

{  

  LandscapeMode();

 

  DeviceSetBatteryMonitoring(1);

  MyFont = FontAdd("Helvetica", "Regular", 18, 0x00FF00);

 

  Value = DeviceGetBatteryLevel();

  sprintf(TextBuffer, "Battery Level: %d", Value);  

  BatteryLevelText = TextAdd(10, 10, TextBuffer, MyFont);

}

 

//===============================================

void OnTimer()

{

  Value = DeviceGetBatteryLevel();

  sprintf(TextBuffer, "Battery Level: %d", Value);  

  TextSetText(BatteryLevelText, TextBuffer);

}

 

//===============================================

void AppExit()

{

 

}